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
This commit is contained in:
@@ -54,6 +54,7 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
|
||||
private final PointF mLastPos = new PointF();
|
||||
|
||||
private boolean mPassedSlop;
|
||||
private boolean mIsStopGesture;
|
||||
|
||||
public OneHandedModeInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
|
||||
InputConsumer delegate, InputMonitorCompat inputMonitor) {
|
||||
@@ -105,7 +106,7 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
|
||||
float distance = (float) Math.hypot(mLastPos.x - mDownPos.x,
|
||||
mLastPos.y - mDownPos.y);
|
||||
if (distance > mDragDistThreshold && mPassedSlop) {
|
||||
onStopGestureDetected();
|
||||
mIsStopGesture = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -113,15 +114,14 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
|
||||
case ACTION_UP: {
|
||||
if (mLastPos.y >= mDownPos.y && mPassedSlop) {
|
||||
onStartGestureDetected();
|
||||
} else if (mIsStopGesture) {
|
||||
onStopGestureDetected();
|
||||
}
|
||||
|
||||
mPassedSlop = false;
|
||||
mState = STATE_INACTIVE;
|
||||
clearState();
|
||||
break;
|
||||
}
|
||||
case ACTION_CANCEL:
|
||||
mPassedSlop = false;
|
||||
mState = STATE_INACTIVE;
|
||||
clearState();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,12 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearState() {
|
||||
mPassedSlop = false;
|
||||
mState = STATE_INACTIVE;
|
||||
mIsStopGesture = false;
|
||||
}
|
||||
|
||||
private void onStartGestureDetected() {
|
||||
if (mDeviceState.isOneHandedModeEnabled()) {
|
||||
if (!mDeviceState.isOneHandedModeActive()) {
|
||||
|
||||
Reference in New Issue
Block a user