summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-06-14 10:03:59 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-06-14 10:03:59 -0700
commit52d3465d0503a3362ec9335ae3de8e23b2ae75a3 (patch)
tree8ccf149b2706449eca7b0f90278766f917f881ce /services/java/com
parent8385adc9600c63bc2d55d6d745eec4d018e0ed0f (diff)
parent95068e5d1bea47091e97955f271c789264994550 (diff)
downloadframeworks_base-52d3465d0503a3362ec9335ae3de8e23b2ae75a3.zip
frameworks_base-52d3465d0503a3362ec9335ae3de8e23b2ae75a3.tar.gz
frameworks_base-52d3465d0503a3362ec9335ae3de8e23b2ae75a3.tar.bz2
Merge "If a gesture cannot be detected the device should transition to touch exploration state." into jb-dev
Diffstat (limited to 'services/java/com')
-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 {