From 43ad100d8bc20fc1327a462f24b5f8c99849ffbe Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 13 May 2013 15:05:37 +0900 Subject: [PATCH] Disable long press timer while sliding input mode Bug: 8915171 Change-Id: Id8685f90766c7de55b56476de83abf97150a186d --- java/src/com/android/inputmethod/keyboard/Key.java | 2 +- .../android/inputmethod/keyboard/KeyboardView.java | 2 +- .../android/inputmethod/keyboard/PointerTracker.java | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index d160038ad..1550e77e3 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -105,7 +105,7 @@ public class Key implements Comparable { /** Hit bounding box of the key */ public final Rect mHitBox = new Rect(); - /** More keys */ + /** More keys. It is guaranteed that this is null or an array of one or more elements */ public final MoreKeySpec[] mMoreKeys; /** More keys column number and flags */ private final int mMoreKeysColumnAndFlags; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index e4e75c342..7941fcba2 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -497,7 +497,7 @@ public class KeyboardView extends View { } } - if (key.hasPopupHint() && key.mMoreKeys != null && key.mMoreKeys.length > 0) { + if (key.hasPopupHint() && key.mMoreKeys != null) { drawKeyPopupHint(key, canvas, paint, params); } } diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 5e4b1a58d..3ed6c896e 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -1303,9 +1303,15 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } private void startLongPressTimer(final Key key) { - if (key != null && key.isLongPressEnabled() && !sInGesture) { - mTimerProxy.startLongPressTimer(this); - } + if (sInGesture) return; + if (key == null) return; + if (!key.isLongPressEnabled()) return; + // Caveat: Please note that isLongPressEnabled() can be true even if the current key + // doesn't have its more keys. (e.g. spacebar, globe key) + // We always need to start the long press timer if the key has its more keys regardless of + // whether or not we are in the sliding input mode. + if (mIsInSlidingKeyInputFromModifier && key.mMoreKeys == null) return; + mTimerProxy.startLongPressTimer(this); } private void detectAndSendKey(final Key key, final int x, final int y, final long eventTime) {