@@ -99,6 +99,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
99
99
private var mCompositionPopupWindow: CompositionPopupWindow ? = null
100
100
var candidateExPage = false
101
101
102
+ var shouldUpdateRimeOption = false
103
+ var shouldResetAsciiMode = false
104
+
102
105
private val cursorCapsMode: Int
103
106
get() =
104
107
currentInputEditorInfo.run {
@@ -175,17 +178,17 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
175
178
176
179
fun loadConfig () {
177
180
val theme = ThemeManager .activeTheme
178
- textInputManager !! . shouldResetAsciiMode = theme.style.getBoolean(" reset_ascii_mode" )
181
+ shouldResetAsciiMode = theme.style.getBoolean(" reset_ascii_mode" )
179
182
isAutoCaps = theme.style.getBoolean(" auto_caps" )
180
- textInputManager !! . shouldUpdateRimeOption = true
183
+ shouldUpdateRimeOption = true
181
184
}
182
185
183
186
private fun updateRimeOption (): Boolean {
184
187
try {
185
- if (textInputManager !! . shouldUpdateRimeOption) {
188
+ if (shouldUpdateRimeOption) {
186
189
Rime .setOption(" soft_cursor" , prefs.keyboard.softCursorEnabled) // 軟光標
187
190
Rime .setOption(" _horizontal" , ThemeManager .activeTheme.style.getBoolean(" horizontal" )) // 水平模式
188
- textInputManager !! . shouldUpdateRimeOption = false
191
+ shouldUpdateRimeOption = false
189
192
}
190
193
} catch (e: Exception ) {
191
194
e.printStackTrace()
@@ -326,11 +329,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
326
329
327
330
loadConfig()
328
331
KeyboardSwitcher .newOrReset()
329
- if (textInputManager != null ) {
330
- textInputManager!! .shouldUpdateRimeOption = true // 不能在Rime.onMessage中調用set_option,會卡死
331
- bindKeyboardToInputView()
332
- updateComposing() // 切換主題時刷新候選
333
- }
332
+ shouldUpdateRimeOption = true // 不能在Rime.onMessage中調用set_option,會卡死
333
+ bindKeyboardToInputView()
334
+ updateComposing() // 切換主題時刷新候選
334
335
setInputView(inputView!! )
335
336
}
336
337
0 commit comments