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

Commit 0ddc9843 authored by Andreas Agvard's avatar Andreas Agvard Committed by Android (Google) Code Review
Browse files

Merge "NavHandleLongPressInputConsumer now cancels long press detection on intercept." into main

parents d103d230 1fff24df
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -67,6 +67,18 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {

    @Override
    public void onMotionEvent(MotionEvent ev) {
        if (mDelegate.allowInterceptByParent()) {
            handleMotionEvent(ev);
        } else if (MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress)) {
            cancelLongPress();
        }

        if (mState != STATE_ACTIVE) {
            mDelegate.onMotionEvent(ev);
        }
    }

    private void handleMotionEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN -> {
                if (mCurrentDownEvent != null) {
@@ -101,10 +113,6 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
            MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
            MAIN_EXECUTOR.getHandler().post(mTriggerLongPress);
        }

        if (mState != STATE_ACTIVE) {
            mDelegate.onMotionEvent(ev);
        }
    }

    private void triggerLongPress() {