Skip to content

Commit

Permalink
refactor: remove deprecated popup keyboard stuffs in KeyboardView
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Nov 28, 2024
1 parent b343450 commit ec7957a
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1159,7 +1137,6 @@ class KeyboardView(

MotionEvent.ACTION_CANCEL -> {
removeMessages()
dismissPopupKeyboard()
mAbortKey = true
showPreview(NOT_A_KEY)
invalidateKey(mKeys[mCurrentKey])
Expand Down Expand Up @@ -1188,7 +1165,6 @@ class KeyboardView(
mPreviewPopup.dismiss()
}
removeMessages()
dismissPopupKeyboard()
freeDrawingBuffer()
}

Expand All @@ -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;
Expand Down

0 comments on commit ec7957a

Please sign in to comment.