// Path: app/src/main/java/be/artoria/belfortapp/activities/LanguageChoiceActivity.java
// public class LanguageChoiceActivity extends BaseActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_language_choice);
//         final TextView tv = (TextView) findViewById(R.id.to);
//         tv.setTypeface(athelas);
//         final TextView tv1 = (TextView) findViewById(R.id.string_welcome);
//         tv1.setTypeface(athelas);
//         final TextView tv2 = (TextView) findViewById(R.id.string_belfry);
//         tv2.setTypeface(athelas);
//         final TextView tv3 = (TextView) findViewById(R.id.string_choose_language);
//         tv3.setTypeface(athelas);
//     }
// 
// 
//     @Override
//     public boolean onCreateOptionsMenu(Menu menu) {
//         // Inflate the menu; this adds items to the action bar if it is present.
//         getMenuInflater().inflate(R.menu.language_choice, menu);
//         return true;
//     }
// 
//     @Override
//     public boolean onOptionsItemSelected(MenuItem item) {
//         // Handle action bar item clicks here. The action bar will
//         // automatically handle clicks on the Home/Up button, so long
//         // as you specify a parent activity in AndroidManifest.xml.
// 
//         return super.onOptionsItemSelected(item);
//     }
// 
//     public void langSelected(View view) {
//         /* Setting the locale in response to a button click */
//         final Locale locale;
//         switch (view.getId()) {
//             case(R.id.english):
//                 locale = new Locale("en");
//                 DataManager.lang = DataManager.Language.ENGLISH;
//                 break;
//             case(R.id.french):
//                 locale = new Locale("fr");
//                 DataManager.lang = DataManager.Language.FRENCH;
//                 break;
//             case(R.id.dutch):
//             default:
//                 /* Default case is dutch */
//                 DataManager.lang = DataManager.Language.DUTCH;
//                 locale = new Locale("nl");
//         }
// 
//         setLang(locale,this);
//         /* Saving preferences*/
//         PrefUtils.setNotFirstTime();
// 
//         /* Opening the Main screen */
//         final Intent intent = new Intent(this,MainActivity.class);
//         startActivity(intent);
//     }
// 
//     public static void setLang(Locale locale, Context ctx){
//         Locale.setDefault(locale);
//         final Configuration config = new Configuration();
//         config.locale = locale;
//         ctx.getApplicationContext().getResources().updateConfiguration(config, null);
//         PrefUtils.saveLanguage(DataManager.getInstance().getCurrentLanguage());
//     }
// }


import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.provider.ContactsContract;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import be.artoria.belfortapp.R;
import be.artoria.belfortapp.activities.LanguageChoiceActivity;
    // get preferences
    @SuppressWarnings("NewApi")
    private static SharedPreferences getPrefs()
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)        {
            return CONTEXT.getSharedPreferences(ARG_USER_KEY, Context.MODE_MULTI_PROCESS);
        } else {
            return CONTEXT.getSharedPreferences(ARG_USER_KEY, Context.MODE_PRIVATE);
        }
    }

    public static DataManager.Language getLanguage() {
        final Locale locale = getContext().getResources().getConfiguration().locale;
        final String lang = locale.getLanguage();
        if("en".equals(lang)){ return DataManager.Language.ENGLISH;}
        if("fr".equals(lang)){ return DataManager.Language.FRENCH;}
        /* default choice is dutch */
        return DataManager.Language.DUTCH;
    }

    public static void saveLanguage(DataManager.Language lang){
        String lng = "nl";//default dutch
        if(lang == DataManager.Language.ENGLISH){lng="en";}
        if(lang == DataManager.Language.FRENCH){lng ="fr";}
        getPrefs().edit().putString(ARG_LANG,lng).apply();
    }

    public static void loadLanguage(Context context){
        final String lang = getPrefs().getString(ARG_LANG,"nl");/*Default dutch*/
        final Locale locale = new Locale(lang);
// Path: app/src/main/java/be/artoria/belfortapp/activities/LanguageChoiceActivity.java
// public class LanguageChoiceActivity extends BaseActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_language_choice);
//         final TextView tv = (TextView) findViewById(R.id.to);
//         tv.setTypeface(athelas);
//         final TextView tv1 = (TextView) findViewById(R.id.string_welcome);
//         tv1.setTypeface(athelas);
//         final TextView tv2 = (TextView) findViewById(R.id.string_belfry);
//         tv2.setTypeface(athelas);
//         final TextView tv3 = (TextView) findViewById(R.id.string_choose_language);
//         tv3.setTypeface(athelas);
//     }
// 
// 
//     @Override
//     public boolean onCreateOptionsMenu(Menu menu) {
//         // Inflate the menu; this adds items to the action bar if it is present.
//         getMenuInflater().inflate(R.menu.language_choice, menu);
//         return true;
//     }
// 
//     @Override
//     public boolean onOptionsItemSelected(MenuItem item) {
//         // Handle action bar item clicks here. The action bar will
//         // automatically handle clicks on the Home/Up button, so long
//         // as you specify a parent activity in AndroidManifest.xml.
// 
//         return super.onOptionsItemSelected(item);
//     }
// 
//     public void langSelected(View view) {
//         /* Setting the locale in response to a button click */
//         final Locale locale;
//         switch (view.getId()) {
//             case(R.id.english):
//                 locale = new Locale("en");
//                 DataManager.lang = DataManager.Language.ENGLISH;
//                 break;
//             case(R.id.french):
//                 locale = new Locale("fr");
//                 DataManager.lang = DataManager.Language.FRENCH;
//                 break;
//             case(R.id.dutch):
//             default:
//                 /* Default case is dutch */
//                 DataManager.lang = DataManager.Language.DUTCH;
//                 locale = new Locale("nl");
//         }
// 
//         setLang(locale,this);
//         /* Saving preferences*/
//         PrefUtils.setNotFirstTime();
// 
//         /* Opening the Main screen */
//         final Intent intent = new Intent(this,MainActivity.class);
//         startActivity(intent);
//     }
// 
//     public static void setLang(Locale locale, Context ctx){
//         Locale.setDefault(locale);
//         final Configuration config = new Configuration();
//         config.locale = locale;
//         ctx.getApplicationContext().getResources().updateConfiguration(config, null);
//         PrefUtils.saveLanguage(DataManager.getInstance().getCurrentLanguage());
//     }
// }


// Path: app/src/main/java/be/artoria/belfortapp/app/PrefUtils.java
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.provider.ContactsContract;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import be.artoria.belfortapp.R;
import be.artoria.belfortapp.activities.LanguageChoiceActivity;

    // get preferences
    @SuppressWarnings("NewApi")
    private static SharedPreferences getPrefs()
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)        {
            return CONTEXT.getSharedPreferences(ARG_USER_KEY, Context.MODE_MULTI_PROCESS);
        } else {
            return CONTEXT.getSharedPreferences(ARG_USER_KEY, Context.MODE_PRIVATE);
        }
    }

    public static DataManager.Language getLanguage() {
        final Locale locale = getContext().getResources().getConfiguration().locale;
        final String lang = locale.getLanguage();
        if("en".equals(lang)){ return DataManager.Language.ENGLISH;}
        if("fr".equals(lang)){ return DataManager.Language.FRENCH;}
        /* default choice is dutch */
        return DataManager.Language.DUTCH;
    }

    public static void saveLanguage(DataManager.Language lang){
        String lng = "nl";//default dutch
        if(lang == DataManager.Language.ENGLISH){lng="en";}
        if(lang == DataManager.Language.FRENCH){lng ="fr";}
        getPrefs().edit().putString(ARG_LANG,lng).apply();
    }

    public static void loadLanguage(Context context){
        final String lang = getPrefs().getString(ARG_LANG,"nl");/*Default dutch*/
        final Locale locale = new Locale(lang);
        LanguageChoiceActivity.setLang(locale,context);