summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-06-13 21:01:51 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-06-13 21:14:16 -0700
commit95068e5d1bea47091e97955f271c789264994550 (patch)
tree66cdc8a3ca4aa9e02af8d158458b3a7b231f1104
parent4365d066e8beed17b61ba51c728d60a9baa499be (diff)
downloadframeworks_base-95068e5d1bea47091e97955f271c789264994550.zip
frameworks_base-95068e5d1bea47091e97955f271c789264994550.tar.gz
frameworks_base-95068e5d1bea47091e97955f271c789264994550.tar.bz2
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
-rw-r--r--services/java/com/android/server/accessibility/TouchExplorer.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java
index a36c673..a8296f8 100644
--- a/services/java/com/android/server/accessibility/TouchExplorer.java
+++ b/services/java/com/android/server/accessibility/TouchExplorer.java
@@ -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: {
@@ -1263,6 +1273,25 @@ public class TouchExplorer {
}
/**
+ * 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.
*/
private final class PerformLongPressDelayed implements Runnable {