Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84c1bbd7 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Move PointerTracker.MIN_GESTURE_RECOGNITION_TIME to GestureStroke" into jb-mr1-dev

parents 49d080f0 f80f09c7
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -47,8 +47,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
    private static boolean sGestureHandlingEnabledByInputField = false;
    private static boolean sGestureHandlingEnabledByUser = false;

    private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec

    public interface KeyEventHandler {
        /**
         * Get KeyDetector object that is used for this PointerTracker.
@@ -562,7 +560,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
            mGestureStrokeWithPreviewPoints.appendIncrementalBatchPoints(sAggregratedPointers);
            final int size = sAggregratedPointers.getPointerSize();
            if (size > sLastRecognitionPointSize
                    && eventTime > sLastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME) {
                    && GestureStroke.hasRecognitionTimePast(eventTime, sLastRecognitionTime)) {
                sLastRecognitionPointSize = size;
                sLastRecognitionTime = eventTime;
                if (DEBUG_LISTENER) {
+10 −3
Original line number Diff line number Diff line
@@ -36,10 +36,16 @@ public class GestureStroke {

    // TODO: Move some of these to resource.
    private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
    private static final int MIN_GESTURE_DURATION = 100; // msec
    private static final int MIN_GESTURE_START_DURATION = 100; // msec
    private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
    private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f;
    private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec

    public static final boolean hasRecognitionTimePast(
            final long currentTime, final long lastRecognitionTime) {
        return currentTime > lastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME;
    }

    public GestureStroke(final int pointerId) {
        mPointerId = pointerId;
    }
@@ -53,7 +59,7 @@ public class GestureStroke {
    public boolean isStartOfAGesture() {
        final int size = mEventTimes.getLength();
        final int downDuration = (size > 0) ? mEventTimes.get(size - 1) : 0;
        return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
        return downDuration > MIN_GESTURE_START_DURATION && mLength > mMinGestureLength;
    }

    public void reset() {
@@ -97,7 +103,8 @@ public class GestureStroke {
        if (!isHistorical) {
            final int duration = (int)(time - mLastPointTime);
            if (mLastPointTime != 0 && duration > 0) {
                final float speed = getDistance(mLastPointX, mLastPointY, x, y) / duration;
                final float distance = getDistance(mLastPointX, mLastPointY, x, y);
                final float speed = distance / duration;
                if (speed < GESTURE_RECOG_SPEED_THRESHOLD) {
                    mIncrementalRecognitionSize = size;
                }