From ec7957a233c846aa6c57afc1ee1507dbd839f4ee Mon Sep 17 00:00:00 2001 From: WhiredPlanck Date: Thu, 28 Nov 2024 05:15:13 +0800 Subject: [PATCH] refactor: remove deprecated popup keyboard stuffs in KeyboardView --- .../osfans/trime/ime/keyboard/KeyboardView.kt | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt index 9b3870830b..a610b6933c 100644 --- a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt +++ b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt @@ -51,8 +51,7 @@ class KeyboardView( context: Context, private val theme: Theme, private val keyboard: Keyboard, -) : View(context), - View.OnClickListener { +) : View(context) { private var mCurrentKeyIndex = NOT_A_KEY private val keyTextSize = theme.generalStyle.keyTextSize private val labelTextSize = @@ -111,11 +110,7 @@ class KeyboardView( // Working variable private val mCoordinates = IntArray(2) - private val mPopupKeyboard = PopupWindow(context) - private var mMiniKeyboardOnScreen = false private var mPopupParent: View = this - private var mMiniKeyboardOffsetX = 0 - private var mMiniKeyboardOffsetY = 0 private val mKeys get() = keyboard.keys var keyboardActionListener: KeyboardActionListener? = null @@ -418,15 +413,6 @@ class KeyboardView( val isCapsOn: Boolean get() = keyboard.mShiftKey?.isOn ?: false - /** - * 關閉彈出鍵盤 - * - * @param v 鍵盤視圖 - */ - override fun onClick(v: View) { - dismissPopupKeyboard() - } - public override fun onMeasure( widthMeasureSpec: Int, heightMeasureSpec: Int, @@ -802,8 +788,6 @@ class KeyboardView( } mHandler.removeMessages(MSG_REMOVE_PREVIEW) getLocationInWindow(mCoordinates) - mCoordinates[0] += mMiniKeyboardOffsetX // Offset may be zero - mCoordinates[1] += mMiniKeyboardOffsetY // Offset may be zero // Set the preview background state mPreviewText.background.setState(EMPTY_STATE_SET) @@ -1001,12 +985,6 @@ class KeyboardView( } } - // Needs to be called after the gesture detector gets a turn, as it may have - // displayed the mini keyboard - if (mMiniKeyboardOnScreen && action != MotionEvent.ACTION_CANCEL) { - return true - } - fun modifiedPointerDown() { mAbortKey = false mStartX = touchX @@ -1089,7 +1067,7 @@ class KeyboardView( showPreview(NOT_A_KEY) Arrays.fill(mKeyIndices, NOT_A_KEY) if (mRepeatKeyIndex != NOT_A_KEY && !mAbortKey) repeatKey() - if (mRepeatKeyIndex == NOT_A_KEY && !mMiniKeyboardOnScreen && !mAbortKey) { + if (mRepeatKeyIndex == NOT_A_KEY && !mAbortKey) { Timber.d("onModifiedTouchEvent: detectAndSendKey") detectAndSendKey( mCurrentKey, @@ -1159,7 +1137,6 @@ class KeyboardView( MotionEvent.ACTION_CANCEL -> { removeMessages() - dismissPopupKeyboard() mAbortKey = true showPreview(NOT_A_KEY) invalidateKey(mKeys[mCurrentKey]) @@ -1188,7 +1165,6 @@ class KeyboardView( mPreviewPopup.dismiss() } removeMessages() - dismissPopupKeyboard() freeDrawingBuffer() } @@ -1197,14 +1173,6 @@ class KeyboardView( freeDrawingBuffer() } - private fun dismissPopupKeyboard() { - if (mPopupKeyboard.isShowing) { - mPopupKeyboard.dismiss() - mMiniKeyboardOnScreen = false - invalidateAllKeys() - } - } - private fun resetMultiTap() { mLastSentIndex = -1 // final int mTapCount = 0;