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

Commit fa1b3bd0 authored by Andy Wickham's avatar Andy Wickham Committed by Android (Google) Code Review
Browse files

Merge "Improve touch finished logging" into main

parents 01563248 cad2f1ed
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -56,5 +56,5 @@ public class NavHandleLongPressHandler implements ResourceBasedOverride {
     * Called when nav handle gesture is finished by the user lifting their finger or the system
     * cancelling the touch for some other reason.
     */
    public void onTouchFinished() {}
    public void onTouchFinished(String reason) {}
}
+6 −5
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
        if (mDelegate.allowInterceptByParent()) {
            handleMotionEvent(ev);
        } else if (MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress)) {
            cancelLongPress();
            cancelLongPress("intercept disallowed by child input consumer");
        }

        if (mState != STATE_ACTIVE) {
@@ -113,10 +113,11 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
                float dy = ev.getY() - mCurrentDownEvent.getY();
                double distanceSquared = (dx * dx) + (dy * dy);
                if (distanceSquared > touchSlopSquared) {
                    cancelLongPress();
                    cancelLongPress("touch slop passed");
                }
            }
            case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> cancelLongPress();
            case MotionEvent.ACTION_UP -> cancelLongPress("touch action up");
            case MotionEvent.ACTION_CANCEL -> cancelLongPress("touch action cancel");
        }

        // If the gesture is deep press then trigger long press asap
@@ -158,9 +159,9 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
        }
    }

    private void cancelLongPress() {
    private void cancelLongPress(String reason) {
        MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
        mNavHandleLongPressHandler.onTouchFinished();
        mNavHandleLongPressHandler.onTouchFinished(reason);
    }

    private boolean isInNavBarHorizontalArea(float x) {