If a gesture cannot be detected the device should transition to touch exploration state.
1. We are deciding whether the user is performing a gesture or an exploration based on the gesture velocity. If we are detecting gesture we do the recognition at the gesture end which is when the finger goes up. This is better than having a mode toggle gesture for exploring and gestures detection. However, it is possible that the user really wanted to perform an exploration but was moving too fast and unless he lifts his finger the device is in gesture detection mode. This is frustrating since the user has no feedback and assumes exploration does not work. We want to perform gesture detection only for a maximal time frame and if the user did not lift his finger we transition into touch exploration state. bug:6663173 Change-Id: I954ff937cca902e31b51325d1e1dfce84d239624
This commit is contained in:
@@ -98,6 +98,9 @@ public class TouchExplorer {
|
||||
// the two dragging pointers as opposed to use the location of the primary one.
|
||||
private static final int MIN_POINTER_DISTANCE_TO_USE_MIDDLE_LOCATION_DIP = 200;
|
||||
|
||||
// The timeout after which we are no longer trying to detect a gesture.
|
||||
private static final int EXIT_GESTURE_DETECTION_TIMEOUT = 2000;
|
||||
|
||||
// Temporary array for storing pointer IDs.
|
||||
private final int[] mTempPointerIds = new int[MAX_POINTER_COUNT];
|
||||
|
||||
@@ -138,6 +141,9 @@ public class TouchExplorer {
|
||||
// Command for delayed sending of a long press.
|
||||
private final PerformLongPressDelayed mPerformLongPressDelayed;
|
||||
|
||||
// Command for exiting gesture detection mode after a timeout.
|
||||
private final ExitGestureDetectionModeDelayed mExitGestureDetectionModeDelayed;
|
||||
|
||||
// Helper to detect and react to double tap in touch explore mode.
|
||||
private final DoubleTapDetector mDoubleTapDetector;
|
||||
|
||||
@@ -212,6 +218,7 @@ public class TouchExplorer {
|
||||
mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop();
|
||||
mHandler = new Handler(context.getMainLooper());
|
||||
mPerformLongPressDelayed = new PerformLongPressDelayed();
|
||||
mExitGestureDetectionModeDelayed = new ExitGestureDetectionModeDelayed();
|
||||
mGestureLibrary = GestureLibraries.fromRawResource(context, R.raw.accessibility_gestures);
|
||||
mGestureLibrary.setOrientationStyle(4);
|
||||
mGestureLibrary.load();
|
||||
@@ -257,6 +264,7 @@ public class TouchExplorer {
|
||||
mSendHoverEnterDelayed.remove();
|
||||
mSendHoverExitDelayed.remove();
|
||||
mPerformLongPressDelayed.remove();
|
||||
mExitGestureDetectionModeDelayed.remove();
|
||||
// Reset the pointer trackers.
|
||||
mReceivedPointerTracker.clear();
|
||||
mInjectedPointerTracker.clear();
|
||||
@@ -420,6 +428,7 @@ public class TouchExplorer {
|
||||
mSendHoverEnterDelayed.remove();
|
||||
mSendHoverExitDelayed.remove();
|
||||
mPerformLongPressDelayed.remove();
|
||||
mExitGestureDetectionModeDelayed.post();
|
||||
} else {
|
||||
// We have just decided that the user is touch,
|
||||
// exploring so start sending events.
|
||||
@@ -727,6 +736,7 @@ public class TouchExplorer {
|
||||
}
|
||||
|
||||
mStrokeBuffer.clear();
|
||||
mExitGestureDetectionModeDelayed.remove();
|
||||
mCurrentState = STATE_TOUCH_EXPLORING;
|
||||
} break;
|
||||
case MotionEvent.ACTION_CANCEL: {
|
||||
@@ -1262,6 +1272,25 @@ public class TouchExplorer {
|
||||
return Integer.bitCount(pointerState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for delayed exiting from gesture detecting mode.
|
||||
*/
|
||||
private final class ExitGestureDetectionModeDelayed implements Runnable {
|
||||
|
||||
public void post() {
|
||||
mHandler.postDelayed(this, EXIT_GESTURE_DETECTION_TIMEOUT);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
mHandler.removeCallbacks(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for delayed sending of long press.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user