mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-15 21:27:51 +01:00
Also handle resetting language to default properly #733
This commit is contained in:
parent
c1925a4e64
commit
12f9386fac
@ -163,7 +163,7 @@ public class GBApplication extends Application {
|
||||
|
||||
deviceManager = new DeviceManager(this);
|
||||
String language = prefs.getString("language", "default");
|
||||
setLanguage(language, null);
|
||||
setLanguage(language);
|
||||
|
||||
deviceService = createDeviceService();
|
||||
loadBlackList();
|
||||
@ -475,9 +475,9 @@ public class GBApplication extends Application {
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void setLanguage(String lang, @Nullable Context baseContext) {
|
||||
public static void setLanguage(String lang) {
|
||||
if (lang.equals("default")) {
|
||||
language = Locale.getDefault();
|
||||
language = Resources.getSystem().getConfiguration().locale;
|
||||
} else {
|
||||
language = new Locale(lang);
|
||||
}
|
||||
@ -486,9 +486,7 @@ public class GBApplication extends Application {
|
||||
|
||||
// FIXME: I have no idea what I am doing
|
||||
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||
if (baseContext != null) {
|
||||
baseContext.getResources().updateConfiguration(config, baseContext.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_LANGUAGE_CHANGE);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||
|
@ -149,8 +149,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
String newLang = newVal.toString();
|
||||
try {
|
||||
GBApplication.setLanguage(newLang, getBaseContext());
|
||||
// recreate();
|
||||
GBApplication.setLanguage(newLang);
|
||||
} catch (Exception ex) {
|
||||
GB.toast(getApplicationContext(),
|
||||
"Error setting language: " + ex.getLocalizedMessage(),
|
||||
|
Loading…
Reference in New Issue
Block a user