Commit d937577c authored by Niklas Fix's avatar Niklas Fix 🎓

fix default lang on first app start

parent 2a6bbdec
......@@ -40,7 +40,11 @@ public class App extends Application implements SettingsDataSource.FetchSettings
public void onCreate() {
super.onCreate();
SharedPreferences prefs = android.preference.PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
String defaultLanguage = prefs.getString(Constants.USER_LANG, getApplicationContext().getResources().getString(R.string.pref_language_eng_value));
String deviceLang = Locale.getDefault().getDisplayLanguage();
String langEN = getApplicationContext().getResources().getString(R.string.pref_language_eng_value);
String langDE = getApplicationContext().getResources().getString(R.string.pref_language_ger_value);
String defaultLang = deviceLang.equals(langEN) || deviceLang.equals(langDE) ? deviceLang : langDE;
String defaultLanguage = prefs.getString(Constants.USER_LANG, defaultLang);
Lingver.init(this, Objects.requireNonNull(defaultLanguage));
boolean isNightMode = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(Constants.IS_NIGHT_MODE, false);
if (isNightMode) {
......@@ -65,6 +69,6 @@ public class App extends Application implements SettingsDataSource.FetchSettings
@Override
public void onFetchSettingsFailed(@NotNull String reason) {
System.out.println("Fetching settings failed.");
System.out.println("Fetching settings failed: " + reason);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment