From 8e2b34cdb24adb1563cc296a4741be7391fa24e9 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 5 Dec 2012 17:49:35 -0800 Subject: [PATCH] Cancel batch input when orientation has been changed Bug: 7665231 Bug: 7662486 Change-Id: I7b6095026dbf1b9b2f6d3b29f2ab83c462ab374e --- .../inputmethod/keyboard/PointerTracker.java | 23 ++++++++++++------- .../android/inputmethod/latin/LatinIME.java | 9 ++++---- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index d9a520917..20a299e49 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -777,6 +777,15 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this)); } + private void cancelBatchInput() { + sPointerTrackerQueue.cancelAllPointerTracker(); + sInGesture = false; + if (DEBUG_LISTENER) { + Log.d(TAG, String.format("[%d] onCancelBatchInput", mPointerId)); + } + mListener.onCancelBatchInput(); + } + public void processMotionEvent(final int action, final int x, final int y, final long eventTime, final KeyEventHandler handler) { switch (action) { @@ -892,12 +901,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard( x, y, gestureTime, isMajorEvent); if (!onValidArea) { - sPointerTrackerQueue.cancelAllPointerTracker(); - if (DEBUG_LISTENER) { - Log.d(TAG, String.format("[%d] onCancelBatchInput: batchPoints=%d", - mPointerId, sAggregratedPointers.getPointerSize())); - } - mListener.onCancelBatchInput(); + cancelBatchInput(); return; } mayStartBatchInput(key); @@ -1162,8 +1166,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element { printTouchEvent("onCancelEvt:", x, y, eventTime); } - sPointerTrackerQueue.releaseAllPointersExcept(this, eventTime); - sPointerTrackerQueue.remove(this); + if (sInGesture) { + cancelBatchInput(); + } + sPointerTrackerQueue.cancelAllPointerTracker(); + sPointerTrackerQueue.releaseAllPointers(eventTime); onCancelEventInternal(); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 3935f99ab..305f38d8c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1553,13 +1553,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords, final boolean dismissGestureFloatingPreviewText) { - final String batchInputText = suggestedWords.isEmpty() - ? null : suggestedWords.getWord(0); - final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - mainKeyboardView.showGestureFloatingPreviewText(batchInputText); showSuggestionStrip(suggestedWords, null); + final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); if (dismissGestureFloatingPreviewText) { mainKeyboardView.dismissGestureFloatingPreviewText(); + } else { + final String batchInputText = suggestedWords.isEmpty() + ? null : suggestedWords.getWord(0); + mainKeyboardView.showGestureFloatingPreviewText(batchInputText); } }