From b2f5d1525093e66faa4a46d6cf10c0144fca2041 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 10 Jan 2013 10:34:20 +0900 Subject: [PATCH] Cancel update batch input timer only when point is added Bug: 7972004 Change-Id: Ie5db5910efba851976da2284cafc69be2910d354 --- .../inputmethod/keyboard/PointerTracker.java | 5 ++++- .../keyboard/internal/GestureStroke.java | 18 +++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 62e674ad5..036372c37 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -920,8 +920,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element { final boolean isMajorEvent, final Key key) { final int gestureTime = (int)(eventTime - sGestureFirstDownTime); if (mIsDetectingGesture) { + final int beforeLength = mGestureStrokeWithPreviewPoints.getLength(); final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard( x, y, gestureTime, isMajorEvent); + if (mGestureStrokeWithPreviewPoints.getLength() > beforeLength) { + mTimerProxy.startUpdateBatchInputTimer(this); + } // If the move event goes out from valid batch input area, cancel batch input. if (!onValidArea) { cancelBatchInput(); @@ -943,7 +947,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (DEBUG_MOVE_EVENT) { printTouchEvent("onMoveEvent:", x, y, eventTime); } - mTimerProxy.cancelUpdateBatchInputTimer(this); if (mIsTrackingCanceled) { return; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java index adf223602..ea03f1bd7 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java @@ -163,6 +163,10 @@ public class GestureStroke { } } + public int getLength() { + return mEventTimes.getLength(); + } + public void onDownEvent(final int x, final int y, final long downTime, final long gestureFirstDownTime, final long lastTypingTime) { reset(); @@ -202,7 +206,7 @@ public class GestureStroke { if (!hasDetectedFastMove()) { return false; } - final int size = mEventTimes.getLength(); + final int size = getLength(); if (size <= 0) { return false; } @@ -229,7 +233,7 @@ public class GestureStroke { } public void duplicateLastPointWith(final int time) { - final int lastIndex = mEventTimes.getLength() - 1; + final int lastIndex = getLength() - 1; if (lastIndex >= 0) { final int x = mXCoordinates.get(lastIndex); final int y = mYCoordinates.get(lastIndex); @@ -255,7 +259,7 @@ public class GestureStroke { } private void appendPoint(final int x, final int y, final int time) { - final int lastIndex = mEventTimes.getLength() - 1; + final int lastIndex = getLength() - 1; // The point that is created by {@link duplicateLastPointWith(int)} may have later event // time than the next {@link MotionEvent}. To maintain the monotonicity of the event time, // drop the successive point here. @@ -281,7 +285,7 @@ public class GestureStroke { } private int detectFastMove(final int x, final int y, final int time) { - final int size = mEventTimes.getLength(); + final int size = getLength(); final int lastIndex = size - 1; final int lastX = mXCoordinates.get(lastIndex); final int lastY = mYCoordinates.get(lastIndex); @@ -321,7 +325,7 @@ public class GestureStroke { */ public boolean addPointOnKeyboard(final int x, final int y, final int time, final boolean isMajorEvent) { - final int size = mEventTimes.getLength(); + final int size = getLength(); if (size <= 0) { // Down event appendPoint(x, y, time); @@ -348,7 +352,7 @@ public class GestureStroke { final int pixelsPerSec = pixels * MSEC_PER_SEC; // Equivalent to (pixels / msecs < mGestureRecognitionThreshold / MSEC_PER_SEC) if (pixelsPerSec < mGestureRecognitionSpeedThreshold * msecs) { - mIncrementalRecognitionSize = mEventTimes.getLength(); + mIncrementalRecognitionSize = getLength(); } } @@ -358,7 +362,7 @@ public class GestureStroke { } public final void appendAllBatchPoints(final InputPointers out) { - appendBatchPoints(out, mEventTimes.getLength()); + appendBatchPoints(out, getLength()); } public final void appendIncrementalBatchPoints(final InputPointers out) {