aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-01-16 17:47:54 +0900
committerTadashi G. Takaoka <takaoka@google.com>2013-01-16 19:51:01 +0900
commit84ce64f2c0255c25d8e697473b3c026d62cbe74d (patch)
tree670704ca291713dafdf132100154d23e6c638535 /java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
parent9579936bcf6bc5cecee315c5e40a30af77f47dfd (diff)
downloadlatinime-84ce64f2c0255c25d8e697473b3c026d62cbe74d.tar.gz
latinime-84ce64f2c0255c25d8e697473b3c026d62cbe74d.tar.xz
latinime-84ce64f2c0255c25d8e697473b3c026d62cbe74d.zip
Fix bounding rectangle of gesture preview trail
Bug: 7917443 Bug: 7987585 Change-Id: I99e6db1fe43d3a9b497e92330a6857e0454c428c
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
index a8407254f..4a8407cb5 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
@@ -138,6 +138,7 @@ final class GesturePreviewTrail {
}
private final RoundedLine mRoundedLine = new RoundedLine();
+ private final Rect mRoundedLineBounds = new Rect();
/**
* Draw gesture preview trail
@@ -149,6 +150,8 @@ final class GesturePreviewTrail {
*/
public boolean drawGestureTrail(final Canvas canvas, final Paint paint,
final Rect outBoundsRect, final Params params) {
+ // Initialize bounds rectangle.
+ outBoundsRect.setEmpty();
final int trailSize = mEventTimes.getLength();
if (trailSize == 0) {
return false;
@@ -171,39 +174,32 @@ final class GesturePreviewTrail {
if (startIndex < trailSize) {
paint.setColor(params.mTrailColor);
paint.setStyle(Paint.Style.FILL);
- final RoundedLine line = mRoundedLine;
+ final RoundedLine roundedLine = mRoundedLine;
int p1x = getXCoordValue(xCoords[startIndex]);
int p1y = yCoords[startIndex];
final int lastTime = sinceDown - eventTimes[startIndex];
- float maxWidth = getWidth(lastTime, params);
- float r1 = maxWidth / 2.0f;
- // Initialize bounds rectangle.
- outBoundsRect.set(p1x, p1y, p1x, p1y);
+ float r1 = getWidth(lastTime, params) / 2.0f;
for (int i = startIndex + 1; i < trailSize; i++) {
final int elapsedTime = sinceDown - eventTimes[i];
final int p2x = getXCoordValue(xCoords[i]);
final int p2y = yCoords[i];
- final float width = getWidth(elapsedTime, params);
- final float r2 = width / 2.0f;
+ final float r2 = getWidth(elapsedTime, params) / 2.0f;
// Draw trail line only when the current point isn't a down point.
if (!isDownEventXCoord(xCoords[i])) {
- final Path path = line.makePath(p1x, p1y, r1, p2x, p2y, r2);
+ final Path path = roundedLine.makePath(p1x, p1y, r1, p2x, p2y, r2);
if (path != null) {
final int alpha = getAlpha(elapsedTime, params);
paint.setAlpha(alpha);
canvas.drawPath(path, paint);
// Take union for the bounds.
- outBoundsRect.union(p2x, p2y);
- maxWidth = Math.max(maxWidth, width);
+ roundedLine.getBounds(mRoundedLineBounds);
+ outBoundsRect.union(mRoundedLineBounds);
}
}
p1x = p2x;
p1y = p2y;
r1 = r2;
}
- // Take care of trail line width.
- final int inset = -((int)maxWidth + 1);
- outBoundsRect.inset(inset, inset);
}
final int newSize = trailSize - startIndex;