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

This commit is contained in:
TreeHugger Robot
2020-12-12 04:10:21 +00:00
committed by Android (Google) Code Review

View File

@@ -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();