Skip to content

Commit 0c971be

Browse files
committed
fix: return default keyboard if no keyboard is matched
1 parent 2863e0c commit 0c971be

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/src/main/java/com/osfans/trime/data/theme/Theme.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ class Theme private constructor(isDarkMode: Boolean) {
301301
?: throw IllegalStateException("The default keyboard definition is missing!")
302302
if (defaultMap.containsKey("import_preset")) {
303303
return defaultMap["import_preset"] as? String ?: "default"
304+
} else {
305+
return "default"
304306
}
305307
}
306308
return remapped

app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ object KeyboardSwitcher {
3535
Timber.d("Switching keyboard back to .default ...")
3636
availableKeyboardIds = (theme.style.getObject("keyboards") as? List<String>)
3737
?.map { theme.keyboards.remapKeyboardId(it) }?.distinct() ?: listOf()
38-
availableKeyboards = availableKeyboardIds.map { Keyboard(theme.keyboards.remapKeyboardId(it)) }
38+
39+
availableKeyboards =
40+
availableKeyboardIds.map {
41+
try {
42+
Keyboard(theme.keyboards.remapKeyboardId(it))
43+
} catch (e: Exception) {
44+
Keyboard("default")
45+
}
46+
}
3947
}
4048

4149
fun switchKeyboard(name: String?) {

0 commit comments

Comments
 (0)