diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index bece71928..61d38745e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -1013,7 +1013,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, public void closing() { dismissAllKeyPreviews(); cancelAllMessages(); - + onCancelMoreKeysPanel(); mInvalidateAllKeys = true; requestLayout(); } @@ -1031,11 +1031,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, return (mMoreKeysPanel != null); } - public boolean dismissMoreKeysPanel() { + @Override + public void onCancelMoreKeysPanel() { if (isShowingMoreKeysPanel()) { - return mMoreKeysPanel.dismissMoreKeysPanel(); + mMoreKeysPanel.dismissMoreKeysPanel(); } - return false; } @Override diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 767297ae2..584d2fe46 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -844,10 +844,16 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack @Override public void closing() { super.closing(); - dismissMoreKeysPanel(); + onCancelMoreKeysPanel(); mMoreKeysPanelCache.clear(); } + @Override + public void onCancelMoreKeysPanel() { + super.onCancelMoreKeysPanel(); + PointerTracker.dismissAllMoreKeysPanels(); + } + @Override public boolean onDismissMoreKeysPanel() { dimEntireKeyboard(false /* dimmed */); diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java index d7186d39f..8a5b7dad5 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java @@ -120,7 +120,15 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel @Override public void onMoveEvent(int x, int y, final int pointerId, long eventTime) { + if (mActivePointerId != pointerId) { + return; + } + final boolean hasOldKey = (mCurrentKey != null); onMoveKeyInternal(x, y, pointerId); + if (hasOldKey && mCurrentKey == null) { + // If the pointer has moved too far away from any target then cancel the panel. + mController.onCancelMoreKeysPanel(); + } } @Override diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java b/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java index 8f43c9cd6..9c677e5c8 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysPanel.java @@ -30,6 +30,11 @@ public interface MoreKeysPanel { * Remove the current {@link MoreKeysPanel} from the target view. */ public boolean onDismissMoreKeysPanel(); + + /** + * Instructs the parent to cancel the panel (e.g., when entering a different input mode). + */ + public void onCancelMoreKeysPanel(); } /** diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 7d91aedfc..0f55607a0 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -412,6 +412,17 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } + public static void dismissAllMoreKeysPanels() { + final int trackersSize = sTrackers.size(); + for (int i = 0; i < trackersSize; ++i) { + final PointerTracker tracker = sTrackers.get(i); + if (tracker.isShowingMoreKeysPanel()) { + tracker.mMoreKeysPanel.dismissMoreKeysPanel(); + tracker.mMoreKeysPanel = null; + } + } + } + private PointerTracker(final int id, final KeyEventHandler handler) { if (handler == null) { throw new NullPointerException(); @@ -715,6 +726,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { sLastRecognitionPointSize = 0; sLastRecognitionTime = 0; mListener.onStartBatchInput(); + dismissAllMoreKeysPanels(); } mTimerProxy.cancelLongPressTimer(); mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this)); @@ -846,7 +858,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } // A gesture should start only from a non-modifier key. mIsDetectingGesture = (mKeyboard != null) && mKeyboard.mId.isAlphabetKeyboard() - && !isShowingMoreKeysPanel() && key != null && !key.isModifier(); + && key != null && !key.isModifier(); if (mIsDetectingGesture) { if (getActivePointerTrackerCount() == 1) { sGestureFirstDownTime = eventTime; @@ -907,6 +919,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element { cancelBatchInput(); return; } + // If the MoreKeysPanel is showing then do not attempt to enter gesture mode. However, + // the gestured touch points are still being recorded in case the panel is dismissed. + if (isShowingMoreKeysPanel()) { + return; + } mayStartBatchInput(key); if (sInGesture) { mayUpdateBatchInput(eventTime, key); @@ -926,7 +943,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element { final int translatedX = mMoreKeysPanel.translateX(x); final int translatedY = mMoreKeysPanel.translateY(y); mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime); - return; } if (sShouldHandleGesture && me != null) { @@ -941,6 +957,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element { false /* isMajorEvent */, null); } } + + if (isShowingMoreKeysPanel()) { + // Do not handle sliding keys (or show key pop-ups) when the MoreKeysPanel is visible. + return; + } onMoveEventInternal(x, y, eventTime); } @@ -1199,8 +1220,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mTimerProxy.cancelKeyTimers(); setReleasedKeyGraphics(mCurrentKey); resetSlidingKeyInput(); - mMoreKeysPanel.dismissMoreKeysPanel(); - mMoreKeysPanel = null; + if (isShowingMoreKeysPanel()) { + mMoreKeysPanel.dismissMoreKeysPanel(); + mMoreKeysPanel = null; + } } private void startRepeatKey(final Key key) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index 1888912ac..d7b514e8a 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -684,6 +684,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick public void onShowMoreKeysPanel(MoreKeysPanel panel) { mKeyboardView.onShowMoreKeysPanel(panel); } + + @Override + public void onCancelMoreKeysPanel() { + dismissMoreSuggestions(); + } }; boolean dismissMoreSuggestions() {