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

Sync the solution from ag/13127399 to fix flicking problem in
3-button mode.
Defer the action of onStopGestureDetected() from ACTION_MOVE
to ACTION_UP in OneHandedInputConsumer.

Test: manual
Change-Id: I41f9538a8e91eb7fa91e9decc688e740645ac9c1
This commit is contained in:
Jason Chang
2020-12-08 17:10:57 +08:00
parent 7ea661f10c
commit bf64024d56

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