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

Commit c3f64a3f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix abnormal flicking when swiping up to exit OHM in 3-button mode"

parents cf4b64cf bf64024d
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class OneHandedGestureHandler implements OneHandedTransitionCallback,
    @Nullable
    OneHandedGestureEventCallback mGestureEventCallback;
    private Rect mGestureRegion = new Rect();
    private boolean mIsStopGesture;

    /**
     * Constructor of OneHandedGestureHandler, we only handle the gesture of
@@ -153,20 +154,20 @@ public class OneHandedGestureHandler implements OneHandedTransitionCallback,
                        float distance = (float) Math.hypot(mLastPos.x - mDownPos.x,
                                mLastPos.y - mDownPos.y);
                        if (distance > mDragDistThreshold) {
                            mGestureEventCallback.onStop();
                            mIsStopGesture = true;
                        }
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    if (mLastPos.y >= mDownPos.y && mPassedSlop) {
                        mGestureEventCallback.onStart();
                    } else if (mIsStopGesture) {
                        mGestureEventCallback.onStop();
                    }
                    mPassedSlop = false;
                    mAllowGesture = false;
                    clearState();
                    break;
                case MotionEvent.ACTION_CANCEL:
                    mPassedSlop = false;
                    mAllowGesture = false;
                    clearState();
                    break;
                default:
                    break;
@@ -174,6 +175,11 @@ public class OneHandedGestureHandler implements OneHandedTransitionCallback,
        }
    }

    private void clearState() {
        mPassedSlop = false;
        mIsStopGesture = false;
    }

    private void disposeInputChannel() {
        if (mInputEventReceiver != null) {
            mInputEventReceiver.dispose();