Merge branch 'languages_refactoring' into scandinavian_language_layouts

This commit is contained in:
merkost 2023-05-25 23:22:05 +10:00
commit 535409e9ee
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

@ -69,6 +69,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
}