Language.kt - added sorted function
This commit is contained in:
parent
c226ebd84b
commit
5738029991
2 changed files with 3 additions and 1 deletions
|
@ -149,7 +149,7 @@ fun Context.setupKeyboardDialogStuff(
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ enum class Language(@StringRes private val stringRes: Int, private val layout: I
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun sorted(context: Context) = Language.values().sortedBy { context.getString(it.stringRes) }
|
||||
|
||||
fun getKeyboardLayout(keyboardLanguage: Int): Int {
|
||||
return Language.values().getOrElse(keyboardLanguage) { ENGLISH_QWERTY }.layout
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue