aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-05-09 19:16:11 +0900
committerSatoshi Kataoka <satok@google.com>2013-05-09 19:19:11 +0900
commitb2c4c73064943577496e3177413a0550d67e553f (patch)
treecd7f0073df66967a148d1d9656b1ae22e57917fe /java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
parentb902109000bcef184e69daac7dc3906fc969791e (diff)
downloadlatinime-b2c4c73064943577496e3177413a0550d67e553f.tar.gz
latinime-b2c4c73064943577496e3177413a0550d67e553f.tar.xz
latinime-b2c4c73064943577496e3177413a0550d67e553f.zip
Add debug facilities for gesture
Bug: 8556775 Change-Id: I9069b2b44356bbae9fa4aaf0b99c3d723a8c9c58
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
index 7fd1bedcb..c7b51426f 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard.internal;
import android.content.res.TypedArray;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
@@ -35,12 +36,19 @@ import com.android.inputmethod.latin.ResizableIntArray;
* @attr ref R.styleable#MainKeyboardView_gesturePreviewTrailWidth
*/
final class GesturePreviewTrail {
+ public static final boolean DBG_SHOW_POINTS = false;
+ public static final int POINT_TYPE_SAMPLED = 0;
+ public static final int POINT_TYPE_INTERPOLATED = 1;
+ public static final int POINT_TYPE_COMPROMISED = 2;
+
private static final int DEFAULT_CAPACITY = GestureStrokeWithPreviewPoints.PREVIEW_CAPACITY;
// These three {@link ResizableIntArray}s should be synchronized by {@link #mEventTimes}.
private final ResizableIntArray mXCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
private final ResizableIntArray mYCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
private final ResizableIntArray mEventTimes = new ResizableIntArray(DEFAULT_CAPACITY);
+ private final ResizableIntArray mPointTypes = new ResizableIntArray(
+ DBG_SHOW_POINTS ? DEFAULT_CAPACITY : 0);
private int mCurrentStrokeId = -1;
// The wall time of the zero value in {@link #mEventTimes}
private long mCurrentTimeBase;
@@ -125,7 +133,7 @@ final class GesturePreviewTrail {
final int lastInterpolatedIndex = (strokeId == mCurrentStrokeId)
? mLastInterpolatedDrawIndex : trailSize;
mLastInterpolatedDrawIndex = stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(
- lastInterpolatedIndex, mEventTimes, mXCoordinates, mYCoordinates);
+ lastInterpolatedIndex, mEventTimes, mXCoordinates, mYCoordinates, mPointTypes);
if (strokeId != mCurrentStrokeId) {
final int elapsedTime = (int)(downTime - mCurrentTimeBase);
for (int i = mTrailStartIndex; i < trailSize; i++) {
@@ -204,6 +212,7 @@ final class GesturePreviewTrail {
final int[] eventTimes = mEventTimes.getPrimitiveArray();
final int[] xCoords = mXCoordinates.getPrimitiveArray();
final int[] yCoords = mYCoordinates.getPrimitiveArray();
+ final int[] pointTypes = mPointTypes.getPrimitiveArray();
final int sinceDown = (int)(SystemClock.uptimeMillis() - mCurrentTimeBase);
int startIndex;
for (startIndex = mTrailStartIndex; startIndex < trailSize; startIndex++) {
@@ -246,6 +255,17 @@ final class GesturePreviewTrail {
final int alpha = getAlpha(elapsedTime, params);
paint.setAlpha(alpha);
canvas.drawPath(path, paint);
+ if (DBG_SHOW_POINTS) {
+ if (pointTypes[i] == POINT_TYPE_INTERPOLATED) {
+ paint.setColor(Color.RED);
+ } else if (pointTypes[i] == POINT_TYPE_SAMPLED) {
+ paint.setColor(Color.BLUE);
+ } else {
+ paint.setColor(Color.GREEN);
+ }
+ canvas.drawCircle(p1x - 1, p1y - 1, 2, paint);
+ paint.setColor(params.mTrailColor);
+ }
}
}
p1x = p2x;
@@ -265,6 +285,7 @@ final class GesturePreviewTrail {
mEventTimes.setLength(newSize);
mXCoordinates.setLength(newSize);
mYCoordinates.setLength(newSize);
+ mPointTypes.setLength(newSize);
// The start index of the last segment of the stroke
// {@link mLastInterpolatedDrawIndex} should also be updated because all array
// elements have just been shifted for compaction or been zeroed.