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

Commit cad2f1ed authored by Andreas Agvard's avatar Andreas Agvard
Browse files

Improve touch finished logging

Test: Manual
Bug: 314993218
Flag: N/A
Change-Id: I1cf827ed3125071b722c617c384350b53e57fac5
parent 42476cc3
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) {