am a80b8fc9: Merge "Show final suggested word when batch input is finished"

* commit 'a80b8fc98f321920bc045bb5fd9952680d0e439e':
  Show final suggested word when batch input is finished
This commit is contained in:
Tadashi G. Takaoka 2013-01-09 23:37:59 -08:00 committed by Android Git Automerger
commit 1e1791cc6e
4 changed files with 22 additions and 31 deletions

View file

@ -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<KeyboardView> {
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

View file

@ -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();
}

View file

@ -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<GesturePreviewTrail> 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<PreviewPlacerView> {
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
}

View file

@ -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);
}
}