From f0e83046f022b5594f98aef07fbda7f2f837f262 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 13 Sep 2012 12:38:08 +0900 Subject: [PATCH] Show gesture floating preview text at oldest finger Bug: 7119032 Change-Id: Iddb26ba1a595e472fde0982d744b5652d5fbda3e --- .../com/android/inputmethod/keyboard/KeyboardView.java | 5 +++-- .../com/android/inputmethod/keyboard/PointerTracker.java | 9 +++++---- .../keyboard/internal/PointerTrackerQueue.java | 4 ++++ .../inputmethod/keyboard/internal/PreviewPlacerView.java | 8 +++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 27c3cc3e3..cf89567f8 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -855,9 +855,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } @Override - public void showGesturePreviewTrail(final PointerTracker tracker) { + public void showGesturePreviewTrail(final PointerTracker tracker, + final boolean isOldestTracker) { locatePreviewPlacerView(); - mPreviewPlacerView.invalidatePointer(tracker); + mPreviewPlacerView.invalidatePointer(tracker, isOldestTracker); } @Override diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 4887ac557..e762b23c6 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -80,7 +80,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { public void invalidateKey(Key key); public void showKeyPreview(PointerTracker tracker); public void dismissKeyPreview(PointerTracker tracker); - public void showGesturePreviewTrail(PointerTracker tracker); + public void showGesturePreviewTrail(PointerTracker tracker, boolean isOldestTracker); } public interface TimerProxy { @@ -550,7 +550,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { } sInGesture = true; mListener.onStartBatchInput(); - mDrawingProxy.showGesturePreviewTrail(this); + mDrawingProxy.showGesturePreviewTrail(this, true /* isOldestTracker */); } private void updateBatchInput(final long eventTime) { @@ -567,7 +567,8 @@ public class PointerTracker implements PointerTrackerQueue.Element { mListener.onUpdateBatchInput(sAggregratedPointers); } } - mDrawingProxy.showGesturePreviewTrail(this); + final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this; + mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker); } private void endBatchInput() { @@ -584,7 +585,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { clearBatchInputPointsOfAllPointerTrackers(); } } - mDrawingProxy.showGesturePreviewTrail(this); + mDrawingProxy.showGesturePreviewTrail(this, true /* isOldestTracker */); } private static void abortBatchInput() { diff --git a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java index e0858c019..c1a5cbead 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java @@ -73,6 +73,10 @@ public class PointerTrackerQueue { mArraySize = newSize; } + public synchronized Element getOldestElement() { + return (mArraySize == 0) ? null : mExpandableArrayOfActivePointers.get(0); + } + public synchronized void releaseAllPointersOlderThan(final Element pointer, final long eventTime) { if (DEBUG) { diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java index 7104e3a12..3a850096f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java @@ -188,7 +188,7 @@ public class PreviewPlacerView extends RelativeLayout { mDrawsGestureFloatingPreviewText = drawsGestureFloatingPreviewText; } - public void invalidatePointer(final PointerTracker tracker) { + public void invalidatePointer(final PointerTracker tracker, final boolean isOldestTracker) { GesturePreviewTrail trail; synchronized (mGesturePreviewTrails) { trail = mGesturePreviewTrails.get(tracker.mPointerId); @@ -199,8 +199,10 @@ public class PreviewPlacerView extends RelativeLayout { } trail.addStroke(tracker.getGestureStrokeWithPreviewTrail(), tracker.getDownTime()); - mLastPointerX = tracker.getLastX(); - mLastPointerY = tracker.getLastY(); + if (isOldestTracker) { + mLastPointerX = tracker.getLastX(); + mLastPointerY = tracker.getLastY(); + } // TODO: Should narrow the invalidate region. invalidate(); }