Skip to content

Commit 3972a91

Browse files
fix: prevent unnecessary key invalidation when keyboard mode change.
1 parent acb82a5 commit 3972a91

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
138138
private var mLastKey = 0
139139
private var mLastCodeX = 0
140140
private var mLastCodeY = 0
141+
private var mLastKeyPressedCode = 0
141142
private var mCurrentKey: Int = NOT_A_KEY
142143
private var mLastKeyTime = 0L
143144
private var mCurrentKeyTime = 0L
@@ -1281,8 +1282,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12811282
} else {
12821283
0
12831284
}
1284-
12851285
mOnKeyboardActionListener!!.onPress(onPressKey)
1286+
mLastKeyPressedCode = onPressKey
12861287

12871288
var wasHandled = false
12881289
if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) {
@@ -1396,7 +1397,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13961397
detectAndSendKey(mCurrentKey, touchX, touchY, eventTime)
13971398
}
13981399

1399-
invalidateKey(keyIndex)
1400+
if (mLastKeyPressedCode != KEYCODE_MODE_CHANGE) {
1401+
invalidateKey(keyIndex)
1402+
}
14001403
mRepeatKeyIndex = NOT_A_KEY
14011404
mOnKeyboardActionListener!!.onActionUp()
14021405
mIsLongPressingSpace = false

0 commit comments

Comments
 (0)