From 50d902ac6fd018131bd7044dd968bb99e0fdba7b Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 10 Jan 2013 11:31:47 +0900 Subject: [PATCH] Show final suggested word when batch input is finished This change moves dismiss timer of gesture floating preview text from PreviewPlacerView to KeyboardView. Bug: 7967461 Change-Id: I0ca5beddc93cb4bc4a405f914d217d37b997402b --- .../inputmethod/keyboard/KeyboardView.java | 16 ++++++++++- .../internal/GestureFloatingPreviewText.java | 6 +--- .../keyboard/internal/PreviewPlacerView.java | 28 ++++--------------- .../android/inputmethod/latin/LatinIME.java | 3 +- 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 63b9ed666..b7584d4cd 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -153,6 +153,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, private boolean mShowKeyPreviewPopup = true; private int mKeyPreviewLingerTimeout; + // Gesture floating preview text + // TODO: Make this parameter customizable by user via settings. + private int mGestureFloatingPreviewTextLingerTimeout; + // Background state set private static final int[][][] KEY_PREVIEW_BACKGROUND_STATE_TABLE = { { // STATE_MIDDLE @@ -204,6 +208,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, public static class DrawingHandler extends StaticInnerHandlerWrapper { private static final int MSG_DISMISS_KEY_PREVIEW = 0; + private static final int MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 1; public DrawingHandler(final KeyboardView outerInstance) { super(outerInstance); @@ -221,6 +226,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, previewText.setVisibility(INVISIBLE); } break; + case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT: + keyboardView.mPreviewPlacerView.setGestureFloatingPreviewText(SuggestedWords.EMPTY); + break; } } @@ -236,6 +244,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, removeMessages(MSG_DISMISS_KEY_PREVIEW); } + public void dismissGestureFloatingPreviewText(final long delay) { + sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), delay); + } + public void cancelAllMessages() { cancelAllDismissKeyPreviews(); } @@ -279,6 +291,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, R.styleable.KeyboardView_moreKeysLayout, 0); mBackgroundDimAlpha = keyboardViewAttr.getInt( R.styleable.KeyboardView_backgroundDimAlpha, 0); + mGestureFloatingPreviewTextLingerTimeout = keyboardViewAttr.getInt( + R.styleable.KeyboardView_gestureFloatingPreviewTextLingerTimeout, 0); keyboardViewAttr.recycle(); final TypedArray keyAttr = context.obtainStyledAttributes(attrs, @@ -877,7 +891,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy, public void dismissGestureFloatingPreviewText() { locatePreviewPlacerView(); - mPreviewPlacerView.dismissGestureFloatingPreviewText(); + mDrawingHandler.dismissGestureFloatingPreviewText(mGestureFloatingPreviewTextLingerTimeout); } @Override diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java b/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java index 30ca859d3..aed23a4db 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureFloatingPreviewText.java @@ -100,11 +100,7 @@ public class GestureFloatingPreviewText extends AbstractDrawingPreview { } public void setSuggetedWords(final SuggestedWords suggestedWords) { - if (suggestedWords == null) { - mSuggestedWords = SuggestedWords.EMPTY; - } else { - mSuggestedWords = suggestedWords; - } + mSuggestedWords = suggestedWords; updatePreviewPosition(); } diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java index a005dc975..bfb7b1fe0 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java @@ -41,6 +41,7 @@ import com.android.inputmethod.latin.SuggestedWords; public final class PreviewPlacerView extends RelativeLayout { private final int[] mKeyboardViewOrigin = CoordinateUtils.newInstance(); + // TODO: Consolidate gesture preview trail with {@link KeyboardView} private final SparseArray mGesturePreviewTrails = CollectionUtils.newSparseArray(); private final Params mGesturePreviewTrailParams; @@ -60,19 +61,16 @@ public final class PreviewPlacerView extends RelativeLayout { private final DrawingHandler mDrawingHandler; + // TODO: Remove drawing handler. private static final class DrawingHandler extends StaticInnerHandlerWrapper { - private static final int MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 0; - private static final int MSG_UPDATE_GESTURE_PREVIEW_TRAIL = 1; + private static final int MSG_UPDATE_GESTURE_PREVIEW_TRAIL = 0; private final Params mGesturePreviewTrailParams; - private final int mGestureFloatingPreviewTextLingerTimeout; public DrawingHandler(final PreviewPlacerView outerInstance, - final Params gesturePreviewTrailParams, - final int getstureFloatinPreviewTextLinerTimeout) { + final Params gesturePreviewTrailParams) { super(outerInstance); mGesturePreviewTrailParams = gesturePreviewTrailParams; - mGestureFloatingPreviewTextLingerTimeout = getstureFloatinPreviewTextLinerTimeout; } @Override @@ -80,21 +78,12 @@ public final class PreviewPlacerView extends RelativeLayout { final PreviewPlacerView placerView = getOuterInstance(); if (placerView == null) return; switch (msg.what) { - case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT: - placerView.setGestureFloatingPreviewText(null); - break; case MSG_UPDATE_GESTURE_PREVIEW_TRAIL: placerView.invalidate(); break; } } - public void dismissGestureFloatingPreviewText() { - removeMessages(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT); - sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), - mGestureFloatingPreviewTextLingerTimeout); - } - public void postUpdateGestureTrailPreview() { removeMessages(MSG_UPDATE_GESTURE_PREVIEW_TRAIL); sendMessageDelayed(obtainMessage(MSG_UPDATE_GESTURE_PREVIEW_TRAIL), @@ -112,16 +101,13 @@ public final class PreviewPlacerView extends RelativeLayout { final TypedArray keyboardViewAttr = context.obtainStyledAttributes( attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView); - final int gestureFloatingPreviewTextLingerTimeout = keyboardViewAttr.getInt( - R.styleable.KeyboardView_gestureFloatingPreviewTextLingerTimeout, 0); // TODO: mGestureFloatingPreviewText could be an instance of GestureFloatingPreviewText or // MultiGesturePreviewText, depending on the user's choice in the settings. mGestureFloatingPreviewText = new GestureFloatingPreviewText(keyboardViewAttr, context); mGesturePreviewTrailParams = new Params(keyboardViewAttr); keyboardViewAttr.recycle(); - mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams, - gestureFloatingPreviewTextLingerTimeout); + mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams); final Paint gesturePaint = new Paint(); gesturePaint.setAntiAlias(true); @@ -285,10 +271,6 @@ public final class PreviewPlacerView extends RelativeLayout { invalidate(); } - public void dismissGestureFloatingPreviewText() { - mDrawingHandler.dismissGestureFloatingPreviewText(); - } - private void drawSlidingKeyInputPreview(final Canvas canvas) { // TODO: Implement rubber band preview } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f1f50fe8f..df733c55a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1588,10 +1588,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final boolean dismissGestureFloatingPreviewText) { showSuggestionStrip(suggestedWords, null); final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); + mainKeyboardView.showGestureFloatingPreviewText(suggestedWords); if (dismissGestureFloatingPreviewText) { mainKeyboardView.dismissGestureFloatingPreviewText(); - } else { - mainKeyboardView.showGestureFloatingPreviewText(suggestedWords); } }