Fix bugs in key repeat logic
Bug: 2950714
Change-Id: I3110369c085f89ee1e8f7392a9a04a6b9e377ed4
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 4337059..8e55c8e 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -1313,13 +1313,14 @@
}
if (mHandler.isInKeyRepeat()) {
- // Will keep being in the key repeating mode while the key is being pressed. It'll be
- // canceled otherwise.
- if (pointerCount == 1 && action == MotionEvent.ACTION_MOVE) {
- return true;
- } else {
+ // It'll be canceled if 2 or more keys are in action. Otherwise it will keep being in
+ // the key repeating mode while the key is being pressed.
+ if (pointerCount > 1) {
mHandler.cancelKeyRepeatTimer();
+ } else if (action == MotionEvent.ACTION_MOVE) {
+ return true;
}
+ // Up event will pass through.
}
if (pointerCount != mOldPointerCount) {
@@ -1415,6 +1416,7 @@
break;
case MotionEvent.ACTION_UP:
+ boolean wasInKeyRepeat = mHandler.isInKeyRepeat();
mHandler.cancelKeyTimers();
mHandler.cancelPopupPreview();
if (mDebouncer.isMinorMoveBounce(touchX, touchY, keyIndex, mCurrentKey)) {
@@ -1431,7 +1433,7 @@
}
showPreview(NOT_A_KEY);
// If we're not on a repeating key (which sends on a DOWN event)
- if (!mMiniKeyboardOnScreen && !mAbortKey) {
+ if (!wasInKeyRepeat && !mMiniKeyboardOnScreen && !mAbortKey) {
detectAndSendKey(mCurrentKey, touchX, touchY, eventTime);
}
invalidateKey(keyIndex);