mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 21:48:50 +03:00
Locales: improve algo
This commit is contained in:
parent
4961bb0e08
commit
19d655ec41
2 changed files with 6 additions and 8 deletions
|
@ -42,8 +42,7 @@ object VectorLocale {
|
||||||
/**
|
/**
|
||||||
* The supported application languages
|
* The supported application languages
|
||||||
*/
|
*/
|
||||||
var supportedLocales = ArrayList<Locale>()
|
val supportedLocales = mutableListOf<Locale>()
|
||||||
private set
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the current application locale
|
* Provides the current application locale
|
||||||
|
@ -195,9 +194,7 @@ object VectorLocale {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
supportedLocales.clear()
|
val list = knownLocalesSet.map { (language, country, script) ->
|
||||||
|
|
||||||
knownLocalesSet.mapTo(supportedLocales) { (language, country, script) ->
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
Locale.Builder()
|
Locale.Builder()
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
|
@ -208,9 +205,11 @@ object VectorLocale {
|
||||||
Locale(language, country)
|
Locale(language, country)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort by human display names
|
// sort by human display names
|
||||||
supportedLocales.sortWith(Comparator { lhs, rhs -> localeToLocalisedString(lhs).compareTo(localeToLocalisedString(rhs)) })
|
.sortedBy { localeToLocalisedString(it).toLowerCase(it) }
|
||||||
|
|
||||||
|
supportedLocales.clear()
|
||||||
|
supportedLocales.addAll(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,6 @@ class LocalePickerController @Inject constructor(
|
||||||
}
|
}
|
||||||
list
|
list
|
||||||
.filter { it != data.currentLocale }
|
.filter { it != data.currentLocale }
|
||||||
.sortedBy { VectorLocale.localeToLocalisedString(it).toLowerCase(it) }
|
|
||||||
.forEach {
|
.forEach {
|
||||||
localeItem {
|
localeItem {
|
||||||
id(it.toString())
|
id(it.toString())
|
||||||
|
|
Loading…
Reference in a new issue