mirror of
https://github.com/osfans/trime.git
synced 2026-11-08 01:16:38 +08:00
fix(keyboard): preserve ascii_mode across keyboard switches (#1979)
When switching between keyboard layouts, ascii_mode is unconditionally reset to the keyboard's default, discarding the user's current input mode. This happends due to TextKeyboard always defaults reset_ascii_mode to true, overriding the global theme setting, and lastAsciiMode is never saved when leaving a keyboard. Fix this by making TextKeyboard.resetAsciiMode nullable so that unset values fall through to the global theme settings in Keyboard, saving the current ascii_mode before switching away. Each keyboard's resetAsciiMode now falls back to the global setting and determines whether to reset or restore the previous mode. v1->v2: - Fix regression in KeyboardWindow::attachKeyboard() Signed-off-by: Xavier Hsinyuan <me@lstlx.com>
This commit is contained in:
parent
fc450aafee
commit
4b8badcbfd
@ -32,7 +32,7 @@ data class TextKeyboard(
|
||||
val keyBorder: Int,
|
||||
val columns: Int,
|
||||
val asciiMode: Boolean,
|
||||
val resetAsciiMode: Boolean,
|
||||
val resetAsciiMode: Boolean?,
|
||||
val labelTransform: LabelTransform,
|
||||
val lock: Boolean,
|
||||
val asciiKeyboard: String,
|
||||
@ -140,7 +140,7 @@ data class TextKeyboard(
|
||||
keyBorder = node["key_border"]?.int ?: -1,
|
||||
columns = node["columns"]?.int ?: 30,
|
||||
asciiMode = (node["ascii_mode"]?.int ?: 1) == 1,
|
||||
resetAsciiMode = node["reset_ascii_mode"]?.boolean ?: true,
|
||||
resetAsciiMode = node["reset_ascii_mode"]?.boolean,
|
||||
labelTransform = node["label_transform"]?.enum<LabelTransform>() ?: LabelTransform.NONE,
|
||||
lock = node["lock"]?.boolean ?: false,
|
||||
asciiKeyboard = node["ascii_keyboard"]?.string ?: "",
|
||||
|
||||
@ -122,7 +122,7 @@ class Keyboard(
|
||||
|
||||
/** Keyboard default ascii mode */
|
||||
val asciiMode = selfConfig?.asciiMode ?: false
|
||||
val resetAsciiMode = selfConfig?.resetAsciiMode ?: true
|
||||
val resetAsciiMode = selfConfig?.resetAsciiMode ?: theme.generalStyle.resetASCIIMode
|
||||
var lastAsciiMode: Boolean = asciiMode
|
||||
|
||||
val landscapeKeyboard: String? = selfConfig?.landscapeKeyboard
|
||||
|
||||
@ -105,6 +105,13 @@ class KeyboardWindow :
|
||||
}
|
||||
|
||||
private fun attachKeyboard(target: String) {
|
||||
currentKeyboard?.let {
|
||||
val mode = rime.run { statusCached }.isAsciiMode
|
||||
|
||||
Timber.d("Leaving $currentKeyboardId with ascii_mode $mode, switching to $target")
|
||||
it.lastAsciiMode = mode
|
||||
}
|
||||
|
||||
currentKeyboardId = target
|
||||
lastKeyboardId = target
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user