mirror of
https://github.com/gabehf/tempus.git
synced 2026-03-16 10:45:58 -07:00
fix: show "System default" language option, sort languages alphabetically
This commit is contained in:
parent
bfd6f28d7a
commit
8a57f8f389
4 changed files with 38 additions and 9 deletions
|
|
@ -201,12 +201,22 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
localePref.setEntries(entries);
|
||||
localePref.setEntryValues(entryValues);
|
||||
|
||||
localePref.setDefaultValue(entryValues[0]);
|
||||
localePref.setSummary(Locale.forLanguageTag(localePref.getValue()).getDisplayLanguage());
|
||||
String value = localePref.getValue();
|
||||
if ("default".equals(value)) {
|
||||
localePref.setSummary(requireContext().getString(R.string.settings_system_language));
|
||||
} else {
|
||||
localePref.setSummary(Locale.forLanguageTag(value).getDisplayLanguage());
|
||||
}
|
||||
|
||||
localePref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
LocaleListCompat appLocale = LocaleListCompat.forLanguageTags((String) newValue);
|
||||
AppCompatDelegate.setApplicationLocales(appLocale);
|
||||
if ("default".equals(newValue)) {
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.getEmptyLocaleList());
|
||||
preference.setSummary(requireContext().getString(R.string.settings_system_language));
|
||||
} else {
|
||||
LocaleListCompat appLocale = LocaleListCompat.forLanguageTags((String) newValue);
|
||||
AppCompatDelegate.setApplicationLocales(appLocale);
|
||||
preference.setSummary(Locale.forLanguageTag((String) newValue).getDisplayLanguage());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue