Merge "Show final suggested word when batch input is finished"
This commit is contained in:
commit
a80b8fc98f
4 changed files with 22 additions and 31 deletions
|
@ -153,6 +153,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
|
||||||
private boolean mShowKeyPreviewPopup = true;
|
private boolean mShowKeyPreviewPopup = true;
|
||||||
private int mKeyPreviewLingerTimeout;
|
private int mKeyPreviewLingerTimeout;
|
||||||
|
|
||||||
|
// Gesture floating preview text
|
||||||
|
// TODO: Make this parameter customizable by user via settings.
|
||||||
|
private int mGestureFloatingPreviewTextLingerTimeout;
|
||||||
|
|
||||||
// Background state set
|
// Background state set
|
||||||
private static final int[][][] KEY_PREVIEW_BACKGROUND_STATE_TABLE = {
|
private static final int[][][] KEY_PREVIEW_BACKGROUND_STATE_TABLE = {
|
||||||
{ // STATE_MIDDLE
|
{ // STATE_MIDDLE
|
||||||
|
@ -204,6 +208,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
|
||||||
|
|
||||||
public static class DrawingHandler extends StaticInnerHandlerWrapper<KeyboardView> {
|
public static class DrawingHandler extends StaticInnerHandlerWrapper<KeyboardView> {
|
||||||
private static final int MSG_DISMISS_KEY_PREVIEW = 0;
|
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) {
|
public DrawingHandler(final KeyboardView outerInstance) {
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
|
@ -221,6 +226,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
|
||||||
previewText.setVisibility(INVISIBLE);
|
previewText.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
break;
|
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);
|
removeMessages(MSG_DISMISS_KEY_PREVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dismissGestureFloatingPreviewText(final long delay) {
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), delay);
|
||||||
|
}
|
||||||
|
|
||||||
public void cancelAllMessages() {
|
public void cancelAllMessages() {
|
||||||
cancelAllDismissKeyPreviews();
|
cancelAllDismissKeyPreviews();
|
||||||
}
|
}
|
||||||
|
@ -279,6 +291,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
|
||||||
R.styleable.KeyboardView_moreKeysLayout, 0);
|
R.styleable.KeyboardView_moreKeysLayout, 0);
|
||||||
mBackgroundDimAlpha = keyboardViewAttr.getInt(
|
mBackgroundDimAlpha = keyboardViewAttr.getInt(
|
||||||
R.styleable.KeyboardView_backgroundDimAlpha, 0);
|
R.styleable.KeyboardView_backgroundDimAlpha, 0);
|
||||||
|
mGestureFloatingPreviewTextLingerTimeout = keyboardViewAttr.getInt(
|
||||||
|
R.styleable.KeyboardView_gestureFloatingPreviewTextLingerTimeout, 0);
|
||||||
keyboardViewAttr.recycle();
|
keyboardViewAttr.recycle();
|
||||||
|
|
||||||
final TypedArray keyAttr = context.obtainStyledAttributes(attrs,
|
final TypedArray keyAttr = context.obtainStyledAttributes(attrs,
|
||||||
|
@ -877,7 +891,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
|
||||||
|
|
||||||
public void dismissGestureFloatingPreviewText() {
|
public void dismissGestureFloatingPreviewText() {
|
||||||
locatePreviewPlacerView();
|
locatePreviewPlacerView();
|
||||||
mPreviewPlacerView.dismissGestureFloatingPreviewText();
|
mDrawingHandler.dismissGestureFloatingPreviewText(mGestureFloatingPreviewTextLingerTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,11 +100,7 @@ public class GestureFloatingPreviewText extends AbstractDrawingPreview {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggetedWords(final SuggestedWords suggestedWords) {
|
public void setSuggetedWords(final SuggestedWords suggestedWords) {
|
||||||
if (suggestedWords == null) {
|
mSuggestedWords = suggestedWords;
|
||||||
mSuggestedWords = SuggestedWords.EMPTY;
|
|
||||||
} else {
|
|
||||||
mSuggestedWords = suggestedWords;
|
|
||||||
}
|
|
||||||
updatePreviewPosition();
|
updatePreviewPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import com.android.inputmethod.latin.SuggestedWords;
|
||||||
public final class PreviewPlacerView extends RelativeLayout {
|
public final class PreviewPlacerView extends RelativeLayout {
|
||||||
private final int[] mKeyboardViewOrigin = CoordinateUtils.newInstance();
|
private final int[] mKeyboardViewOrigin = CoordinateUtils.newInstance();
|
||||||
|
|
||||||
|
// TODO: Consolidate gesture preview trail with {@link KeyboardView}
|
||||||
private final SparseArray<GesturePreviewTrail> mGesturePreviewTrails =
|
private final SparseArray<GesturePreviewTrail> mGesturePreviewTrails =
|
||||||
CollectionUtils.newSparseArray();
|
CollectionUtils.newSparseArray();
|
||||||
private final Params mGesturePreviewTrailParams;
|
private final Params mGesturePreviewTrailParams;
|
||||||
|
@ -60,19 +61,16 @@ public final class PreviewPlacerView extends RelativeLayout {
|
||||||
|
|
||||||
private final DrawingHandler mDrawingHandler;
|
private final DrawingHandler mDrawingHandler;
|
||||||
|
|
||||||
|
// TODO: Remove drawing handler.
|
||||||
private static final class DrawingHandler extends StaticInnerHandlerWrapper<PreviewPlacerView> {
|
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 = 0;
|
||||||
private static final int MSG_UPDATE_GESTURE_PREVIEW_TRAIL = 1;
|
|
||||||
|
|
||||||
private final Params mGesturePreviewTrailParams;
|
private final Params mGesturePreviewTrailParams;
|
||||||
private final int mGestureFloatingPreviewTextLingerTimeout;
|
|
||||||
|
|
||||||
public DrawingHandler(final PreviewPlacerView outerInstance,
|
public DrawingHandler(final PreviewPlacerView outerInstance,
|
||||||
final Params gesturePreviewTrailParams,
|
final Params gesturePreviewTrailParams) {
|
||||||
final int getstureFloatinPreviewTextLinerTimeout) {
|
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
mGesturePreviewTrailParams = gesturePreviewTrailParams;
|
mGesturePreviewTrailParams = gesturePreviewTrailParams;
|
||||||
mGestureFloatingPreviewTextLingerTimeout = getstureFloatinPreviewTextLinerTimeout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,21 +78,12 @@ public final class PreviewPlacerView extends RelativeLayout {
|
||||||
final PreviewPlacerView placerView = getOuterInstance();
|
final PreviewPlacerView placerView = getOuterInstance();
|
||||||
if (placerView == null) return;
|
if (placerView == null) return;
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT:
|
|
||||||
placerView.setGestureFloatingPreviewText(null);
|
|
||||||
break;
|
|
||||||
case MSG_UPDATE_GESTURE_PREVIEW_TRAIL:
|
case MSG_UPDATE_GESTURE_PREVIEW_TRAIL:
|
||||||
placerView.invalidate();
|
placerView.invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismissGestureFloatingPreviewText() {
|
|
||||||
removeMessages(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT);
|
|
||||||
sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT),
|
|
||||||
mGestureFloatingPreviewTextLingerTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void postUpdateGestureTrailPreview() {
|
public void postUpdateGestureTrailPreview() {
|
||||||
removeMessages(MSG_UPDATE_GESTURE_PREVIEW_TRAIL);
|
removeMessages(MSG_UPDATE_GESTURE_PREVIEW_TRAIL);
|
||||||
sendMessageDelayed(obtainMessage(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(
|
final TypedArray keyboardViewAttr = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
|
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
|
// TODO: mGestureFloatingPreviewText could be an instance of GestureFloatingPreviewText or
|
||||||
// MultiGesturePreviewText, depending on the user's choice in the settings.
|
// MultiGesturePreviewText, depending on the user's choice in the settings.
|
||||||
mGestureFloatingPreviewText = new GestureFloatingPreviewText(keyboardViewAttr, context);
|
mGestureFloatingPreviewText = new GestureFloatingPreviewText(keyboardViewAttr, context);
|
||||||
mGesturePreviewTrailParams = new Params(keyboardViewAttr);
|
mGesturePreviewTrailParams = new Params(keyboardViewAttr);
|
||||||
keyboardViewAttr.recycle();
|
keyboardViewAttr.recycle();
|
||||||
|
|
||||||
mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams,
|
mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams);
|
||||||
gestureFloatingPreviewTextLingerTimeout);
|
|
||||||
|
|
||||||
final Paint gesturePaint = new Paint();
|
final Paint gesturePaint = new Paint();
|
||||||
gesturePaint.setAntiAlias(true);
|
gesturePaint.setAntiAlias(true);
|
||||||
|
@ -285,10 +271,6 @@ public final class PreviewPlacerView extends RelativeLayout {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismissGestureFloatingPreviewText() {
|
|
||||||
mDrawingHandler.dismissGestureFloatingPreviewText();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawSlidingKeyInputPreview(final Canvas canvas) {
|
private void drawSlidingKeyInputPreview(final Canvas canvas) {
|
||||||
// TODO: Implement rubber band preview
|
// TODO: Implement rubber band preview
|
||||||
}
|
}
|
||||||
|
|
|
@ -1588,10 +1588,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
final boolean dismissGestureFloatingPreviewText) {
|
final boolean dismissGestureFloatingPreviewText) {
|
||||||
showSuggestionStrip(suggestedWords, null);
|
showSuggestionStrip(suggestedWords, null);
|
||||||
final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
||||||
|
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
|
||||||
if (dismissGestureFloatingPreviewText) {
|
if (dismissGestureFloatingPreviewText) {
|
||||||
mainKeyboardView.dismissGestureFloatingPreviewText();
|
mainKeyboardView.dismissGestureFloatingPreviewText();
|
||||||
} else {
|
|
||||||
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue