@@ -61,8 +61,6 @@ class TextInputManager private constructor() :
61
61
var shouldUpdateRimeOption: Boolean = true
62
62
var performEnterAsLineBreak: Boolean = false
63
63
var isComposable: Boolean = false
64
- var isAsciiMode: Boolean = true
65
- var isTempAsciiMode: Boolean = true
66
64
var shouldResetAsciiMode: Boolean = false
67
65
68
66
companion object {
@@ -179,7 +177,7 @@ class TextInputManager private constructor() :
179
177
super .onStartInputView(instance, restarting)
180
178
isComposable = false
181
179
performEnterAsLineBreak = false
182
- var tempAsciiMode = false
180
+ var tempAsciiMode = if (shouldResetAsciiMode) false else null
183
181
val inputAttrsRaw = instance.editorInfo!! .inputType
184
182
val keyboardType = when (inputAttrsRaw and InputType .TYPE_MASK_CLASS ) {
185
183
InputType .TYPE_CLASS_NUMBER ,
@@ -220,7 +218,7 @@ class TextInputManager private constructor() :
220
218
it.switchToKeyboard(keyboardType)
221
219
}
222
220
Rime .get(trime)
223
- Rime .setOption(" ascii_mode" , tempAsciiMode)
221
+ tempAsciiMode?. let { Rime .setOption(" ascii_mode" , it) }
224
222
isComposable = isComposable && ! Rime .isEmpty()
225
223
if (! trime.onEvaluateInputViewShown()) {
226
224
// Show candidate view when using physical keyboard
@@ -231,9 +229,6 @@ class TextInputManager private constructor() :
231
229
fun onOptionChanged (option : String , value : Boolean ) {
232
230
when (option) {
233
231
" ascii_mode" -> {
234
- if (! isTempAsciiMode) {
235
- isAsciiMode = value // 切換中西文時保存狀態
236
- }
237
232
trime.inputFeedbackManager.ttsLanguage =
238
233
locales[if (value) 1 else 0 ]
239
234
}
@@ -249,7 +244,6 @@ class TextInputManager private constructor() :
249
244
) {
250
245
val keyboard = option.substring(10 )
251
246
keyboardSwitcher.switchToKeyboard(keyboard)
252
- isTempAsciiMode = keyboardSwitcher.asciiMode
253
247
trime.bindKeyboardToInputView()
254
248
} else if (option.startsWith(" _key_" ) && option.length > 5 && value) {
255
249
shouldUpdateRimeOption = false // 防止在 onMessage 中 setOption
@@ -307,8 +301,7 @@ class TextInputManager private constructor() :
307
301
KeyEvent .KEYCODE_EISU -> { // Switch keyboard
308
302
keyboardSwitcher.switchToKeyboard(event.select)
309
303
/* * Set ascii mode according to keyboard's settings, can not place into [Rime.onMessage] */
310
- isTempAsciiMode = keyboardSwitcher.asciiMode
311
- Rime .setOption(" ascii_mode" , isTempAsciiMode)
304
+ Rime .setOption(" ascii_mode" , keyboardSwitcher.asciiMode)
312
305
trime.bindKeyboardToInputView()
313
306
trime.updateComposing()
314
307
}
0 commit comments