Skip to content

Commit

Permalink
fix: keyboard view would be disappear after recreating input view
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Nov 22, 2024
1 parent de303b3 commit fdaaec9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/osfans/trime/ime/core/InputView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class InputView(

windowManager.cacheResidentWindow(keyboardWindow, createView = true)
windowManager.cacheResidentWindow(liquidKeyboard)
// show KeyboardWindow by default
windowManager.attachWindow(KeyboardWindow)

service.window.window!!.also {
when (navbarBackground) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,18 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
commitTextByChar(checkNotNull(ShortcutUtils.pasteFromClipboard(this)).toString())
}

private fun setupInputView(theme: Theme): InputView {
updateComposing() // 切換主題時刷新候選
val newInputView = InputView(this, rime, theme)
inputView = newInputView
return newInputView
}

/** Must be called on the UI thread
*
* 重置鍵盤、候選條、狀態欄等 !!注意,如果其中調用Rime.setOption,切換方案會卡住 */
fun recreateInputView(theme: Theme) {
updateComposing() // 切換主題時刷新候選
setInputView(InputView(this, rime, theme).also { inputView = it })
setInputView(setupInputView(theme))
initializationUi = null
}

Expand Down

0 comments on commit fdaaec9

Please sign in to comment.