diff options
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/PointerTracker.java')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/PointerTracker.java | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index d4902ec28..0778ad902 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -46,6 +46,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { private static boolean sMainDictionaryAvailable = false; private static boolean sGestureHandlingEnabledByInputField = false; private static boolean sGestureHandlingEnabledByUser = false; + private static boolean sGestureOffWhileFastTyping = false; public interface KeyEventHandler { /** @@ -84,6 +85,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { public interface TimerProxy { public void startTypingStateTimer(Key typedKey); public boolean isTypingState(); + public void startGestureOffWhileFastTypingTimer(); public void startKeyRepeatTimer(PointerTracker tracker); public void startLongPressTimer(PointerTracker tracker); public void startLongPressTimer(int code); @@ -99,6 +101,8 @@ public class PointerTracker implements PointerTrackerQueue.Element { @Override public boolean isTypingState() { return false; } @Override + public void startGestureOffWhileFastTypingTimer() {} + @Override public void startKeyRepeatTimer(PointerTracker tracker) {} @Override public void startLongPressTimer(PointerTracker tracker) {} @@ -225,6 +229,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { private static void updateGestureHandlingMode() { sShouldHandleGesture = sMainDictionaryAvailable + && !sGestureOffWhileFastTyping && sGestureHandlingEnabledByInputField && sGestureHandlingEnabledByUser && !AccessibilityUtils.getInstance().isTouchExplorationEnabled(); @@ -241,6 +246,16 @@ public class PointerTracker implements PointerTrackerQueue.Element { updateGestureHandlingMode(); } + public static void setGestureOffWhileFastTyping() { + sGestureOffWhileFastTyping = true; + updateGestureHandlingMode(); + } + + public static void clearGestureOffWhileFastTyping() { + sGestureOffWhileFastTyping = false; + updateGestureHandlingMode(); + } + public static PointerTracker getPointerTracker(final int id, final KeyEventHandler handler) { final ArrayList<PointerTracker> trackers = sTrackers; @@ -346,8 +361,10 @@ public class PointerTracker implements PointerTrackerQueue.Element { if (key.isEnabled() || altersCode) { if (code == Keyboard.CODE_OUTPUT_TEXT) { mListener.onTextInput(key.getOutputText()); + mTimerProxy.startGestureOffWhileFastTypingTimer(); } else if (code != Keyboard.CODE_UNSPECIFIED) { mListener.onCodeInput(code, x, y); + mTimerProxy.startGestureOffWhileFastTypingTimer(); } } } @@ -668,18 +685,13 @@ public class PointerTracker implements PointerTrackerQueue.Element { if (!sShouldHandleGesture) { return; } - final int activePointerTrackerCount = getActivePointerTrackerCount(); - if (activePointerTrackerCount == 1) { - mIsDetectingGesture = false; - // A gesture should start only from the letter key. - final boolean isAlphabetKeyboard = (mKeyboard != null) - && mKeyboard.mId.isAlphabetKeyboard(); - if (isAlphabetKeyboard && !mIsShowingMoreKeysPanel && key != null - && Keyboard.isLetterCode(key.mCode)) { + // A gesture should start only from the letter key. + mIsDetectingGesture = (mKeyboard != null) && mKeyboard.mId.isAlphabetKeyboard() + && !mIsShowingMoreKeysPanel && key != null && Keyboard.isLetterCode(key.mCode); + if (mIsDetectingGesture) { + if (getActivePointerTrackerCount() == 1) { sGestureFirstDownTime = eventTime; - onGestureDownEvent(x, y, eventTime); } - } else if (sInGesture && activePointerTrackerCount > 1) { onGestureDownEvent(x, y, eventTime); } } |