diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorLocale.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorLocale.kt index 4d78a30718..13e68d83df 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorLocale.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorLocale.kt @@ -42,8 +42,7 @@ object VectorLocale { /** * The supported application languages */ - var supportedLocales = ArrayList() - private set + val supportedLocales = mutableListOf() /** * Provides the current application locale @@ -195,9 +194,7 @@ object VectorLocale { ) } - supportedLocales.clear() - - knownLocalesSet.mapTo(supportedLocales) { (language, country, script) -> + val list = knownLocalesSet.map { (language, country, script) -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Locale.Builder() .setLanguage(language) @@ -208,9 +205,11 @@ object VectorLocale { Locale(language, country) } } + // sort by human display names + .sortedBy { localeToLocalisedString(it).toLowerCase(it) } - // sort by human display names - supportedLocales.sortWith(Comparator { lhs, rhs -> localeToLocalisedString(lhs).compareTo(localeToLocalisedString(rhs)) }) + supportedLocales.clear() + supportedLocales.addAll(list) } /** diff --git a/vector/src/main/java/im/vector/riotx/features/settings/locale/LocalePickerController.kt b/vector/src/main/java/im/vector/riotx/features/settings/locale/LocalePickerController.kt index 74c5adf98c..ecaeac31c1 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/locale/LocalePickerController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/locale/LocalePickerController.kt @@ -61,7 +61,6 @@ class LocalePickerController @Inject constructor( } list .filter { it != data.currentLocale } - .sortedBy { VectorLocale.localeToLocalisedString(it).toLowerCase(it) } .forEach { localeItem { id(it.toString())