am 37598210: Move PointerTracker.DrawingProxy to MainKeyboardView (step 2)
* commit '375982106bf073971fccd14b2c65ec8e089bb2ae': Move PointerTracker.DrawingProxy to MainKeyboardView (step 2)main
commit
fe4b3ff0a3
|
@ -51,8 +51,6 @@
|
||||||
<!-- Blur radius of key text shadow. -->
|
<!-- Blur radius of key text shadow. -->
|
||||||
<attr name="keyTextShadowRadius" format="float" />
|
<attr name="keyTextShadowRadius" format="float" />
|
||||||
|
|
||||||
<!-- Layout resource for key press feedback.-->
|
|
||||||
<attr name="keyPreviewLayout" format="reference" />
|
|
||||||
<!-- Key preview background states -->
|
<!-- Key preview background states -->
|
||||||
<attr name="state_left_edge" format="boolean" />
|
<attr name="state_left_edge" format="boolean" />
|
||||||
<attr name="state_right_edge" format="boolean" />
|
<attr name="state_right_edge" format="boolean" />
|
||||||
|
@ -71,8 +69,6 @@
|
||||||
<attr name="gestureFloatingPreviewHorizontalPadding" format="dimension" />
|
<attr name="gestureFloatingPreviewHorizontalPadding" format="dimension" />
|
||||||
<attr name="gestureFloatingPreviewVerticalPadding" format="dimension" />
|
<attr name="gestureFloatingPreviewVerticalPadding" format="dimension" />
|
||||||
<attr name="gestureFloatingPreviewRoundRadius" format="dimension" />
|
<attr name="gestureFloatingPreviewRoundRadius" format="dimension" />
|
||||||
<!-- Delay after gesture input and gesture floating preview text dismissing in millisecond -->
|
|
||||||
<attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" />
|
|
||||||
<!-- Delay after gesture trail starts fading out in millisecond. -->
|
<!-- Delay after gesture trail starts fading out in millisecond. -->
|
||||||
<attr name="gesturePreviewTrailFadeoutStartDelay" format="integer" />
|
<attr name="gesturePreviewTrailFadeoutStartDelay" format="integer" />
|
||||||
<!-- Duration while gesture preview trail is fading out in millisecond. -->
|
<!-- Duration while gesture preview trail is fading out in millisecond. -->
|
||||||
|
@ -117,6 +113,8 @@
|
||||||
<attr name="longPressShiftKeyTimeout" format="integer" />
|
<attr name="longPressShiftKeyTimeout" format="integer" />
|
||||||
<!-- Ignore special key timeout while typing in millisecond. -->
|
<!-- Ignore special key timeout while typing in millisecond. -->
|
||||||
<attr name="ignoreAltCodeKeyTimeout" format="integer" />
|
<attr name="ignoreAltCodeKeyTimeout" format="integer" />
|
||||||
|
<!-- Layout resource for key press feedback.-->
|
||||||
|
<attr name="keyPreviewLayout" format="reference" />
|
||||||
<!-- Vertical offset of the key press feedback from the key. -->
|
<!-- Vertical offset of the key press feedback from the key. -->
|
||||||
<attr name="keyPreviewOffset" format="dimension" />
|
<attr name="keyPreviewOffset" format="dimension" />
|
||||||
<!-- Height of the key press feedback popup. -->
|
<!-- Height of the key press feedback popup. -->
|
||||||
|
@ -127,6 +125,8 @@
|
||||||
<attr name="moreKeysKeyboardLayout" format="reference" />
|
<attr name="moreKeysKeyboardLayout" format="reference" />
|
||||||
<!-- More keys keyboard will shown at touched point. -->
|
<!-- More keys keyboard will shown at touched point. -->
|
||||||
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
||||||
|
<!-- Delay after gesture input and gesture floating preview text dismissing in millisecond -->
|
||||||
|
<attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" />
|
||||||
<!-- Static threshold for gesture after fast typing (msec) -->
|
<!-- Static threshold for gesture after fast typing (msec) -->
|
||||||
<attr name="gestureStaticTimeThresholdAfterFastTyping" format="integer" />
|
<attr name="gestureStaticTimeThresholdAfterFastTyping" format="integer" />
|
||||||
<!-- Static threshold for starting gesture detection (keyWidth%/sec) -->
|
<!-- Static threshold for starting gesture detection (keyWidth%/sec) -->
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
<item name="keyHintLetterPadding">@dimen/key_hint_letter_padding</item>
|
<item name="keyHintLetterPadding">@dimen/key_hint_letter_padding</item>
|
||||||
<item name="keyPopupHintLetterPadding">@dimen/key_popup_hint_letter_padding</item>
|
<item name="keyPopupHintLetterPadding">@dimen/key_popup_hint_letter_padding</item>
|
||||||
<item name="keyShiftedLetterHintPadding">@dimen/key_uppercase_letter_padding</item>
|
<item name="keyShiftedLetterHintPadding">@dimen/key_uppercase_letter_padding</item>
|
||||||
<item name="keyPreviewLayout">@layout/key_preview</item>
|
|
||||||
<item name="keyPreviewTextColor">@color/key_text_color_default</item>
|
<item name="keyPreviewTextColor">@color/key_text_color_default</item>
|
||||||
<item name="keyPreviewTextRatio">@fraction/key_preview_text_ratio</item>
|
<item name="keyPreviewTextRatio">@fraction/key_preview_text_ratio</item>
|
||||||
<item name="verticalCorrection">@dimen/keyboard_vertical_correction</item>
|
<item name="verticalCorrection">@dimen/keyboard_vertical_correction</item>
|
||||||
|
@ -67,7 +66,6 @@
|
||||||
<item name="gestureFloatingPreviewHorizontalPadding">@dimen/gesture_floating_preview_horizontal_padding</item>
|
<item name="gestureFloatingPreviewHorizontalPadding">@dimen/gesture_floating_preview_horizontal_padding</item>
|
||||||
<item name="gestureFloatingPreviewVerticalPadding">@dimen/gesture_floating_preview_vertical_padding</item>
|
<item name="gestureFloatingPreviewVerticalPadding">@dimen/gesture_floating_preview_vertical_padding</item>
|
||||||
<item name="gestureFloatingPreviewRoundRadius">@dimen/gesture_floating_preview_round_radius</item>
|
<item name="gestureFloatingPreviewRoundRadius">@dimen/gesture_floating_preview_round_radius</item>
|
||||||
<item name="gestureFloatingPreviewTextLingerTimeout">@integer/config_gesture_floating_preview_text_linger_timeout</item>
|
|
||||||
<item name="gesturePreviewTrailFadeoutStartDelay">@integer/config_gesture_preview_trail_fadeout_start_delay</item>
|
<item name="gesturePreviewTrailFadeoutStartDelay">@integer/config_gesture_preview_trail_fadeout_start_delay</item>
|
||||||
<item name="gesturePreviewTrailFadeoutDuration">@integer/config_gesture_preview_trail_fadeout_duration</item>
|
<item name="gesturePreviewTrailFadeoutDuration">@integer/config_gesture_preview_trail_fadeout_duration</item>
|
||||||
<item name="gesturePreviewTrailUpdateInterval">@integer/config_gesture_preview_trail_update_interval</item>
|
<item name="gesturePreviewTrailUpdateInterval">@integer/config_gesture_preview_trail_update_interval</item>
|
||||||
|
@ -85,6 +83,7 @@
|
||||||
<item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
|
<item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
|
||||||
<item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
|
<item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
|
||||||
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
|
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
|
||||||
|
<item name="keyPreviewLayout">@layout/key_preview</item>
|
||||||
<item name="keyPreviewOffset">@dimen/key_preview_offset</item>
|
<item name="keyPreviewOffset">@dimen/key_preview_offset</item>
|
||||||
<item name="keyPreviewHeight">@dimen/key_preview_height</item>
|
<item name="keyPreviewHeight">@dimen/key_preview_height</item>
|
||||||
<item name="keyPreviewLingerTimeout">@integer/config_key_preview_linger_timeout</item>
|
<item name="keyPreviewLingerTimeout">@integer/config_key_preview_linger_timeout</item>
|
||||||
|
@ -95,6 +94,7 @@
|
||||||
<item name="altCodeKeyWhileTypingFadeoutAnimator">@anim/alt_code_key_while_typing_fadeout</item>
|
<item name="altCodeKeyWhileTypingFadeoutAnimator">@anim/alt_code_key_while_typing_fadeout</item>
|
||||||
<item name="altCodeKeyWhileTypingFadeinAnimator">@anim/alt_code_key_while_typing_fadein</item>
|
<item name="altCodeKeyWhileTypingFadeinAnimator">@anim/alt_code_key_while_typing_fadein</item>
|
||||||
<!-- Common attributes of MainKeyboardView for gesture typing detection and recognition -->
|
<!-- Common attributes of MainKeyboardView for gesture typing detection and recognition -->
|
||||||
|
<item name="gestureFloatingPreviewTextLingerTimeout">@integer/config_gesture_floating_preview_text_linger_timeout</item>
|
||||||
<item name="gestureStaticTimeThresholdAfterFastTyping">@integer/config_gesture_static_time_threshold_after_fast_typing</item>
|
<item name="gestureStaticTimeThresholdAfterFastTyping">@integer/config_gesture_static_time_threshold_after_fast_typing</item>
|
||||||
<item name="gestureDetectFastMoveSpeedThreshold">@fraction/config_gesture_detect_fast_move_speed_threshold</item>
|
<item name="gestureDetectFastMoveSpeedThreshold">@fraction/config_gesture_detect_fast_move_speed_threshold</item>
|
||||||
<item name="gestureDynamicThresholdDecayDuration">@integer/config_gesture_dynamic_threshold_decay_duration</item>
|
<item name="gestureDynamicThresholdDecayDuration">@integer/config_gesture_dynamic_threshold_decay_duration</item>
|
||||||
|
|
|
@ -28,26 +28,16 @@ import android.graphics.Rect;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Message;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
|
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
|
import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
|
||||||
import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
|
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.CoordinateUtils;
|
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
|
||||||
|
@ -57,26 +47,12 @@ import java.util.HashSet;
|
||||||
* A view that renders a virtual {@link Keyboard}.
|
* A view that renders a virtual {@link Keyboard}.
|
||||||
*
|
*
|
||||||
* @attr ref R.styleable#KeyboardView_keyBackground
|
* @attr ref R.styleable#KeyboardView_keyBackground
|
||||||
* @attr ref R.styleable#KeyboardView_keyPreviewLayout
|
|
||||||
* @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding
|
* @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding
|
||||||
* @attr ref R.styleable#KeyboardView_keyHintLetterPadding
|
* @attr ref R.styleable#KeyboardView_keyHintLetterPadding
|
||||||
* @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
|
* @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
|
||||||
* @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding
|
* @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding
|
||||||
* @attr ref R.styleable#KeyboardView_keyTextShadowRadius
|
* @attr ref R.styleable#KeyboardView_keyTextShadowRadius
|
||||||
* @attr ref R.styleable#KeyboardView_backgroundDimAlpha
|
* @attr ref R.styleable#KeyboardView_backgroundDimAlpha
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextSize
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextColor
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextOffset
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewColor
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewHorizontalPadding
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewVerticalPadding
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewRoundRadius
|
|
||||||
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextLingerTimeout
|
|
||||||
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailFadeoutStartDelay
|
|
||||||
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailFadeoutDuration
|
|
||||||
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailUpdateInterval
|
|
||||||
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailColor
|
|
||||||
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailWidth
|
|
||||||
* @attr ref R.styleable#KeyboardView_verticalCorrection
|
* @attr ref R.styleable#KeyboardView_verticalCorrection
|
||||||
* @attr ref R.styleable#Keyboard_Key_keyTypeface
|
* @attr ref R.styleable#Keyboard_Key_keyTypeface
|
||||||
* @attr ref R.styleable#Keyboard_Key_keyLetterSize
|
* @attr ref R.styleable#Keyboard_Key_keyLetterSize
|
||||||
|
@ -97,8 +73,6 @@ import java.util.HashSet;
|
||||||
* @attr ref R.styleable#Keyboard_Key_keyPreviewTextColor
|
* @attr ref R.styleable#Keyboard_Key_keyPreviewTextColor
|
||||||
*/
|
*/
|
||||||
public class KeyboardView extends View {
|
public class KeyboardView extends View {
|
||||||
private static final String TAG = KeyboardView.class.getSimpleName();
|
|
||||||
|
|
||||||
// XML attributes
|
// XML attributes
|
||||||
protected final KeyVisualAttributes mKeyVisualAttributes;
|
protected final KeyVisualAttributes mKeyVisualAttributes;
|
||||||
private final int mKeyLabelHorizontalPadding;
|
private final int mKeyLabelHorizontalPadding;
|
||||||
|
@ -126,20 +100,6 @@ public class KeyboardView extends View {
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
protected final KeyDrawParams mKeyDrawParams = new KeyDrawParams();
|
protected final KeyDrawParams mKeyDrawParams = new KeyDrawParams();
|
||||||
|
|
||||||
// Preview placer view
|
|
||||||
// TODO: Move PreviewPlacerView to MainKeyboardView
|
|
||||||
protected final PreviewPlacerView mPreviewPlacerView;
|
|
||||||
private final int[] mOriginCoords = CoordinateUtils.newInstance();
|
|
||||||
|
|
||||||
// Key preview
|
|
||||||
// TODO: Move these variable to MainKeyboardView
|
|
||||||
protected final int mKeyPreviewLayoutId;
|
|
||||||
protected final SparseArray<TextView> mKeyPreviewTexts = CollectionUtils.newSparseArray();
|
|
||||||
|
|
||||||
// Gesture floating preview text
|
|
||||||
// TODO: Make this parameter customizable by user via settings.
|
|
||||||
private int mGestureFloatingPreviewTextLingerTimeout;
|
|
||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
/** True if the entire keyboard needs to be dimmed. */
|
/** True if the entire keyboard needs to be dimmed. */
|
||||||
private boolean mNeedsToDimEntireKeyboard;
|
private boolean mNeedsToDimEntireKeyboard;
|
||||||
|
@ -164,56 +124,6 @@ public class KeyboardView extends View {
|
||||||
private static final char[] KEY_LABEL_REFERENCE_CHAR = { 'M' };
|
private static final char[] KEY_LABEL_REFERENCE_CHAR = { 'M' };
|
||||||
private static final char[] KEY_NUMERIC_HINT_LABEL_REFERENCE_CHAR = { '8' };
|
private static final char[] KEY_NUMERIC_HINT_LABEL_REFERENCE_CHAR = { '8' };
|
||||||
|
|
||||||
// TODO: Move this to MainKeyboardView
|
|
||||||
protected final DrawingHandler mDrawingHandler = new DrawingHandler(this);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(final Message msg) {
|
|
||||||
final KeyboardView keyboardView = getOuterInstance();
|
|
||||||
if (keyboardView == null) return;
|
|
||||||
final PointerTracker tracker = (PointerTracker) msg.obj;
|
|
||||||
switch (msg.what) {
|
|
||||||
case MSG_DISMISS_KEY_PREVIEW:
|
|
||||||
final TextView previewText = keyboardView.mKeyPreviewTexts.get(tracker.mPointerId);
|
|
||||||
if (previewText != null) {
|
|
||||||
previewText.setVisibility(INVISIBLE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT:
|
|
||||||
keyboardView.mPreviewPlacerView.setGestureFloatingPreviewText(SuggestedWords.EMPTY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dismissKeyPreview(final long delay, final PointerTracker tracker) {
|
|
||||||
sendMessageDelayed(obtainMessage(MSG_DISMISS_KEY_PREVIEW, tracker), delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancelDismissKeyPreview(final PointerTracker tracker) {
|
|
||||||
removeMessages(MSG_DISMISS_KEY_PREVIEW, tracker);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cancelAllDismissKeyPreviews() {
|
|
||||||
removeMessages(MSG_DISMISS_KEY_PREVIEW);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dismissGestureFloatingPreviewText(final long delay) {
|
|
||||||
sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancelAllMessages() {
|
|
||||||
cancelAllDismissKeyPreviews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyboardView(final Context context, final AttributeSet attrs) {
|
public KeyboardView(final Context context, final AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.keyboardViewStyle);
|
this(context, attrs, R.attr.keyboardViewStyle);
|
||||||
}
|
}
|
||||||
|
@ -235,14 +145,10 @@ public class KeyboardView extends View {
|
||||||
R.styleable.KeyboardView_keyShiftedLetterHintPadding, 0);
|
R.styleable.KeyboardView_keyShiftedLetterHintPadding, 0);
|
||||||
mKeyTextShadowRadius = keyboardViewAttr.getFloat(
|
mKeyTextShadowRadius = keyboardViewAttr.getFloat(
|
||||||
R.styleable.KeyboardView_keyTextShadowRadius, 0.0f);
|
R.styleable.KeyboardView_keyTextShadowRadius, 0.0f);
|
||||||
mKeyPreviewLayoutId = keyboardViewAttr.getResourceId(
|
|
||||||
R.styleable.KeyboardView_keyPreviewLayout, 0);
|
|
||||||
mVerticalCorrection = keyboardViewAttr.getDimension(
|
mVerticalCorrection = keyboardViewAttr.getDimension(
|
||||||
R.styleable.KeyboardView_verticalCorrection, 0);
|
R.styleable.KeyboardView_verticalCorrection, 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,
|
||||||
|
@ -250,7 +156,6 @@ public class KeyboardView extends View {
|
||||||
mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);
|
mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);
|
||||||
keyAttr.recycle();
|
keyAttr.recycle();
|
||||||
|
|
||||||
mPreviewPlacerView = new PreviewPlacerView(context, attrs);
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,13 +191,6 @@ public class KeyboardView extends View {
|
||||||
return mKeyboard;
|
return mKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this method to MainKeyboardView
|
|
||||||
public void setGesturePreviewMode(final boolean drawsGesturePreviewTrail,
|
|
||||||
final boolean drawsGestureFloatingPreviewText) {
|
|
||||||
mPreviewPlacerView.setGesturePreviewMode(
|
|
||||||
drawsGesturePreviewTrail, drawsGestureFloatingPreviewText);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||||
if (mKeyboard != null) {
|
if (mKeyboard != null) {
|
||||||
|
@ -733,94 +631,6 @@ public class KeyboardView extends View {
|
||||||
return paint;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelAllMessages() {
|
|
||||||
mDrawingHandler.cancelAllMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move this method to MainKeyboardView.
|
|
||||||
protected TextView getKeyPreviewText(final int pointerId) {
|
|
||||||
TextView previewText = mKeyPreviewTexts.get(pointerId);
|
|
||||||
if (previewText != null) {
|
|
||||||
return previewText;
|
|
||||||
}
|
|
||||||
final Context context = getContext();
|
|
||||||
if (mKeyPreviewLayoutId != 0) {
|
|
||||||
previewText = (TextView)LayoutInflater.from(context).inflate(mKeyPreviewLayoutId, null);
|
|
||||||
} else {
|
|
||||||
previewText = new TextView(context);
|
|
||||||
}
|
|
||||||
mKeyPreviewTexts.put(pointerId, previewText);
|
|
||||||
return previewText;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move this method to MainKeyboardView.
|
|
||||||
private void dismissAllKeyPreviews() {
|
|
||||||
final int pointerCount = mKeyPreviewTexts.size();
|
|
||||||
for (int id = 0; id < pointerCount; id++) {
|
|
||||||
final TextView previewText = mKeyPreviewTexts.get(id);
|
|
||||||
if (previewText != null) {
|
|
||||||
previewText.setVisibility(INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PointerTracker.setReleasedKeyGraphicsToAllKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move this to MainKeyboardView
|
|
||||||
protected void addKeyPreview(final TextView keyPreview) {
|
|
||||||
locatePreviewPlacerView();
|
|
||||||
mPreviewPlacerView.addView(
|
|
||||||
keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacerView, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move this to MainKeyboardView
|
|
||||||
protected void locatePreviewPlacerView() {
|
|
||||||
if (mPreviewPlacerView.getParent() != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int width = getWidth();
|
|
||||||
final int height = getHeight();
|
|
||||||
if (width == 0 || height == 0) {
|
|
||||||
// In transient state.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getLocationInWindow(mOriginCoords);
|
|
||||||
final DisplayMetrics dm = getResources().getDisplayMetrics();
|
|
||||||
if (CoordinateUtils.y(mOriginCoords) < dm.heightPixels / 4) {
|
|
||||||
// In transient state.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final View rootView = getRootView();
|
|
||||||
if (rootView == null) {
|
|
||||||
Log.w(TAG, "Cannot find root view");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final ViewGroup windowContentView = (ViewGroup)rootView.findViewById(android.R.id.content);
|
|
||||||
// Note: It'd be very weird if we get null by android.R.id.content.
|
|
||||||
if (windowContentView == null) {
|
|
||||||
Log.w(TAG, "Cannot find android.R.id.content view to add PreviewPlacerView");
|
|
||||||
} else {
|
|
||||||
windowContentView.addView(mPreviewPlacerView);
|
|
||||||
mPreviewPlacerView.setKeyboardViewGeometry(mOriginCoords, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showGestureFloatingPreviewText(final SuggestedWords suggestedWords) {
|
|
||||||
locatePreviewPlacerView();
|
|
||||||
mPreviewPlacerView.setGestureFloatingPreviewText(suggestedWords);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dismissGestureFloatingPreviewText() {
|
|
||||||
locatePreviewPlacerView();
|
|
||||||
mDrawingHandler.dismissGestureFloatingPreviewText(mGestureFloatingPreviewTextLingerTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move This to MainKeyboardView
|
|
||||||
public void showGesturePreviewTrail(final PointerTracker tracker,
|
|
||||||
final boolean isOldestTracker) {
|
|
||||||
locatePreviewPlacerView();
|
|
||||||
mPreviewPlacerView.invalidatePointer(tracker, isOldestTracker);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests a redraw of the entire keyboard. Calling {@link #invalidate} is not sufficient
|
* Requests a redraw of the entire keyboard. Calling {@link #invalidate} is not sufficient
|
||||||
* because the keyboard renders the keys to an off-screen buffer and an invalidate() only
|
* because the keyboard renders the keys to an off-screen buffer and an invalidate() only
|
||||||
|
@ -850,8 +660,6 @@ public class KeyboardView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closing() {
|
public void closing() {
|
||||||
dismissAllKeyPreviews();
|
|
||||||
cancelAllMessages();
|
|
||||||
mInvalidateAllKeys = true;
|
mInvalidateAllKeys = true;
|
||||||
mKeyboard = null;
|
mKeyboard = null;
|
||||||
requestLayout();
|
requestLayout();
|
||||||
|
@ -861,7 +669,6 @@ public class KeyboardView extends View {
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
closing();
|
closing();
|
||||||
mPreviewPlacerView.removeAllViews();
|
|
||||||
freeOffscreenBuffer();
|
freeOffscreenBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,9 @@ import android.os.Message;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -49,7 +51,9 @@ import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
|
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
|
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
|
||||||
|
import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
|
||||||
import com.android.inputmethod.keyboard.internal.TouchScreenRegulator;
|
import com.android.inputmethod.keyboard.internal.TouchScreenRegulator;
|
||||||
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.CoordinateUtils;
|
import com.android.inputmethod.latin.CoordinateUtils;
|
||||||
import com.android.inputmethod.latin.DebugSettings;
|
import com.android.inputmethod.latin.DebugSettings;
|
||||||
|
@ -60,6 +64,7 @@ import com.android.inputmethod.latin.ResourceUtils;
|
||||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||||
import com.android.inputmethod.latin.StringUtils;
|
import com.android.inputmethod.latin.StringUtils;
|
||||||
import com.android.inputmethod.latin.SubtypeLocale;
|
import com.android.inputmethod.latin.SubtypeLocale;
|
||||||
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
|
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
@ -88,11 +93,13 @@ import java.util.WeakHashMap;
|
||||||
* @attr ref R.styleable#MainKeyboardView_longPressKeyTimeout
|
* @attr ref R.styleable#MainKeyboardView_longPressKeyTimeout
|
||||||
* @attr ref R.styleable#MainKeyboardView_longPressShiftKeyTimeout
|
* @attr ref R.styleable#MainKeyboardView_longPressShiftKeyTimeout
|
||||||
* @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout
|
* @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout
|
||||||
|
* @attr ref R.styleable#MainKeyboardView_keyPreviewLayout
|
||||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewOffset
|
* @attr ref R.styleable#MainKeyboardView_keyPreviewOffset
|
||||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
|
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
|
||||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewLingerTimeout
|
* @attr ref R.styleable#MainKeyboardView_keyPreviewLingerTimeout
|
||||||
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
|
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
|
||||||
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
|
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
|
||||||
|
* @attr ref R.styleable#MainKeyboardView_gestureFloatingPreviewTextLingerTimeout
|
||||||
* @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping
|
* @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping
|
||||||
* @attr ref R.styleable#MainKeyboardView_gestureDetectFastMoveSpeedThreshold
|
* @attr ref R.styleable#MainKeyboardView_gestureDetectFastMoveSpeedThreshold
|
||||||
* @attr ref R.styleable#MainKeyboardView_gestureDynamicThresholdDecayDuration
|
* @attr ref R.styleable#MainKeyboardView_gestureDynamicThresholdDecayDuration
|
||||||
|
@ -142,14 +149,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
private ObjectAnimator mAltCodeKeyWhileTypingFadeinAnimator;
|
private ObjectAnimator mAltCodeKeyWhileTypingFadeinAnimator;
|
||||||
private int mAltCodeKeyWhileTypingAnimAlpha = Constants.Color.ALPHA_OPAQUE;
|
private int mAltCodeKeyWhileTypingAnimAlpha = Constants.Color.ALPHA_OPAQUE;
|
||||||
|
|
||||||
|
// Preview placer view
|
||||||
|
private final PreviewPlacerView mPreviewPlacerView;
|
||||||
|
private final int[] mOriginCoords = CoordinateUtils.newInstance();
|
||||||
|
|
||||||
// Key preview
|
// Key preview
|
||||||
private static final int PREVIEW_ALPHA = 240;
|
private static final int PREVIEW_ALPHA = 240;
|
||||||
|
private final int mKeyPreviewLayoutId;
|
||||||
private final int mKeyPreviewOffset;
|
private final int mKeyPreviewOffset;
|
||||||
private final int mKeyPreviewHeight;
|
private final int mKeyPreviewHeight;
|
||||||
|
private final SparseArray<TextView> mKeyPreviewTexts = CollectionUtils.newSparseArray();
|
||||||
private final KeyPreviewDrawParams mKeyPreviewDrawParams = new KeyPreviewDrawParams();
|
private final KeyPreviewDrawParams mKeyPreviewDrawParams = new KeyPreviewDrawParams();
|
||||||
private boolean mShowKeyPreviewPopup = true;
|
private boolean mShowKeyPreviewPopup = true;
|
||||||
private int mKeyPreviewLingerTimeout;
|
private int mKeyPreviewLingerTimeout;
|
||||||
private final int[] mOriginCoords = CoordinateUtils.newInstance();
|
|
||||||
|
|
||||||
// More keys keyboard
|
// More keys keyboard
|
||||||
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
|
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
|
||||||
|
@ -160,6 +172,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
// TODO: Consider extending to support multiple more keys panels
|
// TODO: Consider extending to support multiple more keys panels
|
||||||
private MoreKeysPanel mMoreKeysPanel;
|
private MoreKeysPanel mMoreKeysPanel;
|
||||||
|
|
||||||
|
// Gesture floating preview text
|
||||||
|
// TODO: Make this parameter customizable by user via settings.
|
||||||
|
private int mGestureFloatingPreviewTextLingerTimeout;
|
||||||
|
|
||||||
private final TouchScreenRegulator mTouchScreenRegulator;
|
private final TouchScreenRegulator mTouchScreenRegulator;
|
||||||
|
|
||||||
private KeyDetector mKeyDetector;
|
private KeyDetector mKeyDetector;
|
||||||
|
@ -402,6 +418,57 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final DrawingHandler mDrawingHandler = new DrawingHandler(this);
|
||||||
|
|
||||||
|
public static class DrawingHandler extends StaticInnerHandlerWrapper<MainKeyboardView> {
|
||||||
|
private static final int MSG_DISMISS_KEY_PREVIEW = 0;
|
||||||
|
private static final int MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 1;
|
||||||
|
|
||||||
|
public DrawingHandler(final MainKeyboardView outerInstance) {
|
||||||
|
super(outerInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(final Message msg) {
|
||||||
|
final MainKeyboardView mainKeyboardView = getOuterInstance();
|
||||||
|
if (mainKeyboardView == null) return;
|
||||||
|
final PointerTracker tracker = (PointerTracker) msg.obj;
|
||||||
|
switch (msg.what) {
|
||||||
|
case MSG_DISMISS_KEY_PREVIEW:
|
||||||
|
final TextView previewText = mainKeyboardView.mKeyPreviewTexts.get(
|
||||||
|
tracker.mPointerId);
|
||||||
|
if (previewText != null) {
|
||||||
|
previewText.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT:
|
||||||
|
mainKeyboardView.mPreviewPlacerView.setGestureFloatingPreviewText(
|
||||||
|
SuggestedWords.EMPTY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismissKeyPreview(final long delay, final PointerTracker tracker) {
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_DISMISS_KEY_PREVIEW, tracker), delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelDismissKeyPreview(final PointerTracker tracker) {
|
||||||
|
removeMessages(MSG_DISMISS_KEY_PREVIEW, tracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelAllDismissKeyPreviews() {
|
||||||
|
removeMessages(MSG_DISMISS_KEY_PREVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismissGestureFloatingPreviewText(final long delay) {
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT), delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelAllMessages() {
|
||||||
|
cancelAllDismissKeyPreviews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MainKeyboardView(final Context context, final AttributeSet attrs) {
|
public MainKeyboardView(final Context context, final AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.mainKeyboardViewStyle);
|
this(context, attrs, R.attr.mainKeyboardViewStyle);
|
||||||
}
|
}
|
||||||
|
@ -458,6 +525,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
R.styleable.MainKeyboardView_keyPreviewHeight, 0);
|
R.styleable.MainKeyboardView_keyPreviewHeight, 0);
|
||||||
mKeyPreviewLingerTimeout = mainKeyboardViewAttr.getInt(
|
mKeyPreviewLingerTimeout = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
|
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
|
||||||
|
mKeyPreviewLayoutId = mainKeyboardViewAttr.getResourceId(
|
||||||
|
R.styleable.MainKeyboardView_keyPreviewLayout, 0);
|
||||||
if (mKeyPreviewLayoutId == 0) {
|
if (mKeyPreviewLayoutId == 0) {
|
||||||
mShowKeyPreviewPopup = false;
|
mShowKeyPreviewPopup = false;
|
||||||
}
|
}
|
||||||
|
@ -465,6 +534,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
|
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
|
||||||
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
|
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
|
||||||
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
||||||
|
|
||||||
|
mGestureFloatingPreviewTextLingerTimeout = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_gestureFloatingPreviewTextLingerTimeout, 0);
|
||||||
PointerTracker.setParameters(mainKeyboardViewAttr);
|
PointerTracker.setParameters(mainKeyboardViewAttr);
|
||||||
mainKeyboardViewAttr.recycle();
|
mainKeyboardViewAttr.recycle();
|
||||||
|
|
||||||
|
@ -474,6 +546,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
altCodeKeyWhileTypingFadeoutAnimatorResId, this);
|
altCodeKeyWhileTypingFadeoutAnimatorResId, this);
|
||||||
mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator(
|
mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator(
|
||||||
altCodeKeyWhileTypingFadeinAnimatorResId, this);
|
altCodeKeyWhileTypingFadeinAnimatorResId, this);
|
||||||
|
|
||||||
|
mPreviewPlacerView = new PreviewPlacerView(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
|
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
|
||||||
|
@ -583,6 +657,38 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mKeyPreviewLingerTimeout = delay;
|
mKeyPreviewLingerTimeout = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void locatePreviewPlacerView() {
|
||||||
|
if (mPreviewPlacerView.getParent() != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int width = getWidth();
|
||||||
|
final int height = getHeight();
|
||||||
|
if (width == 0 || height == 0) {
|
||||||
|
// In transient state.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getLocationInWindow(mOriginCoords);
|
||||||
|
final DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||||
|
if (CoordinateUtils.y(mOriginCoords) < dm.heightPixels / 4) {
|
||||||
|
// In transient state.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final View rootView = getRootView();
|
||||||
|
if (rootView == null) {
|
||||||
|
Log.w(TAG, "Cannot find root view");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ViewGroup windowContentView = (ViewGroup)rootView.findViewById(android.R.id.content);
|
||||||
|
// Note: It'd be very weird if we get null by android.R.id.content.
|
||||||
|
if (windowContentView == null) {
|
||||||
|
Log.w(TAG, "Cannot find android.R.id.content view to add PreviewPlacerView");
|
||||||
|
} else {
|
||||||
|
windowContentView.addView(mPreviewPlacerView);
|
||||||
|
mPreviewPlacerView.setKeyboardViewGeometry(mOriginCoords, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the enabled state of the key feedback preview
|
* Returns the enabled state of the key feedback preview
|
||||||
* @return whether or not the key feedback preview is enabled
|
* @return whether or not the key feedback preview is enabled
|
||||||
|
@ -592,6 +698,38 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
return mShowKeyPreviewPopup;
|
return mShowKeyPreviewPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addKeyPreview(final TextView keyPreview) {
|
||||||
|
locatePreviewPlacerView();
|
||||||
|
mPreviewPlacerView.addView(
|
||||||
|
keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacerView, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextView getKeyPreviewText(final int pointerId) {
|
||||||
|
TextView previewText = mKeyPreviewTexts.get(pointerId);
|
||||||
|
if (previewText != null) {
|
||||||
|
return previewText;
|
||||||
|
}
|
||||||
|
final Context context = getContext();
|
||||||
|
if (mKeyPreviewLayoutId != 0) {
|
||||||
|
previewText = (TextView)LayoutInflater.from(context).inflate(mKeyPreviewLayoutId, null);
|
||||||
|
} else {
|
||||||
|
previewText = new TextView(context);
|
||||||
|
}
|
||||||
|
mKeyPreviewTexts.put(pointerId, previewText);
|
||||||
|
return previewText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dismissAllKeyPreviews() {
|
||||||
|
final int pointerCount = mKeyPreviewTexts.size();
|
||||||
|
for (int id = 0; id < pointerCount; id++) {
|
||||||
|
final TextView previewText = mKeyPreviewTexts.get(id);
|
||||||
|
if (previewText != null) {
|
||||||
|
previewText.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PointerTracker.setReleasedKeyGraphicsToAllKeys();
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -726,6 +864,28 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mPreviewPlacerView.dismissSlidingKeyInputPreview();
|
mPreviewPlacerView.dismissSlidingKeyInputPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGesturePreviewMode(final boolean drawsGesturePreviewTrail,
|
||||||
|
final boolean drawsGestureFloatingPreviewText) {
|
||||||
|
mPreviewPlacerView.setGesturePreviewMode(
|
||||||
|
drawsGesturePreviewTrail, drawsGestureFloatingPreviewText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showGestureFloatingPreviewText(final SuggestedWords suggestedWords) {
|
||||||
|
locatePreviewPlacerView();
|
||||||
|
mPreviewPlacerView.setGestureFloatingPreviewText(suggestedWords);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismissGestureFloatingPreviewText() {
|
||||||
|
locatePreviewPlacerView();
|
||||||
|
mDrawingHandler.dismissGestureFloatingPreviewText(mGestureFloatingPreviewTextLingerTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showGesturePreviewTrail(final PointerTracker tracker,
|
||||||
|
final boolean isOldestTracker) {
|
||||||
|
locatePreviewPlacerView();
|
||||||
|
mPreviewPlacerView.invalidatePointer(tracker, isOldestTracker);
|
||||||
|
}
|
||||||
|
|
||||||
// Note that this method is called from a non-UI thread.
|
// Note that this method is called from a non-UI thread.
|
||||||
public void setMainDictionaryAvailability(final boolean mainDictionaryAvailable) {
|
public void setMainDictionaryAvailability(final boolean mainDictionaryAvailable) {
|
||||||
PointerTracker.setMainDictionaryAvailability(mainDictionaryAvailable);
|
PointerTracker.setMainDictionaryAvailability(mainDictionaryAvailable);
|
||||||
|
@ -749,6 +909,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
|
mPreviewPlacerView.removeAllViews();
|
||||||
// Notify the research logger that the keyboard view has been detached. This is needed
|
// Notify the research logger that the keyboard view has been detached. This is needed
|
||||||
// to invalidate the reference of {@link MainKeyboardView} to null.
|
// to invalidate the reference of {@link MainKeyboardView} to null.
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
|
@ -756,12 +917,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelAllMessages() {
|
|
||||||
mKeyTimerHandler.cancelAllMessages();
|
|
||||||
super.cancelAllMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean openMoreKeysKeyboardIfRequired(final Key parentKey,
|
private boolean openMoreKeysKeyboardIfRequired(final Key parentKey,
|
||||||
final PointerTracker tracker) {
|
final PointerTracker tracker) {
|
||||||
// Check if we have a popup layout specified first.
|
// Check if we have a popup layout specified first.
|
||||||
|
@ -1065,8 +1220,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
eventTag + eventTime + "," + id + "," + x + "," + y + "," + size + "," + pressure);
|
eventTag + eventTime + "," + id + "," + x + "," + y + "," + size + "," + pressure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancelAllMessages() {
|
||||||
|
mKeyTimerHandler.cancelAllMessages();
|
||||||
|
mDrawingHandler.cancelAllMessages();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closing() {
|
public void closing() {
|
||||||
|
dismissAllKeyPreviews();
|
||||||
|
cancelAllMessages();
|
||||||
super.closing();
|
super.closing();
|
||||||
onCancelMoreKeysPanel();
|
onCancelMoreKeysPanel();
|
||||||
mMoreKeysPanelCache.clear();
|
mMoreKeysPanelCache.clear();
|
||||||
|
|
|
@ -34,6 +34,14 @@ import com.android.inputmethod.latin.SuggestedWords;
|
||||||
/**
|
/**
|
||||||
* The class for single gesture preview text. The class for multiple gesture preview text will be
|
* The class for single gesture preview text. The class for multiple gesture preview text will be
|
||||||
* derived from it.
|
* derived from it.
|
||||||
|
*
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextSize
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextColor
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewTextOffset
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewColor
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewHorizontalPadding
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewVerticalPadding
|
||||||
|
* @attr ref R.styleable#KeyboardView_gestureFloatingPreviewRoundRadius
|
||||||
*/
|
*/
|
||||||
public class GestureFloatingPreviewText extends AbstractDrawingPreview {
|
public class GestureFloatingPreviewText extends AbstractDrawingPreview {
|
||||||
private static final class GesturePreviewTextParams {
|
private static final class GesturePreviewTextParams {
|
||||||
|
@ -50,6 +58,7 @@ public class GestureFloatingPreviewText extends AbstractDrawingPreview {
|
||||||
private static final char[] TEXT_HEIGHT_REFERENCE_CHAR = { 'M' };
|
private static final char[] TEXT_HEIGHT_REFERENCE_CHAR = { 'M' };
|
||||||
|
|
||||||
public GesturePreviewTextParams(final TypedArray keyboardViewAttr) {
|
public GesturePreviewTextParams(final TypedArray keyboardViewAttr) {
|
||||||
|
// TODO: Move these XML attributes to MainKeyboardView
|
||||||
mGesturePreviewTextSize = keyboardViewAttr.getDimensionPixelSize(
|
mGesturePreviewTextSize = keyboardViewAttr.getDimensionPixelSize(
|
||||||
R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0);
|
R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0);
|
||||||
mGesturePreviewTextColor = keyboardViewAttr.getColor(
|
mGesturePreviewTextColor = keyboardViewAttr.getColor(
|
||||||
|
|
|
@ -25,6 +25,13 @@ import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.ResizableIntArray;
|
import com.android.inputmethod.latin.ResizableIntArray;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailFadeoutStartDelay
|
||||||
|
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailFadeoutDuration
|
||||||
|
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailUpdateInterval
|
||||||
|
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailColor
|
||||||
|
* @attr ref R.styleable#KeyboardView_gesturePreviewTrailWidth
|
||||||
|
*/
|
||||||
final class GesturePreviewTrail {
|
final class GesturePreviewTrail {
|
||||||
private static final int DEFAULT_CAPACITY = GestureStrokeWithPreviewPoints.PREVIEW_CAPACITY;
|
private static final int DEFAULT_CAPACITY = GestureStrokeWithPreviewPoints.PREVIEW_CAPACITY;
|
||||||
|
|
||||||
|
@ -47,6 +54,7 @@ final class GesturePreviewTrail {
|
||||||
public final int mTrailLingerDuration;
|
public final int mTrailLingerDuration;
|
||||||
|
|
||||||
public Params(final TypedArray keyboardViewAttr) {
|
public Params(final TypedArray keyboardViewAttr) {
|
||||||
|
// TODO: Move these XML attributes to MainKeyboardView
|
||||||
mTrailColor = keyboardViewAttr.getColor(
|
mTrailColor = keyboardViewAttr.getColor(
|
||||||
R.styleable.KeyboardView_gesturePreviewTrailColor, 0);
|
R.styleable.KeyboardView_gesturePreviewTrailColor, 0);
|
||||||
mTrailStartWidth = keyboardViewAttr.getDimension(
|
mTrailStartWidth = keyboardViewAttr.getDimension(
|
||||||
|
|
|
@ -1617,7 +1617,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
|
private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
|
||||||
final boolean dismissGestureFloatingPreviewText) {
|
final boolean dismissGestureFloatingPreviewText) {
|
||||||
showSuggestionStrip(suggestedWords, null);
|
showSuggestionStrip(suggestedWords, null);
|
||||||
final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
||||||
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
|
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
|
||||||
if (dismissGestureFloatingPreviewText) {
|
if (dismissGestureFloatingPreviewText) {
|
||||||
mainKeyboardView.dismissGestureFloatingPreviewText();
|
mainKeyboardView.dismissGestureFloatingPreviewText();
|
||||||
|
|
Loading…
Reference in New Issue