Merge "[DO NOT MERGE] Transition to clear state after gesture cancelation." into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ae2d666dc7
@@ -104,9 +104,9 @@ class GestureManifold implements GestureMatcher.StateChangeListener {
|
|||||||
// Shared state information.
|
// Shared state information.
|
||||||
private TouchState mState;
|
private TouchState mState;
|
||||||
|
|
||||||
GestureManifold(Context context, Listener listener, TouchState state) {
|
GestureManifold(Context context, Listener listener, TouchState state, Handler handler) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mHandler = new Handler(context.getMainLooper());
|
mHandler = handler;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mState = state;
|
mState = state;
|
||||||
mMultiFingerGesturesEnabled = false;
|
mMultiFingerGesturesEnabled = false;
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
|
|||||||
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
|
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
|
||||||
mDetermineUserIntentTimeout);
|
mDetermineUserIntentTimeout);
|
||||||
if (detector == null) {
|
if (detector == null) {
|
||||||
mGestureDetector = new GestureManifold(context, this, mState);
|
mGestureDetector = new GestureManifold(context, this, mState, mHandler);
|
||||||
} else {
|
} else {
|
||||||
mGestureDetector = detector;
|
mGestureDetector = detector;
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,6 @@ public class TouchExplorer extends BaseEventStreamTransformation
|
|||||||
public boolean onGestureStarted() {
|
public boolean onGestureStarted() {
|
||||||
// We have to perform gesture detection, so
|
// We have to perform gesture detection, so
|
||||||
// clear the current state and try to detect.
|
// clear the current state and try to detect.
|
||||||
mState.startGestureDetecting();
|
|
||||||
mSendHoverEnterAndMoveDelayed.cancel();
|
mSendHoverEnterAndMoveDelayed.cancel();
|
||||||
mSendHoverExitDelayed.cancel();
|
mSendHoverExitDelayed.cancel();
|
||||||
mExitGestureDetectionModeDelayed.post();
|
mExitGestureDetectionModeDelayed.post();
|
||||||
@@ -1107,7 +1106,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldPerformGestureDetection(MotionEvent event) {
|
private boolean shouldPerformGestureDetection(MotionEvent event) {
|
||||||
if (mState.isDelegating()) {
|
if (mState.isDelegating() || mState.isDragging()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||||
@@ -1200,6 +1199,15 @@ public class TouchExplorer extends BaseEventStreamTransformation
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (mReceivedPointerTracker.getReceivedPointerDownCount() > 1) {
|
||||||
|
// Multi-finger touch exploration doesn't make sense.
|
||||||
|
Slog.e(
|
||||||
|
LOG_TAG,
|
||||||
|
"Attempted touch exploration with "
|
||||||
|
+ mReceivedPointerTracker.getReceivedPointerDownCount()
|
||||||
|
+ " pointers down.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Send an accessibility event to announce the touch exploration start.
|
// Send an accessibility event to announce the touch exploration start.
|
||||||
mDispatcher.sendAccessibilityEvent(
|
mDispatcher.sendAccessibilityEvent(
|
||||||
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
|
AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
|
||||||
|
|||||||
@@ -208,7 +208,9 @@ public class TouchState {
|
|||||||
startGestureDetecting();
|
startGestureDetecting();
|
||||||
break;
|
break;
|
||||||
case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
|
case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
|
||||||
startTouchInteracting();
|
// Clear to make sure that we don't accidentally execute passthrough, and that we
|
||||||
|
// are ready for the next interaction.
|
||||||
|
clear();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.accessibilityservice.AccessibilityService;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.os.Handler;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
@@ -56,7 +57,8 @@ public class GestureManifoldTest {
|
|||||||
// Construct a testable GestureManifold.
|
// Construct a testable GestureManifold.
|
||||||
mResultListener = mock(GestureManifold.Listener.class);
|
mResultListener = mock(GestureManifold.Listener.class);
|
||||||
mState = new TouchState();
|
mState = new TouchState();
|
||||||
mManifold = new GestureManifold(context, mResultListener, mState);
|
Handler handler = new Handler(context.getMainLooper());
|
||||||
|
mManifold = new GestureManifold(context, mResultListener, mState, handler);
|
||||||
// Play the role of touch explorer in updating the shared state.
|
// Play the role of touch explorer in updating the shared state.
|
||||||
when(mResultListener.onGestureStarted()).thenReturn(onGestureStarted());
|
when(mResultListener.onGestureStarted()).thenReturn(onGestureStarted());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user