mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-20 23:41:45 +02:00
Restore locale when returning to system default language
This commit is contained in:
@@ -32,14 +32,24 @@ public class BaseAppCompatActivity extends AppCompatActivity {
|
||||
public static final String PREFERENCE_APP_THEME = "app_theme";
|
||||
public static final String PREFERENCE_LANGUAGE = "language";
|
||||
|
||||
private static Locale systemDefaultLocale = null;
|
||||
|
||||
public static Context createBaseContext(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String language = prefs.getString(PREFERENCE_LANGUAGE, "");
|
||||
if (language.isEmpty() || language.equals("default")) {
|
||||
if (systemDefaultLocale != null) {
|
||||
Locale.setDefault(systemDefaultLocale);
|
||||
systemDefaultLocale = null;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
if (systemDefaultLocale == null) {
|
||||
systemDefaultLocale = Locale.getDefault();
|
||||
}
|
||||
|
||||
Locale locale;
|
||||
String[] localeParts = TextUtils.split(language, "-");
|
||||
if (localeParts.length == 2) {
|
||||
|
Reference in New Issue
Block a user