@@ -43,7 +43,6 @@ import com.osfans.trime.data.prefs.AppPrefs
4343import com.osfans.trime.data.theme.ColorManager
4444import com.osfans.trime.data.theme.ThemeManager
4545import com.osfans.trime.ime.broadcast.IntentReceiver
46- import com.osfans.trime.ime.composition.CompositionPopupWindow
4746import com.osfans.trime.ime.enums.FullscreenMode
4847import com.osfans.trime.ime.enums.InlinePreeditMode
4948import com.osfans.trime.ime.enums.Keycode
@@ -55,7 +54,6 @@ import com.osfans.trime.ime.keyboard.KeyboardSwitcher
5554import com.osfans.trime.ime.keyboard.KeyboardView
5655import com.osfans.trime.ime.symbol.SymbolBoardType
5756import com.osfans.trime.ime.symbol.TabManager
58- import com.osfans.trime.ime.text.Candidate
5957import com.osfans.trime.ime.text.TextInputManager
6058import com.osfans.trime.util.ShortcutUtils
6159import com.osfans.trime.util.ShortcutUtils.openCategory
@@ -88,15 +86,13 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
8886 private val prefs: AppPrefs
8987 get() = AppPrefs .defaultInstance()
9088 private var mainKeyboardView: KeyboardView ? = null // 主軟鍵盤
91- private var mCandidate: Candidate ? = null // 候選
9289 var inputView: InputView ? = null
9390 private var initializationUi: InitializationUi ? = null
9491 private var eventListeners = WeakHashSet <EventListener >()
9592 private var mIntentReceiver: IntentReceiver ? = null
9693 private var isWindowShown = false // 键盘窗口是否已显示
9794 private var isAutoCaps = false // 句首自動大寫
9895 var textInputManager: TextInputManager ? = null // 文字输入管理器
99- private var mCompositionPopupWindow: CompositionPopupWindow ? = null
10096 var candidateExPage = false
10197
10298 var shouldUpdateRimeOption = false
@@ -318,24 +314,12 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
318314 commitTextByChar(checkNotNull(ShortcutUtils .pasteFromClipboard(this )).toString())
319315 }
320316
321- private fun showCompositionView () {
322- if (Rime .isComposing) {
323- mCompositionPopupWindow?.updateCompositionView()
324- } else {
325- mCompositionPopupWindow?.hideCompositionView()
326- }
327- }
328-
329317 /* * Must be called on the UI thread
330318 *
331319 * 重置鍵盤、候選條、狀態欄等 !!注意,如果其中調用Rime.setOption,切換方案會卡住 */
332320 fun recreateInputView () {
333321 inputView = InputView (this , rime)
334322 mainKeyboardView = inputView!! .keyboardWindow.oldMainInputView.mainKeyboardView
335- // 初始化候选栏
336- mCandidate = inputView!! .quickBar.oldCandidateBar.candidates
337-
338- mCompositionPopupWindow = inputView!! .composition
339323
340324 loadConfig()
341325 KeyboardSwitcher .newOrReset()
@@ -351,7 +335,6 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
351335 mIntentReceiver = null
352336 InputFeedbackManager .destroy()
353337 inputView = null
354- mCompositionPopupWindow = null
355338 for (listener in eventListeners) {
356339 listener.onDestroy()
357340 }
@@ -392,8 +375,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
392375 }
393376
394377 override fun onUpdateCursorAnchorInfo (cursorAnchorInfo : CursorAnchorInfo ) {
395- mCompositionPopupWindow?.updateCursorAnchorInfo(cursorAnchorInfo)
396- showCompositionView()
378+ inputView?.updateCursorAnchorInfo(cursorAnchorInfo)
397379 }
398380
399381 override fun onUpdateSelection (
@@ -1110,27 +1092,10 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
11101092 }
11111093
11121094 /* * 更新Rime的中西文狀態、編輯區文本 */
1113- fun updateComposing (): Int {
1114- val ic = currentInputConnection
1095+ fun updateComposing () {
11151096 updateComposingText()
1116- if (ic != null && mCompositionPopupWindow?.isWinFixed() == false ) {
1117- mCompositionPopupWindow?.isCursorUpdated = ic.requestCursorUpdates(1 )
1118- }
1119- var startNum = 0
1120- if (mCompositionPopupWindow?.isPopupWindowEnabled == true ) {
1121- val composition = mCompositionPopupWindow!! .composition
1122- composition.compositionView.visibility = View .VISIBLE
1123- startNum = Rime .inputContext?.let { composition.compositionView.update(it) } ? : 0
1124- mCandidate?.setText(startNum)
1125- // if isCursorUpdated, showCompositionView will be called in onUpdateCursorAnchorInfo
1126- // otherwise we need to call it here
1127- if (mCompositionPopupWindow?.isCursorUpdated == false ) showCompositionView()
1128- } else {
1129- mCandidate?.setText(0 )
1130- }
1131- mainKeyboardView?.invalidateComposingKeys()
1097+ inputView?.updateComposing(currentInputConnection)
11321098 if (! onEvaluateInputViewShown()) setCandidatesViewShown(textInputManager!! .isComposable) // 實體鍵盤打字時顯示候選欄
1133- return startNum
11341099 }
11351100
11361101 /* *
0 commit comments