use lowercase main locale to specifically fix problems with sr_zz and sr_ZZ

This commit is contained in:
Helium 2022-03-21 09:49:12 +01:00
parent 115d0f8120
commit 034ebe780f
3 changed files with 3 additions and 4 deletions

View file

@ -67,7 +67,7 @@ public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showSecondaryLocaleDialog(subtype.getLocale(), subtype.isAsciiCapable());
showSecondaryLocaleDialog(subtype.getLocale().toLowerCase(Locale.ENGLISH), subtype.isAsciiCapable());
return true;
}
});

View file

@ -514,12 +514,11 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_PAGE_ID, defValue);
}
// TODO: test whether this gets updated on keyboard language switch!
public static Locale getSecondaryLocale(final SharedPreferences prefs, final String mainLocaleString) {
final Set<String> encodedLocales = prefs.getStringSet(PREF_SECONDARY_LOCALES, new HashSet<>());
for (String loc : encodedLocales) {
String[] locales = loc.split("§");
if (locales.length == 2 && locales[0].equals(mainLocaleString))
if (locales.length == 2 && locales[0].equals(mainLocaleString.toLowerCase(Locale.ENGLISH)))
return LocaleUtils.constructLocaleFromString(locales[1]);
}
return null;

View file

@ -202,7 +202,7 @@ public class ScriptUtils {
*/
public static int getScriptFromSpellCheckerLocale(final Locale locale) {
// need special treatment of serbian latin, which would get detected as cyrillic
if (locale.toString().equals("sr_ZZ"))
if (locale.toString().toLowerCase(Locale.ENGLISH).equals("sr_zz"))
return ScriptUtils.SCRIPT_LATIN;
String language = locale.getLanguage();
Integer script = mLanguageCodeToScriptCode.get(language);