clear language setting if it matches the system-wide setting
If the user can set the language using the Setting app, then there is not reason to use the Languages hack. This then clears the preference if it matches the language of the system-wide locale. This also removes the current system-wide language from the Languages menu. closes #943
This commit is contained in:
parent
6456f56ced
commit
1b390cceca
@ -73,6 +73,9 @@ public final class Languages {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove the current system language from the menu
|
||||||
|
tmpMap.remove(currentLocale.getLanguage());
|
||||||
|
|
||||||
/* SYSTEM_DEFAULT is a fake one for displaying in a chooser menu. */
|
/* SYSTEM_DEFAULT is a fake one for displaying in a chooser menu. */
|
||||||
tmpMap.put(USE_SYSTEM_DEFAULT, activity.getString(resId));
|
tmpMap.put(USE_SYSTEM_DEFAULT, activity.getString(resId));
|
||||||
nameMap = Collections.unmodifiableMap(tmpMap);
|
nameMap = Collections.unmodifiableMap(tmpMap);
|
||||||
@ -116,13 +119,21 @@ public final class Languages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(17)
|
@TargetApi(17)
|
||||||
|
/**
|
||||||
|
* Handles setting the language if it is different than the current language,
|
||||||
|
* or different than the current system-wide locale. The preference is cleared
|
||||||
|
* if the language matches the system-wide locale or "System Default" is chosen.
|
||||||
|
*/
|
||||||
public static void setLanguage(final ContextWrapper contextWrapper, String language, boolean refresh) {
|
public static void setLanguage(final ContextWrapper contextWrapper, String language, boolean refresh) {
|
||||||
if (Build.VERSION.SDK_INT >= 24) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
Utils.debugLog(TAG, "Languages.setLanguage() ignored on >= android-24");
|
Utils.debugLog(TAG, "Languages.setLanguage() ignored on >= android-24");
|
||||||
Preferences.get().clearLanguage();
|
Preferences.get().clearLanguage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (locale != null && TextUtils.equals(locale.getLanguage(), language) && (!refresh)) {
|
if (TextUtils.equals(language, DEFAULT_LOCALE.getLanguage())) {
|
||||||
|
Preferences.get().clearLanguage();
|
||||||
|
locale = DEFAULT_LOCALE;
|
||||||
|
} else if (locale != null && TextUtils.equals(locale.getLanguage(), language) && (!refresh)) {
|
||||||
return; // already configured
|
return; // already configured
|
||||||
} else if (language == null || language.equals(USE_SYSTEM_DEFAULT)) {
|
} else if (language == null || language.equals(USE_SYSTEM_DEFAULT)) {
|
||||||
Preferences.get().clearLanguage();
|
Preferences.get().clearLanguage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user