am cb3bba3c: Rename GesturePreviewTrail.java -> GestureTrail.java
* commit 'cb3bba3c4ee4652e12c81185ab9a648db20bb0dd': Rename GesturePreviewTrail.java -> GestureTrail.javamain
commit
01c133d72e
|
@ -85,8 +85,8 @@
|
|||
<dimen name="suggestion_text_size">22dp</dimen>
|
||||
<dimen name="more_suggestions_hint_text_size">33dp</dimen>
|
||||
|
||||
<!-- Gesture preview trail parameters -->
|
||||
<dimen name="gesture_preview_trail_width">2.5dp</dimen>
|
||||
<!-- Gesture trail parameters -->
|
||||
<dimen name="gesture_trail_width">2.5dp</dimen>
|
||||
<!-- Gesture floating preview text parameters -->
|
||||
<dimen name="gesture_floating_preview_text_size">28dp</dimen>
|
||||
<dimen name="gesture_floating_preview_text_offset">87dp</dimen>
|
||||
|
|
|
@ -86,8 +86,8 @@
|
|||
<dimen name="suggestion_text_size">22dp</dimen>
|
||||
<dimen name="more_suggestions_hint_text_size">33dp</dimen>
|
||||
|
||||
<!-- Gesture preview trail parameters -->
|
||||
<dimen name="gesture_preview_trail_width">2.5dp</dimen>
|
||||
<!-- Gesture trail parameters -->
|
||||
<dimen name="gesture_trail_width">2.5dp</dimen>
|
||||
<!-- Gesture floating preview text parameters -->
|
||||
<dimen name="gesture_floating_preview_text_size">26dp</dimen>
|
||||
<dimen name="gesture_floating_preview_text_offset">86dp</dimen>
|
||||
|
|
|
@ -108,25 +108,25 @@
|
|||
<attr name="backgroundDimAlpha" format="integer" />
|
||||
<!-- More keys keyboard will shown at touched point. -->
|
||||
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
||||
<!-- Minimum distance between gesture preview trail sampling points. -->
|
||||
<attr name="gesturePreviewTrailMinSamplingDistance" format="dimension" />
|
||||
<!-- Maximum angular threshold between gesture preview trail interpolation segments in degree. -->
|
||||
<attr name="gesturePreviewTrailMaxInterpolationAngularThreshold" format="integer" />
|
||||
<!-- Maximum distance threshold between gesture preview trail interpolation segments. -->
|
||||
<attr name="gesturePreviewTrailMaxInterpolationDistanceThreshold" format="dimension" />
|
||||
<!-- Maximum number of gesture preview trail interpolation segments. -->
|
||||
<attr name="gesturePreviewTrailMaxInterpolationSegments" format="integer" />
|
||||
<!-- Minimum distance between gesture trail sampling points. -->
|
||||
<attr name="gestureTrailMinSamplingDistance" format="dimension" />
|
||||
<!-- Maximum angular threshold between gesture trail interpolation segments in degree. -->
|
||||
<attr name="gestureTrailMaxInterpolationAngularThreshold" format="integer" />
|
||||
<!-- Maximum distance threshold between gesture trail interpolation segments. -->
|
||||
<attr name="gestureTrailMaxInterpolationDistanceThreshold" format="dimension" />
|
||||
<!-- Maximum number of gesture trail interpolation segments. -->
|
||||
<attr name="gestureTrailMaxInterpolationSegments" format="integer" />
|
||||
<!-- Delay after gesture trail starts fading out in millisecond. -->
|
||||
<attr name="gesturePreviewTrailFadeoutStartDelay" format="integer" />
|
||||
<!-- Duration while gesture preview trail is fading out in millisecond. -->
|
||||
<attr name="gesturePreviewTrailFadeoutDuration" format="integer" />
|
||||
<!-- Interval of updating gesture preview trail in millisecond. -->
|
||||
<attr name="gesturePreviewTrailUpdateInterval" format="integer" />
|
||||
<attr name="gesturePreviewTrailColor" format="color" />
|
||||
<attr name="gesturePreviewTrailStartWidth" format="dimension" />
|
||||
<attr name="gesturePreviewTrailEndWidth" format="dimension" />
|
||||
<attr name="gesturePreviewTrailBodyRatio" format="integer" />
|
||||
<attr name="gesturePreviewTrailShadowRatio" format="integer" />
|
||||
<attr name="gestureTrailFadeoutStartDelay" format="integer" />
|
||||
<!-- Duration while gesture trail is fading out in millisecond. -->
|
||||
<attr name="gestureTrailFadeoutDuration" format="integer" />
|
||||
<!-- Interval of updating gesture trail in millisecond. -->
|
||||
<attr name="gestureTrailUpdateInterval" format="integer" />
|
||||
<attr name="gestureTrailColor" format="color" />
|
||||
<attr name="gestureTrailStartWidth" format="dimension" />
|
||||
<attr name="gestureTrailEndWidth" format="dimension" />
|
||||
<attr name="gestureTrailBodyRatio" format="integer" />
|
||||
<attr name="gestureTrailShadowRatio" format="integer" />
|
||||
<!-- Delay after gesture input and gesture floating preview text dismissing in millisecond -->
|
||||
<attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" />
|
||||
<!-- Attributes for GestureFloatingPreviewText -->
|
||||
|
|
|
@ -75,9 +75,9 @@
|
|||
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
||||
<bool name="config_block_potentially_offensive">true</bool>
|
||||
<integer name="config_gesture_floating_preview_text_linger_timeout">200</integer>
|
||||
<integer name="config_gesture_preview_trail_fadeout_start_delay">100</integer>
|
||||
<integer name="config_gesture_preview_trail_fadeout_duration">800</integer>
|
||||
<integer name="config_gesture_preview_trail_update_interval">20</integer>
|
||||
<integer name="config_gesture_trail_fadeout_start_delay">100</integer>
|
||||
<integer name="config_gesture_trail_fadeout_duration">800</integer>
|
||||
<integer name="config_gesture_trail_update_interval">20</integer>
|
||||
<!-- Static threshold for gesture after fast typing (msec) -->
|
||||
<integer name="config_gesture_static_time_threshold_after_fast_typing">500</integer>
|
||||
<!-- Static threshold for starting gesture detection (keyWidth%/sec) -->
|
||||
|
|
|
@ -100,22 +100,22 @@
|
|||
<integer name="suggestions_count_in_strip">3</integer>
|
||||
<fraction name="center_suggestion_percentile">36%</fraction>
|
||||
|
||||
<!-- Gesture preview trail parameters -->
|
||||
<!-- Minimum distance between gesture preview trail sampling points. -->
|
||||
<dimen name="gesture_preview_trail_min_sampling_distance">6.4dp</dimen>
|
||||
<!-- Maximum angular threshold between gesture preview trails interpolation segments in degree. -->
|
||||
<integer name="gesture_preview_trail_max_interpolation_angular_threshold">15</integer>
|
||||
<!-- Maximum distance threshold between gesture preview trails interpolation segments. -->
|
||||
<dimen name="gesture_preview_trail_max_interpolation_distance_threshold">16.0dp</dimen>
|
||||
<!-- Maximum number of gesture preview trail interpolation segments. -->
|
||||
<integer name="gesture_preview_trail_max_interpolation_segments">6</integer>
|
||||
<dimen name="gesture_preview_trail_start_width">10.0dp</dimen>
|
||||
<dimen name="gesture_preview_trail_end_width">2.5dp</dimen>
|
||||
<!-- Gesture trail parameters -->
|
||||
<!-- Minimum distance between gesture trail sampling points. -->
|
||||
<dimen name="gesture_trail_min_sampling_distance">6.4dp</dimen>
|
||||
<!-- Maximum angular threshold between gesture trails interpolation segments in degree. -->
|
||||
<integer name="gesture_trail_max_interpolation_angular_threshold">15</integer>
|
||||
<!-- Maximum distance threshold between gesture trails interpolation segments. -->
|
||||
<dimen name="gesture_trail_max_interpolation_distance_threshold">16.0dp</dimen>
|
||||
<!-- Maximum number of gesture trail interpolation segments. -->
|
||||
<integer name="gesture_trail_max_interpolation_segments">6</integer>
|
||||
<dimen name="gesture_trail_start_width">10.0dp</dimen>
|
||||
<dimen name="gesture_trail_end_width">2.5dp</dimen>
|
||||
<!-- Percentages of gesture preview taril body and shadow, in proportion to the trail width.
|
||||
A negative value of the shadow ratio disables drawing shadow. -->
|
||||
<!-- TODO: May use the shadow to alleviate rugged trail drawing. -->
|
||||
<integer name="gesture_preview_trail_body_ratio">100</integer>
|
||||
<integer name="gesture_preview_trail_shadow_ratio">-1</integer>
|
||||
<integer name="gesture_trail_body_ratio">100</integer>
|
||||
<integer name="gesture_trail_shadow_ratio">-1</integer>
|
||||
<!-- Gesture floating preview text parameters -->
|
||||
<dimen name="gesture_floating_preview_text_size">24dp</dimen>
|
||||
<dimen name="gesture_floating_preview_text_offset">73dp</dimen>
|
||||
|
|
|
@ -64,18 +64,18 @@
|
|||
<item name="gestureFloatingPreviewHorizontalPadding">@dimen/gesture_floating_preview_horizontal_padding</item>
|
||||
<item name="gestureFloatingPreviewVerticalPadding">@dimen/gesture_floating_preview_vertical_padding</item>
|
||||
<item name="gestureFloatingPreviewRoundRadius">@dimen/gesture_floating_preview_round_radius</item>
|
||||
<item name="gesturePreviewTrailMinSamplingDistance">@dimen/gesture_preview_trail_min_sampling_distance</item>
|
||||
<item name="gesturePreviewTrailMaxInterpolationAngularThreshold">@integer/gesture_preview_trail_max_interpolation_angular_threshold</item>
|
||||
<item name="gesturePreviewTrailMaxInterpolationDistanceThreshold">@dimen/gesture_preview_trail_max_interpolation_distance_threshold</item>
|
||||
<item name="gesturePreviewTrailMaxInterpolationSegments">@integer/gesture_preview_trail_max_interpolation_segments</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="gesturePreviewTrailUpdateInterval">@integer/config_gesture_preview_trail_update_interval</item>
|
||||
<item name="gesturePreviewTrailColor">@color/highlight_color_default</item>
|
||||
<item name="gesturePreviewTrailStartWidth">@dimen/gesture_preview_trail_start_width</item>
|
||||
<item name="gesturePreviewTrailEndWidth">@dimen/gesture_preview_trail_end_width</item>
|
||||
<item name="gesturePreviewTrailBodyRatio">@integer/gesture_preview_trail_body_ratio</item>
|
||||
<item name="gesturePreviewTrailShadowRatio">@integer/gesture_preview_trail_shadow_ratio</item>
|
||||
<item name="gestureTrailMinSamplingDistance">@dimen/gesture_trail_min_sampling_distance</item>
|
||||
<item name="gestureTrailMaxInterpolationAngularThreshold">@integer/gesture_trail_max_interpolation_angular_threshold</item>
|
||||
<item name="gestureTrailMaxInterpolationDistanceThreshold">@dimen/gesture_trail_max_interpolation_distance_threshold</item>
|
||||
<item name="gestureTrailMaxInterpolationSegments">@integer/gesture_trail_max_interpolation_segments</item>
|
||||
<item name="gestureTrailFadeoutStartDelay">@integer/config_gesture_trail_fadeout_start_delay</item>
|
||||
<item name="gestureTrailFadeoutDuration">@integer/config_gesture_trail_fadeout_duration</item>
|
||||
<item name="gestureTrailUpdateInterval">@integer/config_gesture_trail_update_interval</item>
|
||||
<item name="gestureTrailColor">@color/highlight_color_default</item>
|
||||
<item name="gestureTrailStartWidth">@dimen/gesture_trail_start_width</item>
|
||||
<item name="gestureTrailEndWidth">@dimen/gesture_trail_end_width</item>
|
||||
<item name="gestureTrailBodyRatio">@integer/gesture_trail_body_ratio</item>
|
||||
<item name="gestureTrailShadowRatio">@integer/gesture_trail_shadow_ratio</item>
|
||||
<!-- Common attributes of MainKeyboardView -->
|
||||
<item name="keyHysteresisDistance">@dimen/config_key_hysteresis_distance</item>
|
||||
<item name="keyHysteresisDistanceForSlidingModifier">@dimen/config_key_hysteresis_distance_for_sliding_modifier</item>
|
||||
|
@ -348,7 +348,7 @@
|
|||
<item name="keyTextShadowRadius">0.0</item>
|
||||
<item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_ics</item>
|
||||
<item name="gestureFloatingPreviewTextColor">@color/highlight_color_ics</item>
|
||||
<item name="gesturePreviewTrailColor">@color/highlight_color_ics</item>
|
||||
<item name="gestureTrailColor">@color/highlight_color_ics</item>
|
||||
</style>
|
||||
<style
|
||||
name="MainKeyboardView.IceCreamSandwich"
|
||||
|
|
|
@ -910,10 +910,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
mSlidingKeyInputPreview.dismissSlidingKeyInputPreview();
|
||||
}
|
||||
|
||||
public void setGesturePreviewMode(final boolean drawsGesturePreviewTrail,
|
||||
public void setGesturePreviewMode(final boolean drawsGestureTrail,
|
||||
final boolean drawsGestureFloatingPreviewText) {
|
||||
mGestureFloatingPreviewText.setPreviewEnabled(drawsGestureFloatingPreviewText);
|
||||
mGestureTrailsPreview.setPreviewEnabled(drawsGesturePreviewTrail);
|
||||
mGestureTrailsPreview.setPreviewEnabled(drawsGestureTrail);
|
||||
}
|
||||
|
||||
public void showGestureFloatingPreviewText(final SuggestedWords suggestedWords) {
|
||||
|
@ -927,7 +927,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
|||
}
|
||||
|
||||
@Override
|
||||
public void showGesturePreviewTrail(final PointerTracker tracker) {
|
||||
public void showGestureTrail(final PointerTracker tracker) {
|
||||
locatePreviewPlacerView();
|
||||
mGestureFloatingPreviewText.setPreviewPosition(tracker);
|
||||
mGestureTrailsPreview.setPreviewPosition(tracker);
|
||||
|
|
|
@ -84,7 +84,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
public void dismissKeyPreview(PointerTracker tracker);
|
||||
public void showSlidingKeyInputPreview(PointerTracker tracker);
|
||||
public void dismissSlidingKeyInputPreview();
|
||||
public void showGesturePreviewTrail(PointerTracker tracker);
|
||||
public void showGestureTrail(PointerTracker tracker);
|
||||
}
|
||||
|
||||
public interface TimerProxy {
|
||||
|
@ -737,7 +737,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
dismissAllMoreKeysPanels();
|
||||
}
|
||||
mTimerProxy.cancelLongPressTimer();
|
||||
mDrawingProxy.showGesturePreviewTrail(this);
|
||||
mDrawingProxy.showGestureTrail(this);
|
||||
}
|
||||
|
||||
public void updateBatchInputByTimer(final long eventTime) {
|
||||
|
@ -753,7 +753,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
if (mIsTrackingForActionDisabled) {
|
||||
return;
|
||||
}
|
||||
mDrawingProxy.showGesturePreviewTrail(this);
|
||||
mDrawingProxy.showGestureTrail(this);
|
||||
}
|
||||
|
||||
private void updateBatchInput(final long eventTime) {
|
||||
|
@ -794,7 +794,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
|||
if (mIsTrackingForActionDisabled) {
|
||||
return;
|
||||
}
|
||||
mDrawingProxy.showGesturePreviewTrail(this);
|
||||
mDrawingProxy.showGestureTrail(this);
|
||||
}
|
||||
|
||||
private void cancelBatchInput() {
|
||||
|
|
|
@ -63,18 +63,18 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
|
|||
|
||||
public GestureStrokePreviewParams(final TypedArray mainKeyboardViewAttr) {
|
||||
mMinSamplingDistance = mainKeyboardViewAttr.getDimension(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailMinSamplingDistance,
|
||||
R.styleable.MainKeyboardView_gestureTrailMinSamplingDistance,
|
||||
(float)DEFAULT.mMinSamplingDistance);
|
||||
final int interpolationAngularDegree = mainKeyboardViewAttr.getInteger(R.styleable
|
||||
.MainKeyboardView_gesturePreviewTrailMaxInterpolationAngularThreshold, 0);
|
||||
.MainKeyboardView_gestureTrailMaxInterpolationAngularThreshold, 0);
|
||||
mMaxInterpolationAngularThreshold = (interpolationAngularDegree <= 0)
|
||||
? DEFAULT.mMaxInterpolationAngularThreshold
|
||||
: degreeToRadian(interpolationAngularDegree);
|
||||
mMaxInterpolationDistanceThreshold = mainKeyboardViewAttr.getDimension(R.styleable
|
||||
.MainKeyboardView_gesturePreviewTrailMaxInterpolationDistanceThreshold,
|
||||
.MainKeyboardView_gestureTrailMaxInterpolationDistanceThreshold,
|
||||
(float)DEFAULT.mMaxInterpolationDistanceThreshold);
|
||||
mMaxInterpolationSegments = mainKeyboardViewAttr.getInteger(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailMaxInterpolationSegments,
|
||||
R.styleable.MainKeyboardView_gestureTrailMaxInterpolationSegments,
|
||||
DEFAULT.mMaxInterpolationSegments);
|
||||
}
|
||||
}
|
||||
|
@ -145,9 +145,9 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
|
|||
*
|
||||
* @param lastInterpolatedIndex the start index of the last interpolated segment of
|
||||
* <code>eventTimes</code>, <code>xCoords</code>, and <code>yCoords</code>.
|
||||
* @param eventTimes the event time array of gesture preview trail to be drawn.
|
||||
* @param xCoords the x-coordinates array of gesture preview trail to be drawn.
|
||||
* @param yCoords the y-coordinates array of gesture preview trail to be drawn.
|
||||
* @param eventTimes the event time array of gesture trail to be drawn.
|
||||
* @param xCoords the x-coordinates array of gesture trail to be drawn.
|
||||
* @param yCoords the y-coordinates array of gesture trail to be drawn.
|
||||
* @return the start index of the last interpolated segment of input arrays.
|
||||
*/
|
||||
public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex,
|
||||
|
@ -189,16 +189,16 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
|
|||
eventTimes.add(d1, (int)(dt * t) + t1);
|
||||
xCoords.add(d1, (int)mInterpolator.mInterpolatedX);
|
||||
yCoords.add(d1, (int)mInterpolator.mInterpolatedY);
|
||||
if (GesturePreviewTrail.DBG_SHOW_POINTS) {
|
||||
types.add(d1, GesturePreviewTrail.POINT_TYPE_INTERPOLATED);
|
||||
if (GestureTrail.DBG_SHOW_POINTS) {
|
||||
types.add(d1, GestureTrail.POINT_TYPE_INTERPOLATED);
|
||||
}
|
||||
d1++;
|
||||
}
|
||||
eventTimes.add(d1, pt[p2]);
|
||||
xCoords.add(d1, px[p2]);
|
||||
yCoords.add(d1, py[p2]);
|
||||
if (GesturePreviewTrail.DBG_SHOW_POINTS) {
|
||||
types.add(d1, GesturePreviewTrail.POINT_TYPE_SAMPLED);
|
||||
if (GestureTrail.DBG_SHOW_POINTS) {
|
||||
types.add(d1, GestureTrail.POINT_TYPE_SAMPLED);
|
||||
}
|
||||
}
|
||||
return lastInterpolatedDrawIndex;
|
||||
|
|
|
@ -29,13 +29,13 @@ import com.android.inputmethod.latin.R;
|
|||
import com.android.inputmethod.latin.ResizableIntArray;
|
||||
|
||||
/*
|
||||
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailFadeoutStartDelay
|
||||
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailFadeoutDuration
|
||||
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailUpdateInterval
|
||||
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailColor
|
||||
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailWidth
|
||||
* @attr ref R.styleable#MainKeyboardView_gestureTrailFadeoutStartDelay
|
||||
* @attr ref R.styleable#MainKeyboardView_gestureTrailFadeoutDuration
|
||||
* @attr ref R.styleable#MainKeyboardView_gestureTrailUpdateInterval
|
||||
* @attr ref R.styleable#MainKeyboardView_gestureTrailColor
|
||||
* @attr ref R.styleable#MainKeyboardView_gestureTrailWidth
|
||||
*/
|
||||
final class GesturePreviewTrail {
|
||||
final class GestureTrail {
|
||||
public static final boolean DBG_SHOW_POINTS = false;
|
||||
public static final int POINT_TYPE_SAMPLED = 0;
|
||||
public static final int POINT_TYPE_INTERPOLATED = 1;
|
||||
|
@ -70,26 +70,26 @@ final class GesturePreviewTrail {
|
|||
|
||||
public Params(final TypedArray mainKeyboardViewAttr) {
|
||||
mTrailColor = mainKeyboardViewAttr.getColor(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailColor, 0);
|
||||
R.styleable.MainKeyboardView_gestureTrailColor, 0);
|
||||
mTrailStartWidth = mainKeyboardViewAttr.getDimension(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailStartWidth, 0.0f);
|
||||
R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);
|
||||
mTrailEndWidth = mainKeyboardViewAttr.getDimension(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailEndWidth, 0.0f);
|
||||
R.styleable.MainKeyboardView_gestureTrailEndWidth, 0.0f);
|
||||
final int PERCENTAGE_INT = 100;
|
||||
mTrailBodyRatio = (float)mainKeyboardViewAttr.getInt(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailBodyRatio, PERCENTAGE_INT)
|
||||
R.styleable.MainKeyboardView_gestureTrailBodyRatio, PERCENTAGE_INT)
|
||||
/ (float)PERCENTAGE_INT;
|
||||
final int trailShadowRatioInt = mainKeyboardViewAttr.getInt(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailShadowRatio, 0);
|
||||
R.styleable.MainKeyboardView_gestureTrailShadowRatio, 0);
|
||||
mTrailShadowEnabled = (trailShadowRatioInt > 0);
|
||||
mTrailShadowRatio = (float)trailShadowRatioInt / (float)PERCENTAGE_INT;
|
||||
mFadeoutStartDelay = DBG_SHOW_POINTS ? 2000 : mainKeyboardViewAttr.getInt(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutStartDelay, 0);
|
||||
R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay, 0);
|
||||
mFadeoutDuration = DBG_SHOW_POINTS ? 200 : mainKeyboardViewAttr.getInt(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutDuration, 0);
|
||||
R.styleable.MainKeyboardView_gestureTrailFadeoutDuration, 0);
|
||||
mTrailLingerDuration = mFadeoutStartDelay + mFadeoutDuration;
|
||||
mUpdateInterval = mainKeyboardViewAttr.getInt(
|
||||
R.styleable.MainKeyboardView_gesturePreviewTrailUpdateInterval, 0);
|
||||
R.styleable.MainKeyboardView_gestureTrailUpdateInterval, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,12 +186,12 @@ final class GesturePreviewTrail {
|
|||
private final Rect mRoundedLineBounds = new Rect();
|
||||
|
||||
/**
|
||||
* Draw gesture preview trail
|
||||
* @param canvas The canvas to draw the gesture preview trail
|
||||
* @param paint The paint object to be used to draw the gesture preview trail
|
||||
* Draw gesture trail
|
||||
* @param canvas The canvas to draw the gesture trail
|
||||
* @param paint The paint object to be used to draw the gesture trail
|
||||
* @param outBoundsRect the bounding box of this gesture trail drawing
|
||||
* @param params The drawing parameters of gesture preview trail
|
||||
* @return true if some gesture preview trails remain to be drawn
|
||||
* @param params The drawing parameters of gesture trail
|
||||
* @return true if some gesture trails remain to be drawn
|
||||
*/
|
||||
public boolean drawGestureTrail(final Canvas canvas, final Paint paint,
|
||||
final Rect outBoundsRect, final Params params) {
|
|
@ -29,7 +29,7 @@ import android.util.SparseArray;
|
|||
import android.view.View;
|
||||
|
||||
import com.android.inputmethod.keyboard.PointerTracker;
|
||||
import com.android.inputmethod.keyboard.internal.GesturePreviewTrail.Params;
|
||||
import com.android.inputmethod.keyboard.internal.GestureTrail.Params;
|
||||
import com.android.inputmethod.latin.CollectionUtils;
|
||||
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
||||
|
||||
|
@ -37,9 +37,8 @@ import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
|||
* Draw gesture trail preview graphics during gesture.
|
||||
*/
|
||||
public final class GestureTrailsPreview extends AbstractDrawingPreview {
|
||||
private final SparseArray<GesturePreviewTrail> mGesturePreviewTrails =
|
||||
CollectionUtils.newSparseArray();
|
||||
private final Params mGesturePreviewTrailParams;
|
||||
private final SparseArray<GestureTrail> mGestureTrails = CollectionUtils.newSparseArray();
|
||||
private final Params mGestureTrailParams;
|
||||
private final Paint mGesturePaint;
|
||||
private int mOffscreenWidth;
|
||||
private int mOffscreenHeight;
|
||||
|
@ -48,20 +47,20 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
|
|||
private final Canvas mOffscreenCanvas = new Canvas();
|
||||
private final Rect mOffscreenSrcRect = new Rect();
|
||||
private final Rect mDirtyRect = new Rect();
|
||||
private final Rect mGesturePreviewTrailBoundsRect = new Rect(); // per trail
|
||||
private final Rect mGestureTrailBoundsRect = new Rect(); // per trail
|
||||
|
||||
private final DrawingHandler mDrawingHandler;
|
||||
|
||||
private static final class DrawingHandler
|
||||
extends StaticInnerHandlerWrapper<GestureTrailsPreview> {
|
||||
private static final int MSG_UPDATE_GESTURE_PREVIEW_TRAIL = 0;
|
||||
private static final int MSG_UPDATE_GESTURE_TRAIL = 0;
|
||||
|
||||
private final Params mGesturePreviewTrailParams;
|
||||
private final Params mGestureTrailParams;
|
||||
|
||||
public DrawingHandler(final GestureTrailsPreview outerInstance,
|
||||
final Params gesturePreviewTrailParams) {
|
||||
final Params gestureTrailParams) {
|
||||
super(outerInstance);
|
||||
mGesturePreviewTrailParams = gesturePreviewTrailParams;
|
||||
mGestureTrailParams = gestureTrailParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,23 +68,23 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
|
|||
final GestureTrailsPreview preview = getOuterInstance();
|
||||
if (preview == null) return;
|
||||
switch (msg.what) {
|
||||
case MSG_UPDATE_GESTURE_PREVIEW_TRAIL:
|
||||
case MSG_UPDATE_GESTURE_TRAIL:
|
||||
preview.getDrawingView().invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdateGestureTrailPreview() {
|
||||
removeMessages(MSG_UPDATE_GESTURE_PREVIEW_TRAIL);
|
||||
sendMessageDelayed(obtainMessage(MSG_UPDATE_GESTURE_PREVIEW_TRAIL),
|
||||
mGesturePreviewTrailParams.mUpdateInterval);
|
||||
removeMessages(MSG_UPDATE_GESTURE_TRAIL);
|
||||
sendMessageDelayed(obtainMessage(MSG_UPDATE_GESTURE_TRAIL),
|
||||
mGestureTrailParams.mUpdateInterval);
|
||||
}
|
||||
}
|
||||
|
||||
public GestureTrailsPreview(final View drawingView, final TypedArray mainKeyboardViewAttr) {
|
||||
super(drawingView);
|
||||
mGesturePreviewTrailParams = new Params(mainKeyboardViewAttr);
|
||||
mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams);
|
||||
mGestureTrailParams = new Params(mainKeyboardViewAttr);
|
||||
mDrawingHandler = new DrawingHandler(this, mGestureTrailParams);
|
||||
final Paint gesturePaint = new Paint();
|
||||
gesturePaint.setAntiAlias(true);
|
||||
gesturePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
|
||||
|
@ -133,21 +132,20 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
|
|||
offscreenCanvas.drawRect(dirtyRect, paint);
|
||||
}
|
||||
dirtyRect.setEmpty();
|
||||
boolean needsUpdatingGesturePreviewTrail = false;
|
||||
boolean needsUpdatingGestureTrail = false;
|
||||
// Draw gesture trails to offscreen buffer.
|
||||
synchronized (mGesturePreviewTrails) {
|
||||
synchronized (mGestureTrails) {
|
||||
// Trails count == fingers count that have ever been active.
|
||||
final int trailsCount = mGesturePreviewTrails.size();
|
||||
final int trailsCount = mGestureTrails.size();
|
||||
for (int index = 0; index < trailsCount; index++) {
|
||||
final GesturePreviewTrail trail = mGesturePreviewTrails.valueAt(index);
|
||||
needsUpdatingGesturePreviewTrail |=
|
||||
trail.drawGestureTrail(offscreenCanvas, paint,
|
||||
mGesturePreviewTrailBoundsRect, mGesturePreviewTrailParams);
|
||||
// {@link #mGesturePreviewTrailBoundsRect} has bounding box of the trail.
|
||||
dirtyRect.union(mGesturePreviewTrailBoundsRect);
|
||||
final GestureTrail trail = mGestureTrails.valueAt(index);
|
||||
needsUpdatingGestureTrail |= trail.drawGestureTrail(offscreenCanvas, paint,
|
||||
mGestureTrailBoundsRect, mGestureTrailParams);
|
||||
// {@link #mGestureTrailBoundsRect} has bounding box of the trail.
|
||||
dirtyRect.union(mGestureTrailBoundsRect);
|
||||
}
|
||||
}
|
||||
return needsUpdatingGesturePreviewTrail;
|
||||
return needsUpdatingGestureTrail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,9 +159,9 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
|
|||
}
|
||||
mayAllocateOffscreenBuffer();
|
||||
// Draw gesture trails to offscreen buffer.
|
||||
final boolean needsUpdatingGesturePreviewTrail = drawGestureTrails(
|
||||
final boolean needsUpdatingGestureTrail = drawGestureTrails(
|
||||
mOffscreenCanvas, mGesturePaint, mDirtyRect);
|
||||
if (needsUpdatingGesturePreviewTrail) {
|
||||
if (needsUpdatingGestureTrail) {
|
||||
mDrawingHandler.postUpdateGestureTrailPreview();
|
||||
}
|
||||
// Transfer offscreen buffer to screen.
|
||||
|
@ -185,12 +183,12 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
|
|||
if (!isPreviewEnabled()) {
|
||||
return;
|
||||
}
|
||||
GesturePreviewTrail trail;
|
||||
synchronized (mGesturePreviewTrails) {
|
||||
trail = mGesturePreviewTrails.get(tracker.mPointerId);
|
||||
GestureTrail trail;
|
||||
synchronized (mGestureTrails) {
|
||||
trail = mGestureTrails.get(tracker.mPointerId);
|
||||
if (trail == null) {
|
||||
trail = new GesturePreviewTrail();
|
||||
mGesturePreviewTrails.put(tracker.mPointerId, trail);
|
||||
trail = new GestureTrail();
|
||||
mGestureTrails.put(tracker.mPointerId, trail);
|
||||
}
|
||||
}
|
||||
trail.addStroke(tracker.getGestureStrokeWithPreviewPoints(), tracker.getDownTime());
|
||||
|
|
Loading…
Reference in New Issue