Language.kt - added sorted function
This commit is contained in:
parent
c226ebd84b
commit
5738029991
|
@ -149,7 +149,7 @@ fun Context.setupKeyboardDialogStuff(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getKeyboardLanguages(): ArrayList<RadioItem> {
|
fun Context.getKeyboardLanguages(): ArrayList<RadioItem> {
|
||||||
val languages = Language.values().map { RadioItem(it.ordinal, it.getName(this)) }
|
val languages = Language.sorted(this).map { RadioItem(it.ordinal, it.getName(this)) }
|
||||||
return ArrayList(languages)
|
return ArrayList(languages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ enum class Language(@StringRes private val stringRes: Int, private val layout: I
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
fun sorted(context: Context) = Language.values().sortedBy { context.getString(it.stringRes) }
|
||||||
|
|
||||||
fun getKeyboardLayout(keyboardLanguage: Int): Int {
|
fun getKeyboardLayout(keyboardLanguage: Int): Int {
|
||||||
return Language.values().getOrElse(keyboardLanguage) { ENGLISH_QWERTY }.layout
|
return Language.values().getOrElse(keyboardLanguage) { ENGLISH_QWERTY }.layout
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue