@@ -99,6 +99,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
9999 private var mCompositionPopupWindow: CompositionPopupWindow ? = null
100100 var candidateExPage = false
101101
102+ var shouldUpdateRimeOption = false
103+ var shouldResetAsciiMode = false
104+
102105 private val cursorCapsMode: Int
103106 get() =
104107 currentInputEditorInfo.run {
@@ -175,17 +178,17 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
175178
176179 fun loadConfig () {
177180 val theme = ThemeManager .activeTheme
178- textInputManager !! . shouldResetAsciiMode = theme.style.getBoolean(" reset_ascii_mode" )
181+ shouldResetAsciiMode = theme.style.getBoolean(" reset_ascii_mode" )
179182 isAutoCaps = theme.style.getBoolean(" auto_caps" )
180- textInputManager !! . shouldUpdateRimeOption = true
183+ shouldUpdateRimeOption = true
181184 }
182185
183186 private fun updateRimeOption (): Boolean {
184187 try {
185- if (textInputManager !! . shouldUpdateRimeOption) {
188+ if (shouldUpdateRimeOption) {
186189 Rime .setOption(" soft_cursor" , prefs.keyboard.softCursorEnabled) // 軟光標
187190 Rime .setOption(" _horizontal" , ThemeManager .activeTheme.style.getBoolean(" horizontal" )) // 水平模式
188- textInputManager !! . shouldUpdateRimeOption = false
191+ shouldUpdateRimeOption = false
189192 }
190193 } catch (e: Exception ) {
191194 e.printStackTrace()
@@ -326,11 +329,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
326329
327330 loadConfig()
328331 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() // 切換主題時刷新候選
334335 setInputView(inputView!! )
335336 }
336337
0 commit comments