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

Commit e08dd586 authored by Jason Chang's avatar Jason Chang
Browse files

Fix abnormal flicking when swiping up to exit OHM

Defer the action of onStopGestureDetected() from ACTION_MOVE
to ACTION_UP in OneHandedInputConsumer.

Bug: 171307756

Test: manual
Change-Id: Ie4a3cb0ba4477c131191a7ed1cf4daec2d364285
parent f8d7e342
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
    private final PointF mLastPos = new PointF();
    private final PointF mLastPos = new PointF();


    private boolean mPassedSlop;
    private boolean mPassedSlop;
    private boolean mIsStopGesture;


    public OneHandedModeInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
    public OneHandedModeInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
            InputConsumer delegate, InputMonitorCompat inputMonitor) {
            InputConsumer delegate, InputMonitorCompat inputMonitor) {
@@ -105,7 +106,7 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
                    float distance = (float) Math.hypot(mLastPos.x - mDownPos.x,
                    float distance = (float) Math.hypot(mLastPos.x - mDownPos.x,
                            mLastPos.y - mDownPos.y);
                            mLastPos.y - mDownPos.y);
                    if (distance > mDragDistThreshold && mPassedSlop) {
                    if (distance > mDragDistThreshold && mPassedSlop) {
                        onStopGestureDetected();
                        mIsStopGesture = true;
                    }
                    }
                }
                }
                break;
                break;
@@ -113,15 +114,14 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
            case ACTION_UP: {
            case ACTION_UP: {
                if (mLastPos.y >= mDownPos.y && mPassedSlop) {
                if (mLastPos.y >= mDownPos.y && mPassedSlop) {
                    onStartGestureDetected();
                    onStartGestureDetected();
                } else if (mIsStopGesture) {
                    onStopGestureDetected();
                }
                }

                clearState();
                mPassedSlop = false;
                mState = STATE_INACTIVE;
                break;
                break;
            }
            }
            case ACTION_CANCEL:
            case ACTION_CANCEL:
                mPassedSlop = false;
                clearState();
                mState = STATE_INACTIVE;
                break;
                break;
        }
        }


@@ -130,6 +130,12 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
        }
        }
    }
    }


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

    private void onStartGestureDetected() {
    private void onStartGestureDetected() {
        if (mDeviceState.isOneHandedModeEnabled()) {
        if (mDeviceState.isOneHandedModeEnabled()) {
            if (!mDeviceState.isOneHandedModeActive()) {
            if (!mDeviceState.isOneHandedModeActive()) {