Cancel long press timer when sliding key input is not allowed
This change also fixes auto snap back behavior of key which has output
text, such as smiley key.
Bug: 3297825
Change-Id: Ia06e1abc0fbdff2a26504ddcce1dc7f933b45453
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 31d98a6..0fb9014 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -576,7 +576,7 @@
}
break;
case AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN:
- if (key != Keyboard.CODE_SPACE && key != Keyboard.CODE_ENTER && key > 0) {
+ if (key != Keyboard.CODE_SPACE && key != Keyboard.CODE_ENTER && key >= 0) {
mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_SYMBOL;
}
break;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index ffaf3db..15eab8f 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -296,6 +296,7 @@
// onRelease() first to notify that the previous key has been released, then call
// onPress() to notify that the new key is being pressed.
callListenerOnRelease(oldKey.mCodes[0]);
+ mHandler.cancelLongPressTimers();
if (mIsAllowedSlidingKeyInput) {
resetMultiTap();
callListenerOnPress(getKey(keyIndex).mCodes[0]);
@@ -312,10 +313,10 @@
// The pointer has been slid out from the previous key, we must call onRelease() to
// notify that the previous key has been released.
callListenerOnRelease(oldKey.mCodes[0]);
+ mHandler.cancelLongPressTimers();
if (mIsAllowedSlidingKeyInput) {
resetMultiTap();
keyState.onMoveToNewKey(keyIndex, x ,y);
- mHandler.cancelLongPressTimers();
} else {
setAlreadyProcessed();
showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY);
@@ -332,10 +333,10 @@
if (DEBUG_EVENT)
printTouchEvent("onUpEvent :", x, y, eventTime);
showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY);
- if (mKeyAlreadyProcessed)
- return;
mHandler.cancelKeyTimers();
mHandler.cancelPopupPreview();
+ if (mKeyAlreadyProcessed)
+ return;
final PointerTrackerKeyState keyState = mKeyState;
int keyIndex = keyState.onUpKey(x, y);
if (isMinorMoveBounce(x, y, keyIndex)) {
@@ -438,7 +439,7 @@
}
if (key.mOutputText != null) {
callListenerOnText(key.mOutputText);
- callListenerOnRelease(NOT_A_KEY);
+ callListenerOnRelease(key.mCodes[0]);
} else {
int code = key.mCodes[0];
final int[] codes = mKeyDetector.newCodeArray();
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 12a24e8..3a3a000 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1128,6 +1128,7 @@
ic.commitText(text, 1);
ic.endBatchEdit();
mKeyboardSwitcher.updateShiftState();
+ mKeyboardSwitcher.onKey(0); // dummy key code.
mJustReverted = false;
mJustAddedAutoSpace = false;
mEnteredText = text;