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