removing more unused variables

This commit is contained in:
tibbi 2022-01-21 20:27:58 +01:00
parent b12c6cb6dc
commit 9bff0e60f5
1 changed files with 3 additions and 33 deletions

View File

@ -85,11 +85,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private var mKeys = ArrayList<MyKeyboard.Key>() private var mKeys = ArrayList<MyKeyboard.Key>()
private var mMiniKeyboardSelectedKeyIndex = -1 private var mMiniKeyboardSelectedKeyIndex = -1
/**
* Returns the [OnKeyboardActionListener] object.
* @return the listener attached to this keyboard
*/
/** Listener for [OnKeyboardActionListener]. */
var onKeyboardActionListener: OnKeyboardActionListener? = null var onKeyboardActionListener: OnKeyboardActionListener? = null
private var mVerticalCorrection = 0 private var mVerticalCorrection = 0
private var mProximityThreshold = 0 private var mProximityThreshold = 0
@ -113,8 +108,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private var mRepeatKeyIndex = NOT_A_KEY private var mRepeatKeyIndex = NOT_A_KEY
private var mPopupLayout = 0 private var mPopupLayout = 0
private var mAbortKey = false private var mAbortKey = false
private var mInvalidatedKey: MyKeyboard.Key? = null
private val mClipRegion = Rect(0, 0, 0, 0)
private var mIsLongPressingSpace = false private var mIsLongPressingSpace = false
private var mLastSpaceMoveX = 0 private var mLastSpaceMoveX = 0
private var mPopupMaxMoveDistance = 0f private var mPopupMaxMoveDistance = 0f
@ -276,13 +269,11 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
showPreview(NOT_A_KEY) showPreview(NOT_A_KEY)
} }
// Remove any pending messages
removeMessages() removeMessages()
mKeyboard = keyboard mKeyboard = keyboard
val keys = mKeyboard!!.mKeys val keys = mKeyboard!!.mKeys
mKeys = keys!!.toMutableList() as ArrayList<MyKeyboard.Key> mKeys = keys!!.toMutableList() as ArrayList<MyKeyboard.Key>
requestLayout() requestLayout()
// Hint to reallocate the buffer if the size changed
mKeyboardChanged = true mKeyboardChanged = true
invalidateAllKeys() invalidateAllKeys()
computeProximityThreshold(keyboard) computeProximityThreshold(keyboard)
@ -408,9 +399,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
val canvas = mCanvas val canvas = mCanvas
canvas!!.clipRect(mDirtyRect) canvas!!.clipRect(mDirtyRect)
val paint = mPaint val paint = mPaint
val clipRegion = mClipRegion
val keys = mKeys val keys = mKeys
val invalidKey = mInvalidatedKey
paint.color = mTextColor paint.color = mTextColor
val smallLetterPaint = Paint() val smallLetterPaint = Paint()
smallLetterPaint.set(paint) smallLetterPaint.set(paint)
@ -420,26 +409,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
typeface = Typeface.DEFAULT typeface = Typeface.DEFAULT
} }
var drawSingleKey = false
if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
// Is clipRegion completely contained within the invalidated key?
if (invalidKey.x - 1 <= clipRegion.left &&
invalidKey.y - 1 <= clipRegion.top &&
invalidKey.x + invalidKey.width + 1 >= clipRegion.right &&
invalidKey.y + invalidKey.height + 1 >= clipRegion.bottom
) {
drawSingleKey = true
}
}
canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR) canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR)
val keyCount = keys.size val keyCount = keys.size
for (i in 0 until keyCount) { for (i in 0 until keyCount) {
val key = keys[i] val key = keys[i]
if (drawSingleKey && invalidKey !== key) {
continue
}
val code = key.codes.firstOrNull() ?: -100 val code = key.codes.firstOrNull() ?: -100
var keyBackground = mKeyBackground var keyBackground = mKeyBackground
if (code == MyKeyboard.KEYCODE_SPACE) { if (code == MyKeyboard.KEYCODE_SPACE) {
@ -519,7 +492,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
canvas.translate(-key.x.toFloat(), -key.y.toFloat()) canvas.translate(-key.x.toFloat(), -key.y.toFloat())
} }
mInvalidatedKey = null
// Overlay a dark rectangle to dim the keyboard // Overlay a dark rectangle to dim the keyboard
if (mMiniKeyboardOnScreen) { if (mMiniKeyboardOnScreen) {
paint.color = Color.BLACK.adjustAlpha(0.3f) paint.color = Color.BLACK.adjustAlpha(0.3f)
@ -812,13 +784,12 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
* @param keyIndex the index of the key in the attached [MyKeyboard]. * @param keyIndex the index of the key in the attached [MyKeyboard].
* @see .invalidateAllKeys * @see .invalidateAllKeys
*/ */
fun invalidateKey(keyIndex: Int) { private fun invalidateKey(keyIndex: Int) {
if (keyIndex < 0 || keyIndex >= mKeys.size) { if (keyIndex < 0 || keyIndex >= mKeys.size) {
return return
} }
val key = mKeys[keyIndex] val key = mKeys[keyIndex]
mInvalidatedKey = key
mDirtyRect.union( mDirtyRect.union(
key.x, key.y, key.x, key.y,
key.x + key.width, key.y + key.height key.x + key.width, key.y + key.height
@ -857,7 +828,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
* @return true if the long press is handled, false otherwise. Subclasses should call the * @return true if the long press is handled, false otherwise. Subclasses should call the
* method on the base class if the subclass doesn't wish to handle the call. * method on the base class if the subclass doesn't wish to handle the call.
*/ */
protected fun onLongPress(popupKey: MyKeyboard.Key, me: MotionEvent): Boolean { private fun onLongPress(popupKey: MyKeyboard.Key, me: MotionEvent): Boolean {
val popupKeyboardId = popupKey.popupResId val popupKeyboardId = popupKey.popupResId
if (popupKeyboardId != 0) { if (popupKeyboardId != 0) {
mMiniKeyboardContainer = mMiniKeyboardCache[popupKey] mMiniKeyboardContainer = mMiniKeyboardCache[popupKey]
@ -946,7 +917,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
mPopupKeyboard.height = mMiniKeyboardContainer!!.measuredHeight mPopupKeyboard.height = mMiniKeyboardContainer!!.measuredHeight
mPopupKeyboard.showAtLocation(this, Gravity.NO_GRAVITY, x, y) mPopupKeyboard.showAtLocation(this, Gravity.NO_GRAVITY, x, y)
mMiniKeyboardOnScreen = true mMiniKeyboardOnScreen = true
//mMiniKeyboard.onTouchEvent(getTranslatedEvent(me));
invalidateAllKeys() invalidateAllKeys()
return true return true
} }
@ -1238,7 +1208,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
return true return true
} }
fun closing() { private fun closing() {
if (mPreviewPopup.isShowing) { if (mPreviewPopup.isShowing) {
mPreviewPopup.dismiss() mPreviewPopup.dismiss()
} }