am cb3bba3c: Rename GesturePreviewTrail.java -> GestureTrail.java

* commit 'cb3bba3c4ee4652e12c81185ab9a648db20bb0dd':
  Rename GesturePreviewTrail.java -> GestureTrail.java
main
Ken Wakasa 2013-05-12 22:55:25 -07:00 committed by Android Git Automerger
commit 01c133d72e
11 changed files with 118 additions and 120 deletions

View File

@ -85,8 +85,8 @@
<dimen name="suggestion_text_size">22dp</dimen> <dimen name="suggestion_text_size">22dp</dimen>
<dimen name="more_suggestions_hint_text_size">33dp</dimen> <dimen name="more_suggestions_hint_text_size">33dp</dimen>
<!-- Gesture preview trail parameters --> <!-- Gesture trail parameters -->
<dimen name="gesture_preview_trail_width">2.5dp</dimen> <dimen name="gesture_trail_width">2.5dp</dimen>
<!-- Gesture floating preview text parameters --> <!-- Gesture floating preview text parameters -->
<dimen name="gesture_floating_preview_text_size">28dp</dimen> <dimen name="gesture_floating_preview_text_size">28dp</dimen>
<dimen name="gesture_floating_preview_text_offset">87dp</dimen> <dimen name="gesture_floating_preview_text_offset">87dp</dimen>

View File

@ -86,8 +86,8 @@
<dimen name="suggestion_text_size">22dp</dimen> <dimen name="suggestion_text_size">22dp</dimen>
<dimen name="more_suggestions_hint_text_size">33dp</dimen> <dimen name="more_suggestions_hint_text_size">33dp</dimen>
<!-- Gesture preview trail parameters --> <!-- Gesture trail parameters -->
<dimen name="gesture_preview_trail_width">2.5dp</dimen> <dimen name="gesture_trail_width">2.5dp</dimen>
<!-- Gesture floating preview text parameters --> <!-- Gesture floating preview text parameters -->
<dimen name="gesture_floating_preview_text_size">26dp</dimen> <dimen name="gesture_floating_preview_text_size">26dp</dimen>
<dimen name="gesture_floating_preview_text_offset">86dp</dimen> <dimen name="gesture_floating_preview_text_offset">86dp</dimen>

View File

@ -108,25 +108,25 @@
<attr name="backgroundDimAlpha" format="integer" /> <attr name="backgroundDimAlpha" format="integer" />
<!-- 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" />
<!-- Minimum distance between gesture preview trail sampling points. --> <!-- Minimum distance between gesture trail sampling points. -->
<attr name="gesturePreviewTrailMinSamplingDistance" format="dimension" /> <attr name="gestureTrailMinSamplingDistance" format="dimension" />
<!-- Maximum angular threshold between gesture preview trail interpolation segments in degree. --> <!-- Maximum angular threshold between gesture trail interpolation segments in degree. -->
<attr name="gesturePreviewTrailMaxInterpolationAngularThreshold" format="integer" /> <attr name="gestureTrailMaxInterpolationAngularThreshold" format="integer" />
<!-- Maximum distance threshold between gesture preview trail interpolation segments. --> <!-- Maximum distance threshold between gesture trail interpolation segments. -->
<attr name="gesturePreviewTrailMaxInterpolationDistanceThreshold" format="dimension" /> <attr name="gestureTrailMaxInterpolationDistanceThreshold" format="dimension" />
<!-- Maximum number of gesture preview trail interpolation segments. --> <!-- Maximum number of gesture trail interpolation segments. -->
<attr name="gesturePreviewTrailMaxInterpolationSegments" format="integer" /> <attr name="gestureTrailMaxInterpolationSegments" 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="gestureTrailFadeoutStartDelay" format="integer" />
<!-- Duration while gesture preview trail is fading out in millisecond. --> <!-- Duration while gesture trail is fading out in millisecond. -->
<attr name="gesturePreviewTrailFadeoutDuration" format="integer" /> <attr name="gestureTrailFadeoutDuration" format="integer" />
<!-- Interval of updating gesture preview trail in millisecond. --> <!-- Interval of updating gesture trail in millisecond. -->
<attr name="gesturePreviewTrailUpdateInterval" format="integer" /> <attr name="gestureTrailUpdateInterval" format="integer" />
<attr name="gesturePreviewTrailColor" format="color" /> <attr name="gestureTrailColor" format="color" />
<attr name="gesturePreviewTrailStartWidth" format="dimension" /> <attr name="gestureTrailStartWidth" format="dimension" />
<attr name="gesturePreviewTrailEndWidth" format="dimension" /> <attr name="gestureTrailEndWidth" format="dimension" />
<attr name="gesturePreviewTrailBodyRatio" format="integer" /> <attr name="gestureTrailBodyRatio" format="integer" />
<attr name="gesturePreviewTrailShadowRatio" format="integer" /> <attr name="gestureTrailShadowRatio" format="integer" />
<!-- Delay after gesture input and gesture floating preview text dismissing in millisecond --> <!-- Delay after gesture input and gesture floating preview text dismissing in millisecond -->
<attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" /> <attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" />
<!-- Attributes for GestureFloatingPreviewText --> <!-- Attributes for GestureFloatingPreviewText -->

View File

@ -75,9 +75,9 @@
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool> <bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
<bool name="config_block_potentially_offensive">true</bool> <bool name="config_block_potentially_offensive">true</bool>
<integer name="config_gesture_floating_preview_text_linger_timeout">200</integer> <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_trail_fadeout_start_delay">100</integer>
<integer name="config_gesture_preview_trail_fadeout_duration">800</integer> <integer name="config_gesture_trail_fadeout_duration">800</integer>
<integer name="config_gesture_preview_trail_update_interval">20</integer> <integer name="config_gesture_trail_update_interval">20</integer>
<!-- Static threshold for gesture after fast typing (msec) --> <!-- Static threshold for gesture after fast typing (msec) -->
<integer name="config_gesture_static_time_threshold_after_fast_typing">500</integer> <integer name="config_gesture_static_time_threshold_after_fast_typing">500</integer>
<!-- Static threshold for starting gesture detection (keyWidth%/sec) --> <!-- Static threshold for starting gesture detection (keyWidth%/sec) -->

View File

@ -100,22 +100,22 @@
<integer name="suggestions_count_in_strip">3</integer> <integer name="suggestions_count_in_strip">3</integer>
<fraction name="center_suggestion_percentile">36%</fraction> <fraction name="center_suggestion_percentile">36%</fraction>
<!-- Gesture preview trail parameters --> <!-- Gesture trail parameters -->
<!-- Minimum distance between gesture preview trail sampling points. --> <!-- Minimum distance between gesture trail sampling points. -->
<dimen name="gesture_preview_trail_min_sampling_distance">6.4dp</dimen> <dimen name="gesture_trail_min_sampling_distance">6.4dp</dimen>
<!-- Maximum angular threshold between gesture preview trails interpolation segments in degree. --> <!-- Maximum angular threshold between gesture trails interpolation segments in degree. -->
<integer name="gesture_preview_trail_max_interpolation_angular_threshold">15</integer> <integer name="gesture_trail_max_interpolation_angular_threshold">15</integer>
<!-- Maximum distance threshold between gesture preview trails interpolation segments. --> <!-- Maximum distance threshold between gesture trails interpolation segments. -->
<dimen name="gesture_preview_trail_max_interpolation_distance_threshold">16.0dp</dimen> <dimen name="gesture_trail_max_interpolation_distance_threshold">16.0dp</dimen>
<!-- Maximum number of gesture preview trail interpolation segments. --> <!-- Maximum number of gesture trail interpolation segments. -->
<integer name="gesture_preview_trail_max_interpolation_segments">6</integer> <integer name="gesture_trail_max_interpolation_segments">6</integer>
<dimen name="gesture_preview_trail_start_width">10.0dp</dimen> <dimen name="gesture_trail_start_width">10.0dp</dimen>
<dimen name="gesture_preview_trail_end_width">2.5dp</dimen> <dimen name="gesture_trail_end_width">2.5dp</dimen>
<!-- Percentages of gesture preview taril body and shadow, in proportion to the trail width. <!-- Percentages of gesture preview taril body and shadow, in proportion to the trail width.
A negative value of the shadow ratio disables drawing shadow. --> A negative value of the shadow ratio disables drawing shadow. -->
<!-- TODO: May use the shadow to alleviate rugged trail drawing. --> <!-- TODO: May use the shadow to alleviate rugged trail drawing. -->
<integer name="gesture_preview_trail_body_ratio">100</integer> <integer name="gesture_trail_body_ratio">100</integer>
<integer name="gesture_preview_trail_shadow_ratio">-1</integer> <integer name="gesture_trail_shadow_ratio">-1</integer>
<!-- Gesture floating preview text parameters --> <!-- Gesture floating preview text parameters -->
<dimen name="gesture_floating_preview_text_size">24dp</dimen> <dimen name="gesture_floating_preview_text_size">24dp</dimen>
<dimen name="gesture_floating_preview_text_offset">73dp</dimen> <dimen name="gesture_floating_preview_text_offset">73dp</dimen>

View File

@ -64,18 +64,18 @@
<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="gesturePreviewTrailMinSamplingDistance">@dimen/gesture_preview_trail_min_sampling_distance</item> <item name="gestureTrailMinSamplingDistance">@dimen/gesture_trail_min_sampling_distance</item>
<item name="gesturePreviewTrailMaxInterpolationAngularThreshold">@integer/gesture_preview_trail_max_interpolation_angular_threshold</item> <item name="gestureTrailMaxInterpolationAngularThreshold">@integer/gesture_trail_max_interpolation_angular_threshold</item>
<item name="gesturePreviewTrailMaxInterpolationDistanceThreshold">@dimen/gesture_preview_trail_max_interpolation_distance_threshold</item> <item name="gestureTrailMaxInterpolationDistanceThreshold">@dimen/gesture_trail_max_interpolation_distance_threshold</item>
<item name="gesturePreviewTrailMaxInterpolationSegments">@integer/gesture_preview_trail_max_interpolation_segments</item> <item name="gestureTrailMaxInterpolationSegments">@integer/gesture_trail_max_interpolation_segments</item>
<item name="gesturePreviewTrailFadeoutStartDelay">@integer/config_gesture_preview_trail_fadeout_start_delay</item> <item name="gestureTrailFadeoutStartDelay">@integer/config_gesture_trail_fadeout_start_delay</item>
<item name="gesturePreviewTrailFadeoutDuration">@integer/config_gesture_preview_trail_fadeout_duration</item> <item name="gestureTrailFadeoutDuration">@integer/config_gesture_trail_fadeout_duration</item>
<item name="gesturePreviewTrailUpdateInterval">@integer/config_gesture_preview_trail_update_interval</item> <item name="gestureTrailUpdateInterval">@integer/config_gesture_trail_update_interval</item>
<item name="gesturePreviewTrailColor">@color/highlight_color_default</item> <item name="gestureTrailColor">@color/highlight_color_default</item>
<item name="gesturePreviewTrailStartWidth">@dimen/gesture_preview_trail_start_width</item> <item name="gestureTrailStartWidth">@dimen/gesture_trail_start_width</item>
<item name="gesturePreviewTrailEndWidth">@dimen/gesture_preview_trail_end_width</item> <item name="gestureTrailEndWidth">@dimen/gesture_trail_end_width</item>
<item name="gesturePreviewTrailBodyRatio">@integer/gesture_preview_trail_body_ratio</item> <item name="gestureTrailBodyRatio">@integer/gesture_trail_body_ratio</item>
<item name="gesturePreviewTrailShadowRatio">@integer/gesture_preview_trail_shadow_ratio</item> <item name="gestureTrailShadowRatio">@integer/gesture_trail_shadow_ratio</item>
<!-- Common attributes of MainKeyboardView --> <!-- Common attributes of MainKeyboardView -->
<item name="keyHysteresisDistance">@dimen/config_key_hysteresis_distance</item> <item name="keyHysteresisDistance">@dimen/config_key_hysteresis_distance</item>
<item name="keyHysteresisDistanceForSlidingModifier">@dimen/config_key_hysteresis_distance_for_sliding_modifier</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="keyTextShadowRadius">0.0</item>
<item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_ics</item> <item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_ics</item>
<item name="gestureFloatingPreviewTextColor">@color/highlight_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>
<style <style
name="MainKeyboardView.IceCreamSandwich" name="MainKeyboardView.IceCreamSandwich"

View File

@ -910,10 +910,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mSlidingKeyInputPreview.dismissSlidingKeyInputPreview(); mSlidingKeyInputPreview.dismissSlidingKeyInputPreview();
} }
public void setGesturePreviewMode(final boolean drawsGesturePreviewTrail, public void setGesturePreviewMode(final boolean drawsGestureTrail,
final boolean drawsGestureFloatingPreviewText) { final boolean drawsGestureFloatingPreviewText) {
mGestureFloatingPreviewText.setPreviewEnabled(drawsGestureFloatingPreviewText); mGestureFloatingPreviewText.setPreviewEnabled(drawsGestureFloatingPreviewText);
mGestureTrailsPreview.setPreviewEnabled(drawsGesturePreviewTrail); mGestureTrailsPreview.setPreviewEnabled(drawsGestureTrail);
} }
public void showGestureFloatingPreviewText(final SuggestedWords suggestedWords) { public void showGestureFloatingPreviewText(final SuggestedWords suggestedWords) {
@ -927,7 +927,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
} }
@Override @Override
public void showGesturePreviewTrail(final PointerTracker tracker) { public void showGestureTrail(final PointerTracker tracker) {
locatePreviewPlacerView(); locatePreviewPlacerView();
mGestureFloatingPreviewText.setPreviewPosition(tracker); mGestureFloatingPreviewText.setPreviewPosition(tracker);
mGestureTrailsPreview.setPreviewPosition(tracker); mGestureTrailsPreview.setPreviewPosition(tracker);

View File

@ -84,7 +84,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
public void dismissKeyPreview(PointerTracker tracker); public void dismissKeyPreview(PointerTracker tracker);
public void showSlidingKeyInputPreview(PointerTracker tracker); public void showSlidingKeyInputPreview(PointerTracker tracker);
public void dismissSlidingKeyInputPreview(); public void dismissSlidingKeyInputPreview();
public void showGesturePreviewTrail(PointerTracker tracker); public void showGestureTrail(PointerTracker tracker);
} }
public interface TimerProxy { public interface TimerProxy {
@ -737,7 +737,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
dismissAllMoreKeysPanels(); dismissAllMoreKeysPanels();
} }
mTimerProxy.cancelLongPressTimer(); mTimerProxy.cancelLongPressTimer();
mDrawingProxy.showGesturePreviewTrail(this); mDrawingProxy.showGestureTrail(this);
} }
public void updateBatchInputByTimer(final long eventTime) { public void updateBatchInputByTimer(final long eventTime) {
@ -753,7 +753,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
if (mIsTrackingForActionDisabled) { if (mIsTrackingForActionDisabled) {
return; return;
} }
mDrawingProxy.showGesturePreviewTrail(this); mDrawingProxy.showGestureTrail(this);
} }
private void updateBatchInput(final long eventTime) { private void updateBatchInput(final long eventTime) {
@ -794,7 +794,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
if (mIsTrackingForActionDisabled) { if (mIsTrackingForActionDisabled) {
return; return;
} }
mDrawingProxy.showGesturePreviewTrail(this); mDrawingProxy.showGestureTrail(this);
} }
private void cancelBatchInput() { private void cancelBatchInput() {

View File

@ -63,18 +63,18 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
public GestureStrokePreviewParams(final TypedArray mainKeyboardViewAttr) { public GestureStrokePreviewParams(final TypedArray mainKeyboardViewAttr) {
mMinSamplingDistance = mainKeyboardViewAttr.getDimension( mMinSamplingDistance = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gesturePreviewTrailMinSamplingDistance, R.styleable.MainKeyboardView_gestureTrailMinSamplingDistance,
(float)DEFAULT.mMinSamplingDistance); (float)DEFAULT.mMinSamplingDistance);
final int interpolationAngularDegree = mainKeyboardViewAttr.getInteger(R.styleable final int interpolationAngularDegree = mainKeyboardViewAttr.getInteger(R.styleable
.MainKeyboardView_gesturePreviewTrailMaxInterpolationAngularThreshold, 0); .MainKeyboardView_gestureTrailMaxInterpolationAngularThreshold, 0);
mMaxInterpolationAngularThreshold = (interpolationAngularDegree <= 0) mMaxInterpolationAngularThreshold = (interpolationAngularDegree <= 0)
? DEFAULT.mMaxInterpolationAngularThreshold ? DEFAULT.mMaxInterpolationAngularThreshold
: degreeToRadian(interpolationAngularDegree); : degreeToRadian(interpolationAngularDegree);
mMaxInterpolationDistanceThreshold = mainKeyboardViewAttr.getDimension(R.styleable mMaxInterpolationDistanceThreshold = mainKeyboardViewAttr.getDimension(R.styleable
.MainKeyboardView_gesturePreviewTrailMaxInterpolationDistanceThreshold, .MainKeyboardView_gestureTrailMaxInterpolationDistanceThreshold,
(float)DEFAULT.mMaxInterpolationDistanceThreshold); (float)DEFAULT.mMaxInterpolationDistanceThreshold);
mMaxInterpolationSegments = mainKeyboardViewAttr.getInteger( mMaxInterpolationSegments = mainKeyboardViewAttr.getInteger(
R.styleable.MainKeyboardView_gesturePreviewTrailMaxInterpolationSegments, R.styleable.MainKeyboardView_gestureTrailMaxInterpolationSegments,
DEFAULT.mMaxInterpolationSegments); DEFAULT.mMaxInterpolationSegments);
} }
} }
@ -145,9 +145,9 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
* *
* @param lastInterpolatedIndex the start index of the last interpolated segment of * @param lastInterpolatedIndex the start index of the last interpolated segment of
* <code>eventTimes</code>, <code>xCoords</code>, and <code>yCoords</code>. * <code>eventTimes</code>, <code>xCoords</code>, and <code>yCoords</code>.
* @param eventTimes the event time 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 preview trail to be drawn. * @param xCoords the x-coordinates array of gesture trail to be drawn.
* @param yCoords the y-coordinates array of gesture preview 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. * @return the start index of the last interpolated segment of input arrays.
*/ */
public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex, public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex,
@ -189,16 +189,16 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
eventTimes.add(d1, (int)(dt * t) + t1); eventTimes.add(d1, (int)(dt * t) + t1);
xCoords.add(d1, (int)mInterpolator.mInterpolatedX); xCoords.add(d1, (int)mInterpolator.mInterpolatedX);
yCoords.add(d1, (int)mInterpolator.mInterpolatedY); yCoords.add(d1, (int)mInterpolator.mInterpolatedY);
if (GesturePreviewTrail.DBG_SHOW_POINTS) { if (GestureTrail.DBG_SHOW_POINTS) {
types.add(d1, GesturePreviewTrail.POINT_TYPE_INTERPOLATED); types.add(d1, GestureTrail.POINT_TYPE_INTERPOLATED);
} }
d1++; d1++;
} }
eventTimes.add(d1, pt[p2]); eventTimes.add(d1, pt[p2]);
xCoords.add(d1, px[p2]); xCoords.add(d1, px[p2]);
yCoords.add(d1, py[p2]); yCoords.add(d1, py[p2]);
if (GesturePreviewTrail.DBG_SHOW_POINTS) { if (GestureTrail.DBG_SHOW_POINTS) {
types.add(d1, GesturePreviewTrail.POINT_TYPE_SAMPLED); types.add(d1, GestureTrail.POINT_TYPE_SAMPLED);
} }
} }
return lastInterpolatedDrawIndex; return lastInterpolatedDrawIndex;

View File

@ -29,13 +29,13 @@ import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResizableIntArray; import com.android.inputmethod.latin.ResizableIntArray;
/* /*
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailFadeoutStartDelay * @attr ref R.styleable#MainKeyboardView_gestureTrailFadeoutStartDelay
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailFadeoutDuration * @attr ref R.styleable#MainKeyboardView_gestureTrailFadeoutDuration
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailUpdateInterval * @attr ref R.styleable#MainKeyboardView_gestureTrailUpdateInterval
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailColor * @attr ref R.styleable#MainKeyboardView_gestureTrailColor
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailWidth * @attr ref R.styleable#MainKeyboardView_gestureTrailWidth
*/ */
final class GesturePreviewTrail { final class GestureTrail {
public static final boolean DBG_SHOW_POINTS = false; public static final boolean DBG_SHOW_POINTS = false;
public static final int POINT_TYPE_SAMPLED = 0; public static final int POINT_TYPE_SAMPLED = 0;
public static final int POINT_TYPE_INTERPOLATED = 1; public static final int POINT_TYPE_INTERPOLATED = 1;
@ -70,26 +70,26 @@ final class GesturePreviewTrail {
public Params(final TypedArray mainKeyboardViewAttr) { public Params(final TypedArray mainKeyboardViewAttr) {
mTrailColor = mainKeyboardViewAttr.getColor( mTrailColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gesturePreviewTrailColor, 0); R.styleable.MainKeyboardView_gestureTrailColor, 0);
mTrailStartWidth = mainKeyboardViewAttr.getDimension( mTrailStartWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gesturePreviewTrailStartWidth, 0.0f); R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);
mTrailEndWidth = mainKeyboardViewAttr.getDimension( mTrailEndWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gesturePreviewTrailEndWidth, 0.0f); R.styleable.MainKeyboardView_gestureTrailEndWidth, 0.0f);
final int PERCENTAGE_INT = 100; final int PERCENTAGE_INT = 100;
mTrailBodyRatio = (float)mainKeyboardViewAttr.getInt( mTrailBodyRatio = (float)mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailBodyRatio, PERCENTAGE_INT) R.styleable.MainKeyboardView_gestureTrailBodyRatio, PERCENTAGE_INT)
/ (float)PERCENTAGE_INT; / (float)PERCENTAGE_INT;
final int trailShadowRatioInt = mainKeyboardViewAttr.getInt( final int trailShadowRatioInt = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailShadowRatio, 0); R.styleable.MainKeyboardView_gestureTrailShadowRatio, 0);
mTrailShadowEnabled = (trailShadowRatioInt > 0); mTrailShadowEnabled = (trailShadowRatioInt > 0);
mTrailShadowRatio = (float)trailShadowRatioInt / (float)PERCENTAGE_INT; mTrailShadowRatio = (float)trailShadowRatioInt / (float)PERCENTAGE_INT;
mFadeoutStartDelay = DBG_SHOW_POINTS ? 2000 : mainKeyboardViewAttr.getInt( mFadeoutStartDelay = DBG_SHOW_POINTS ? 2000 : mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutStartDelay, 0); R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay, 0);
mFadeoutDuration = DBG_SHOW_POINTS ? 200 : mainKeyboardViewAttr.getInt( mFadeoutDuration = DBG_SHOW_POINTS ? 200 : mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutDuration, 0); R.styleable.MainKeyboardView_gestureTrailFadeoutDuration, 0);
mTrailLingerDuration = mFadeoutStartDelay + mFadeoutDuration; mTrailLingerDuration = mFadeoutStartDelay + mFadeoutDuration;
mUpdateInterval = mainKeyboardViewAttr.getInt( 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(); private final Rect mRoundedLineBounds = new Rect();
/** /**
* Draw gesture preview trail * Draw gesture trail
* @param canvas The canvas to draw the gesture preview trail * @param canvas The canvas to draw the gesture trail
* @param paint The paint object to be used to draw the gesture preview 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 outBoundsRect the bounding box of this gesture trail drawing
* @param params The drawing parameters of gesture preview trail * @param params The drawing parameters of gesture trail
* @return true if some gesture preview trails remain to be drawn * @return true if some gesture trails remain to be drawn
*/ */
public boolean drawGestureTrail(final Canvas canvas, final Paint paint, public boolean drawGestureTrail(final Canvas canvas, final Paint paint,
final Rect outBoundsRect, final Params params) { final Rect outBoundsRect, final Params params) {

View File

@ -29,7 +29,7 @@ import android.util.SparseArray;
import android.view.View; import android.view.View;
import com.android.inputmethod.keyboard.PointerTracker; 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.CollectionUtils;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
@ -37,9 +37,8 @@ import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
* Draw gesture trail preview graphics during gesture. * Draw gesture trail preview graphics during gesture.
*/ */
public final class GestureTrailsPreview extends AbstractDrawingPreview { public final class GestureTrailsPreview extends AbstractDrawingPreview {
private final SparseArray<GesturePreviewTrail> mGesturePreviewTrails = private final SparseArray<GestureTrail> mGestureTrails = CollectionUtils.newSparseArray();
CollectionUtils.newSparseArray(); private final Params mGestureTrailParams;
private final Params mGesturePreviewTrailParams;
private final Paint mGesturePaint; private final Paint mGesturePaint;
private int mOffscreenWidth; private int mOffscreenWidth;
private int mOffscreenHeight; private int mOffscreenHeight;
@ -48,20 +47,20 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
private final Canvas mOffscreenCanvas = new Canvas(); private final Canvas mOffscreenCanvas = new Canvas();
private final Rect mOffscreenSrcRect = new Rect(); private final Rect mOffscreenSrcRect = new Rect();
private final Rect mDirtyRect = 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 final DrawingHandler mDrawingHandler;
private static final class DrawingHandler private static final class DrawingHandler
extends StaticInnerHandlerWrapper<GestureTrailsPreview> { 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, public DrawingHandler(final GestureTrailsPreview outerInstance,
final Params gesturePreviewTrailParams) { final Params gestureTrailParams) {
super(outerInstance); super(outerInstance);
mGesturePreviewTrailParams = gesturePreviewTrailParams; mGestureTrailParams = gestureTrailParams;
} }
@Override @Override
@ -69,23 +68,23 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
final GestureTrailsPreview preview = getOuterInstance(); final GestureTrailsPreview preview = getOuterInstance();
if (preview == null) return; if (preview == null) return;
switch (msg.what) { switch (msg.what) {
case MSG_UPDATE_GESTURE_PREVIEW_TRAIL: case MSG_UPDATE_GESTURE_TRAIL:
preview.getDrawingView().invalidate(); preview.getDrawingView().invalidate();
break; break;
} }
} }
public void postUpdateGestureTrailPreview() { public void postUpdateGestureTrailPreview() {
removeMessages(MSG_UPDATE_GESTURE_PREVIEW_TRAIL); removeMessages(MSG_UPDATE_GESTURE_TRAIL);
sendMessageDelayed(obtainMessage(MSG_UPDATE_GESTURE_PREVIEW_TRAIL), sendMessageDelayed(obtainMessage(MSG_UPDATE_GESTURE_TRAIL),
mGesturePreviewTrailParams.mUpdateInterval); mGestureTrailParams.mUpdateInterval);
} }
} }
public GestureTrailsPreview(final View drawingView, final TypedArray mainKeyboardViewAttr) { public GestureTrailsPreview(final View drawingView, final TypedArray mainKeyboardViewAttr) {
super(drawingView); super(drawingView);
mGesturePreviewTrailParams = new Params(mainKeyboardViewAttr); mGestureTrailParams = new Params(mainKeyboardViewAttr);
mDrawingHandler = new DrawingHandler(this, mGesturePreviewTrailParams); mDrawingHandler = new DrawingHandler(this, mGestureTrailParams);
final Paint gesturePaint = new Paint(); final Paint gesturePaint = new Paint();
gesturePaint.setAntiAlias(true); gesturePaint.setAntiAlias(true);
gesturePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); gesturePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
@ -133,21 +132,20 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
offscreenCanvas.drawRect(dirtyRect, paint); offscreenCanvas.drawRect(dirtyRect, paint);
} }
dirtyRect.setEmpty(); dirtyRect.setEmpty();
boolean needsUpdatingGesturePreviewTrail = false; boolean needsUpdatingGestureTrail = false;
// Draw gesture trails to offscreen buffer. // Draw gesture trails to offscreen buffer.
synchronized (mGesturePreviewTrails) { synchronized (mGestureTrails) {
// Trails count == fingers count that have ever been active. // 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++) { for (int index = 0; index < trailsCount; index++) {
final GesturePreviewTrail trail = mGesturePreviewTrails.valueAt(index); final GestureTrail trail = mGestureTrails.valueAt(index);
needsUpdatingGesturePreviewTrail |= needsUpdatingGestureTrail |= trail.drawGestureTrail(offscreenCanvas, paint,
trail.drawGestureTrail(offscreenCanvas, paint, mGestureTrailBoundsRect, mGestureTrailParams);
mGesturePreviewTrailBoundsRect, mGesturePreviewTrailParams); // {@link #mGestureTrailBoundsRect} has bounding box of the trail.
// {@link #mGesturePreviewTrailBoundsRect} has bounding box of the trail. dirtyRect.union(mGestureTrailBoundsRect);
dirtyRect.union(mGesturePreviewTrailBoundsRect);
} }
} }
return needsUpdatingGesturePreviewTrail; return needsUpdatingGestureTrail;
} }
/** /**
@ -161,9 +159,9 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
} }
mayAllocateOffscreenBuffer(); mayAllocateOffscreenBuffer();
// Draw gesture trails to offscreen buffer. // Draw gesture trails to offscreen buffer.
final boolean needsUpdatingGesturePreviewTrail = drawGestureTrails( final boolean needsUpdatingGestureTrail = drawGestureTrails(
mOffscreenCanvas, mGesturePaint, mDirtyRect); mOffscreenCanvas, mGesturePaint, mDirtyRect);
if (needsUpdatingGesturePreviewTrail) { if (needsUpdatingGestureTrail) {
mDrawingHandler.postUpdateGestureTrailPreview(); mDrawingHandler.postUpdateGestureTrailPreview();
} }
// Transfer offscreen buffer to screen. // Transfer offscreen buffer to screen.
@ -185,12 +183,12 @@ public final class GestureTrailsPreview extends AbstractDrawingPreview {
if (!isPreviewEnabled()) { if (!isPreviewEnabled()) {
return; return;
} }
GesturePreviewTrail trail; GestureTrail trail;
synchronized (mGesturePreviewTrails) { synchronized (mGestureTrails) {
trail = mGesturePreviewTrails.get(tracker.mPointerId); trail = mGestureTrails.get(tracker.mPointerId);
if (trail == null) { if (trail == null) {
trail = new GesturePreviewTrail(); trail = new GestureTrail();
mGesturePreviewTrails.put(tracker.mPointerId, trail); mGestureTrails.put(tracker.mPointerId, trail);
} }
} }
trail.addStroke(tracker.getGestureStrokeWithPreviewPoints(), tracker.getDownTime()); trail.addStroke(tracker.getGestureStrokeWithPreviewPoints(), tracker.getDownTime());