From 67a4ecacc7525c9343cded13fc93e9a2381ea2d8 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sat, 18 Dec 2010 18:48:32 +0900 Subject: [PATCH] Disallow sliding key input This feature is configurable by R.bool.config_sliding_key_input_enabled. Bug: 3294076 Change-Id: I0225a6ce19d9b911c9d9543a106ab57ee0b7de75 --- java/res/values-xlarge/config.xml | 1 + java/res/values/config.xml | 1 + .../inputmethod/keyboard/PointerTracker.java | 33 +++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/java/res/values-xlarge/config.xml b/java/res/values-xlarge/config.xml index 26c23dd1c..5b9932b06 100644 --- a/java/res/values-xlarge/config.xml +++ b/java/res/values-xlarge/config.xml @@ -23,6 +23,7 @@ false false false + false false medium diff --git a/java/res/values/config.xml b/java/res/values/config.xml index d82960e15..4187c31fb 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -26,6 +26,7 @@ true true true + true true 0 diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 65c370dcd..c96cefd2b 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -51,6 +51,7 @@ public class PointerTracker { private final KeyDetector mKeyDetector; private KeyboardActionListener mListener; private final boolean mHasDistinctMultitouch; + private final boolean mConfigSlidingKeyInputEnabled; private Keyboard mKeyboard; private Key[] mKeys; @@ -64,6 +65,9 @@ public class PointerTracker { // true if this pointer is repeatable key private boolean mIsRepeatableKey; + // true if sliding key is allowed. + private boolean mIsAllowedSlidingKeyInput; + // For multi-tap private int mLastSentIndex; private int mTapCount; @@ -173,6 +177,7 @@ public class PointerTracker { mKeyDetector = keyDetector; mKeyState = new KeyState(keyDetector); mHasDistinctMultitouch = proxy.hasDistinctMultitouch(); + mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled); mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start); mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout); mLongPressShiftKeyTimeout = res.getInteger(R.integer.config_long_press_shift_key_timeout); @@ -277,6 +282,10 @@ public class PointerTracker { if (DEBUG) debugLog("onDownEvent:", x, y); int keyIndex = mKeyState.onDownKey(x, y, eventTime); + // Sliding key is allowed when 1) enabled by configuration, 2) this pointer starts sliding + // form modifier key, or 3) this pointer is on mini-keyboard. + mIsAllowedSlidingKeyInput = mConfigSlidingKeyInputEnabled || isModifierInternal(keyIndex) + || mKeyDetector instanceof MiniKeyboardKeyDetector; mKeyAlreadyProcessed = false; mIsRepeatableKey = false; checkMultiTap(eventTime, keyIndex); @@ -304,7 +313,7 @@ public class PointerTracker { debugLog("onMoveEvent:", x, y); if (mKeyAlreadyProcessed) return; - KeyState keyState = mKeyState; + final KeyState keyState = mKeyState; final int keyIndex = keyState.onMoveKey(x, y); final Key oldKey = getKey(keyState.getKeyIndex()); if (isValidKeyIndex(keyIndex)) { @@ -314,16 +323,28 @@ public class PointerTracker { } else if (!isMinorMoveBounce(x, y, keyIndex)) { if (mListener != null) mListener.onRelease(oldKey.mCodes[0]); - resetMultiTap(); - keyState.onMoveToNewKey(keyIndex, x, y); - startLongPressTimer(keyIndex); + if (mIsAllowedSlidingKeyInput) { + resetMultiTap(); + keyState.onMoveToNewKey(keyIndex, x, y); + startLongPressTimer(keyIndex); + } else { + setAlreadyProcessed(); + showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY); + return; + } } } else { if (oldKey != null) { if (mListener != null) mListener.onRelease(oldKey.mCodes[0]); - keyState.onMoveToNewKey(keyIndex, x ,y); - mHandler.cancelLongPressTimers(); + if (mIsAllowedSlidingKeyInput) { + keyState.onMoveToNewKey(keyIndex, x ,y); + mHandler.cancelLongPressTimers(); + } else { + setAlreadyProcessed(); + showKeyPreviewAndUpdateKeyGraphics(NOT_A_KEY); + return; + } } else if (!isMinorMoveBounce(x, y, keyIndex)) { resetMultiTap(); keyState.onMoveToNewKey(keyIndex, x ,y);