From 7d6263a38daf3a9b80229811687d4703793ee86d Mon Sep 17 00:00:00 2001 From: Josh Imbriani Date: Tue, 25 Jun 2019 08:44:21 -0700 Subject: [PATCH] Correcting sort order of languages for non en-us locales Test: Manually tested Fixes: b/78125395 Change-Id: I1b370d4ae4995cc7d9f05409be97d4ecf9104241 --- src/com/android/settings/tts/TextToSpeechSettings.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java index d4c73180025..70d56d4f300 100644 --- a/src/com/android/settings/tts/TextToSpeechSettings.java +++ b/src/com/android/settings/tts/TextToSpeechSettings.java @@ -49,6 +49,7 @@ import com.android.settings.widget.SeekBarPreference; import com.android.settingslib.search.SearchIndexable; import com.android.settingslib.widget.ActionButtonsPreference; +import java.text.Collator; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -509,8 +510,12 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment } } - // Sort it - Collections.sort(entryPairs, (lhs, rhs) -> lhs.first.compareToIgnoreCase(rhs.first)); + // Get the primary locale and create a Collator to sort the strings + Locale userLocale = getResources().getConfiguration().getLocales().get(0); + Collator collator = Collator.getInstance(userLocale); + + // Sort the list + Collections.sort(entryPairs, (lhs, rhs) -> collator.compare(lhs.first, rhs.first)); // Get two arrays out of one of pairs mSelectedLocaleIndex = 0; // Will point to the R.string.tts_lang_use_system value