aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/keyboard/PointerTracker.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/PointerTracker.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java42
1 files changed, 27 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 64f2f9644..1b1aa492c 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -392,7 +392,7 @@ public class PointerTracker {
startLongPressTimer(keyIndex);
showKeyPreview(keyIndex);
setPressedKeyGraphics(keyIndex);
- } else if (!isMinorMoveBounce(x, y, keyIndex)) {
+ } else if (isMajorEnoughMoveToBeOnNewKey(x, y, keyIndex)) {
// The pointer has been slid in to the new key from the previous key, we must call
// onRelease() first to notify that the previous key has been released, then call
// onPress() to notify that the new key is being pressed.
@@ -430,9 +430,12 @@ public class PointerTracker {
}
return;
}
+ } else if (mKeyboard.needSpacebarPreview(keyIndex)) {
+ // Display spacebar slide language switcher.
+ showKeyPreview(keyIndex);
}
} else {
- if (oldKey != null && !isMinorMoveBounce(x, y, keyIndex)) {
+ if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, keyIndex)) {
// The pointer has been slid out from the previous key, we must call onRelease() to
// notify that the previous key has been released.
setReleasedKeyGraphics(oldKeyIndex);
@@ -483,7 +486,7 @@ public class PointerTracker {
mIsInSlidingKeyInput = false;
final PointerTrackerKeyState keyState = mKeyState;
final int keyX, keyY;
- if (!isMinorMoveBounce(x, y, keyState.onMoveKey(x, y))) {
+ if (isMajorEnoughMoveToBeOnNewKey(x, y, keyState.onMoveKey(x, y))) {
keyX = x;
keyY = y;
} else {
@@ -544,28 +547,37 @@ public class PointerTracker {
return mKeyState.getDownTime();
}
- private boolean isMinorMoveBounce(int x, int y, int newKey) {
+ private boolean isMajorEnoughMoveToBeOnNewKey(int x, int y, int newKey) {
if (mKeys == null || mKeyHysteresisDistanceSquared < 0)
throw new IllegalStateException("keyboard and/or hysteresis not set");
int curKey = mKeyState.getKeyIndex();
if (newKey == curKey) {
- return true;
+ return false;
} else if (isValidKeyIndex(curKey)) {
- return mKeys.get(curKey).squaredDistanceToEdge(x, y) < mKeyHysteresisDistanceSquared;
+ return mKeys.get(curKey).squaredDistanceToEdge(x, y) >= mKeyHysteresisDistanceSquared;
} else {
- return false;
+ return true;
}
}
- private void showKeyPreview(int keyIndex) {
+ // The modifier key, such as shift key, should not show its key preview. If accessibility is
+ // turned on, the modifier key should show its key preview.
+ private boolean isKeyPreviewNotRequired(int keyIndex) {
final Key key = getKey(keyIndex);
- if (key != null && !key.mEnabled)
- return;
- // The modifier key, such as shift key, should not be shown as preview when multi-touch is
- // supported. On the other hand, if multi-touch is not supported, the modifier key should
- // be shown as preview. If accessibility is turned on, the modifier key should be shown as
- // preview.
- if (mHasDistinctMultitouch && isModifier() && !mIsAccessibilityEnabled)
+ if (!key.mEnabled)
+ return true;
+ if (mIsAccessibilityEnabled)
+ return false;
+ // Such as spacebar sliding language switch.
+ if (mKeyboard.needSpacebarPreview(keyIndex))
+ return false;
+ final int code = key.mCode;
+ return isModifierCode(code) || code == Keyboard.CODE_DELETE
+ || code == Keyboard.CODE_ENTER || code == Keyboard.CODE_SPACE;
+ }
+
+ private void showKeyPreview(int keyIndex) {
+ if (isKeyPreviewNotRequired(keyIndex))
return;
mProxy.showKeyPreview(keyIndex, this);
}