Skip to content

Commit

Permalink
fix: return default keyboard if no keyboard is matched
Browse files Browse the repository at this point in the history
  • Loading branch information
goofyz committed Dec 30, 2023
1 parent 2863e0c commit 0c971be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/src/main/java/com/osfans/trime/data/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ class Theme private constructor(isDarkMode: Boolean) {
?: throw IllegalStateException("The default keyboard definition is missing!")
if (defaultMap.containsKey("import_preset")) {
return defaultMap["import_preset"] as? String ?: "default"
} else {
return "default"
}
}
return remapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ object KeyboardSwitcher {
Timber.d("Switching keyboard back to .default ...")
availableKeyboardIds = (theme.style.getObject("keyboards") as? List<String>)
?.map { theme.keyboards.remapKeyboardId(it) }?.distinct() ?: listOf()
availableKeyboards = availableKeyboardIds.map { Keyboard(theme.keyboards.remapKeyboardId(it)) }

availableKeyboards =
availableKeyboardIds.map {
try {
Keyboard(theme.keyboards.remapKeyboardId(it))
} catch (e: Exception) {
Keyboard("default")
}
}
}

fun switchKeyboard(name: String?) {
Expand Down

0 comments on commit 0c971be

Please sign in to comment.