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

Commit 8091f226 authored by Michael Wright's avatar Michael Wright Committed by Android Git Automerger
Browse files

am edaf6af1: Merge "Remove tap to click from touch nav devices" into klp-dev

* commit 'edaf6af1':
  Remove tap to click from touch nav devices
parents d13fa001 edaf6af1
Loading
Loading
Loading
Loading
+3 −53
Original line number Original line Diff line number Diff line
@@ -229,7 +229,6 @@ public final class ViewRootImpl implements ViewParent,


    InputStage mFirstInputStage;
    InputStage mFirstInputStage;
    InputStage mFirstPostImeInputStage;
    InputStage mFirstPostImeInputStage;
    SyntheticInputStage mSyntheticInputStage;


    boolean mFlipControllerFallbackKeys;
    boolean mFlipControllerFallbackKeys;


@@ -595,8 +594,8 @@ public final class ViewRootImpl implements ViewParent,


                // Set up the input pipeline.
                // Set up the input pipeline.
                CharSequence counterSuffix = attrs.getTitle();
                CharSequence counterSuffix = attrs.getTitle();
                mSyntheticInputStage = new SyntheticInputStage();
                InputStage syntheticInputStage = new SyntheticInputStage();
                InputStage viewPostImeStage = new ViewPostImeInputStage(mSyntheticInputStage);
                InputStage viewPostImeStage = new ViewPostImeInputStage(syntheticInputStage);
                InputStage nativePostImeStage = new NativePostImeInputStage(viewPostImeStage,
                InputStage nativePostImeStage = new NativePostImeInputStage(viewPostImeStage,
                        "aq:native-post-ime:" + counterSuffix);
                        "aq:native-post-ime:" + counterSuffix);
                InputStage earlyPostImeStage = new EarlyPostImeInputStage(nativePostImeStage);
                InputStage earlyPostImeStage = new EarlyPostImeInputStage(nativePostImeStage);
@@ -3782,9 +3781,6 @@ public final class ViewRootImpl implements ViewParent,
        private int processKeyEvent(QueuedInputEvent q) {
        private int processKeyEvent(QueuedInputEvent q) {
            final KeyEvent event = (KeyEvent)q.mEvent;
            final KeyEvent event = (KeyEvent)q.mEvent;


            // The synthetic stage occasionally needs to know about keys in order to debounce taps
            mSyntheticInputStage.notifyKeyEvent(event);

            // Deliver the key to the view hierarchy.
            // Deliver the key to the view hierarchy.
            if (mView.dispatchKeyEvent(event)) {
            if (mView.dispatchKeyEvent(event)) {
                return FINISH_HANDLED;
                return FINISH_HANDLED;
@@ -3963,10 +3959,6 @@ public final class ViewRootImpl implements ViewParent,
            }
            }
            super.onDeliverToNext(q);
            super.onDeliverToNext(q);
        }
        }

        public void notifyKeyEvent(KeyEvent e) {
            mTouchNavigation.notifyKeyEvent(e);
        }
    }
    }


    /**
    /**
@@ -4394,15 +4386,6 @@ public final class ViewRootImpl implements ViewParent,


        /* TODO: These constants should eventually be moved to ViewConfiguration. */
        /* TODO: These constants should eventually be moved to ViewConfiguration. */


        // Tap timeout in milliseconds.
        private static final int TAP_TIMEOUT = 250;

        // Debounce timeout for touch nav devices with a button under their pad, in milliseconds
        private static final int DEBOUNCE_TIME = 250;

        // The maximum distance traveled for a gesture to be considered a tap in millimeters.
        private static final int TAP_SLOP_MILLIMETERS = 5;

        // The nominal distance traveled to move by one unit.
        // The nominal distance traveled to move by one unit.
        private static final int TICK_DISTANCE_MILLIMETERS = 12;
        private static final int TICK_DISTANCE_MILLIMETERS = 12;


@@ -4430,13 +4413,6 @@ public final class ViewRootImpl implements ViewParent,


        /* Configuration for the current input device. */
        /* Configuration for the current input device. */


        // The tap timeout and scaled slop.
        private int mConfigTapTimeout;
        private float mConfigTapSlop;

        // Amount of time to wait between button presses and tap generation for debouncing
        private int mConfigDebounceTime;

        // The scaled tick distance.  A movement of this amount should generally translate
        // The scaled tick distance.  A movement of this amount should generally translate
        // into a single dpad event in a given direction.
        // into a single dpad event in a given direction.
        private float mConfigTickDistance;
        private float mConfigTickDistance;
@@ -4485,8 +4461,6 @@ public final class ViewRootImpl implements ViewParent,
        // The last time a confirm key was pressed on the touch nav device
        // The last time a confirm key was pressed on the touch nav device
        private long mLastConfirmKeyTime = Long.MAX_VALUE;
        private long mLastConfirmKeyTime = Long.MAX_VALUE;


        private boolean mHasButtonUnderPad;

        public SyntheticTouchNavigationHandler() {
        public SyntheticTouchNavigationHandler() {
            super(true);
            super(true);
        }
        }
@@ -4523,21 +4497,15 @@ public final class ViewRootImpl implements ViewParent,
                        float nominalRes = (xRes + yRes) * 0.5f;
                        float nominalRes = (xRes + yRes) * 0.5f;


                        // Precompute all of the configuration thresholds we will need.
                        // Precompute all of the configuration thresholds we will need.
                        mConfigTapTimeout = TAP_TIMEOUT;
                        mConfigTapSlop = TAP_SLOP_MILLIMETERS * nominalRes;
                        mConfigTickDistance = TICK_DISTANCE_MILLIMETERS * nominalRes;
                        mConfigTickDistance = TICK_DISTANCE_MILLIMETERS * nominalRes;
                        mConfigMinFlingVelocity =
                        mConfigMinFlingVelocity =
                                MIN_FLING_VELOCITY_TICKS_PER_SECOND * mConfigTickDistance;
                                MIN_FLING_VELOCITY_TICKS_PER_SECOND * mConfigTickDistance;
                        mConfigMaxFlingVelocity =
                        mConfigMaxFlingVelocity =
                                MAX_FLING_VELOCITY_TICKS_PER_SECOND * mConfigTickDistance;
                                MAX_FLING_VELOCITY_TICKS_PER_SECOND * mConfigTickDistance;
                        mConfigDebounceTime = DEBOUNCE_TIME;
                        mHasButtonUnderPad = device.hasButtonUnderPad();


                        if (LOCAL_DEBUG) {
                        if (LOCAL_DEBUG) {
                            Log.d(LOCAL_TAG, "Configured device " + mCurrentDeviceId
                            Log.d(LOCAL_TAG, "Configured device " + mCurrentDeviceId
                                    + " (" + Integer.toHexString(mCurrentSource) + "): "
                                    + " (" + Integer.toHexString(mCurrentSource) + "): "
                                    + "mConfigTapTimeout=" + mConfigTapTimeout
                                    + ", mConfigTapSlop=" + mConfigTapSlop
                                    + ", mConfigTickDistance=" + mConfigTickDistance
                                    + ", mConfigTickDistance=" + mConfigTickDistance
                                    + ", mConfigMinFlingVelocity=" + mConfigMinFlingVelocity
                                    + ", mConfigMinFlingVelocity=" + mConfigMinFlingVelocity
                                    + ", mConfigMaxFlingVelocity=" + mConfigMaxFlingVelocity);
                                    + ", mConfigMaxFlingVelocity=" + mConfigMaxFlingVelocity);
@@ -4599,18 +4567,7 @@ public final class ViewRootImpl implements ViewParent,


                    // Detect taps and flings.
                    // Detect taps and flings.
                    if (action == MotionEvent.ACTION_UP) {
                    if (action == MotionEvent.ACTION_UP) {
                        if (!mConsumedMovement
                        if (mConsumedMovement && mPendingKeyCode != KeyEvent.KEYCODE_UNKNOWN) {
                                && Math.hypot(mLastX - mStartX, mLastY - mStartY) < mConfigTapSlop
                                && time <= mStartTime + mConfigTapTimeout) {
                            if (!mHasButtonUnderPad ||
                                        time >= mLastConfirmKeyTime + mConfigDebounceTime) {
                                // It's a tap!
                                finishKeys(time);
                                sendKeyDownOrRepeat(time, KeyEvent.KEYCODE_DPAD_CENTER, metaState);
                                sendKeyUp(time);
                            }
                        } else if (mConsumedMovement
                                && mPendingKeyCode != KeyEvent.KEYCODE_UNKNOWN) {
                            // It might be a fling.
                            // It might be a fling.
                            mVelocityTracker.computeCurrentVelocity(1000, mConfigMaxFlingVelocity);
                            mVelocityTracker.computeCurrentVelocity(1000, mConfigMaxFlingVelocity);
                            final float vx = mVelocityTracker.getXVelocity(mActivePointerId);
                            final float vx = mVelocityTracker.getXVelocity(mActivePointerId);
@@ -4641,13 +4598,6 @@ public final class ViewRootImpl implements ViewParent,
            }
            }
        }
        }


        public void notifyKeyEvent(KeyEvent e) {
            final int keyCode = e.getKeyCode();
            if (KeyEvent.isConfirmKey(e.getKeyCode())) {
                mLastConfirmKeyTime  = e.getDownTime();
            }
        }

        private void finishKeys(long time) {
        private void finishKeys(long time) {
            cancelFling();
            cancelFling();
            sendKeyUp(time);
            sendKeyUp(time);