Language.kt - added sorted function

This commit is contained in:
merkost 2023-05-25 23:19:53 +10:00
parent c226ebd84b
commit 5738029991
2 changed files with 3 additions and 1 deletions

View file

@ -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)
}

View file

@ -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
}