diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java index 0bb8fff2a1..22bd334517 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java @@ -52,7 +52,6 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer { private final PointF mDownPos = new PointF(); private final PointF mLastPos = new PointF(); - private final PointF mStartDragPos = new PointF(); private boolean mPassedSlop; @@ -92,7 +91,6 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer { if (!mPassedSlop) { if (squaredHypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSquaredSlop) { - mStartDragPos.set(mLastPos.x, mLastPos.y); if ((!mDeviceState.isOneHandedModeActive() && isValidStartAngle( mDownPos.x - mLastPos.x, mDownPos.y - mLastPos.y)) || (mDeviceState.isOneHandedModeActive() && isValidExitAngle( @@ -104,17 +102,16 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer { } } } else { - float distance = (float) Math.hypot(mLastPos.x - mStartDragPos.x, - mLastPos.y - mStartDragPos.y); + float distance = (float) Math.hypot(mLastPos.x - mDownPos.x, + mLastPos.y - mDownPos.y); if (distance > mDragDistThreshold && mPassedSlop) { onStopGestureDetected(); } } break; } - case ACTION_UP: - case ACTION_CANCEL: { - if (mLastPos.y >= mStartDragPos.y && mPassedSlop) { + case ACTION_UP: { + if (mLastPos.y >= mDownPos.y && mPassedSlop) { onStartGestureDetected(); } @@ -122,6 +119,10 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer { mState = STATE_INACTIVE; break; } + case ACTION_CANCEL: + mPassedSlop = false; + mState = STATE_INACTIVE; + break; } if (mState != STATE_ACTIVE) { diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index 2868b1b37c..716887509d 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -79,6 +79,8 @@ public class RecentsAnimationDeviceState implements DefaultDisplay.DisplayInfoChangeListener, OneHandedModeChangeListener { + static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode"; + private final Context mContext; private final SysUINavigationMode mSysUiNavMode; private final DefaultDisplay mDefaultDisplay; @@ -165,13 +167,15 @@ public class RecentsAnimationDeviceState implements } } - if (SystemProperties.getBoolean("ro.support_one_handed_mode", false)) { + if (SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) { SecureSettingsObserver oneHandedEnabledObserver = SecureSettingsObserver.newOneHandedSettingsObserver( mContext, enabled -> mIsOneHandedModeEnabled = enabled); oneHandedEnabledObserver.register(); oneHandedEnabledObserver.dispatchOnChange(); runOnDestroy(oneHandedEnabledObserver::unregister); + } else { + mIsOneHandedModeEnabled = false; } SecureSettingsObserver swipeBottomEnabledObserver = @@ -443,7 +447,7 @@ public class RecentsAnimationDeviceState implements } /** - * @return whether screen pinning is enabled and active + * @return whether one-handed mode is enabled and active */ public boolean isOneHandedModeActive() { return (mSystemUiStateFlags & SYSUI_STATE_ONE_HANDED_ACTIVE) != 0; @@ -518,6 +522,10 @@ public class RecentsAnimationDeviceState implements * @return whether the given motion event can trigger the one handed mode. */ public boolean canTriggerOneHandedAction(MotionEvent ev) { + if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) { + return false; + } + if (!mIsOneHandedModeEnabled && !mIsSwipeToNotificationEnabled) { return false; }