Loading services/accessibility/java/com/android/server/accessibility/gestures/GestureMatcher.java +21 −13 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.accessibility.gestures; import static com.android.server.accessibility.gestures.TouchExplorer.DEBUG; import android.annotation.IntDef; import android.annotation.NonNull; import android.os.Handler; import android.util.Slog; import android.view.MotionEvent; Loading @@ -31,21 +32,22 @@ import android.view.ViewConfiguration; * onUp, etc methods as necessary. If you don't override a method your matcher will do nothing in * response to that type of event. Finally, be sure to give your gesture a name by overriding * getGestureName(). * @hide */ abstract class GestureMatcher { public abstract class GestureMatcher { // Potential states for this individual gesture matcher. // In STATE_CLEAR, this matcher is accepting new motion events but has not formally signaled // that there is enough data to judge that a gesture has started. static final int STATE_CLEAR = 0; public static final int STATE_CLEAR = 0; // In STATE_GESTURE_STARTED, this matcher continues to accept motion events and it has signaled // to the gesture manifold that what looks like the specified gesture has started. static final int STATE_GESTURE_STARTED = 1; public static final int STATE_GESTURE_STARTED = 1; // In STATE_GESTURE_COMPLETED, this matcher has successfully matched the specified gesture. and // will not accept motion events until it is cleared. static final int STATE_GESTURE_COMPLETED = 2; public static final int STATE_GESTURE_COMPLETED = 2; // In STATE_GESTURE_CANCELED, this matcher will not accept new motion events because it is // impossible that this set of motion events will match the specified gesture. static final int STATE_GESTURE_CANCELED = 3; public static final int STATE_GESTURE_CANCELED = 3; @IntDef({STATE_CLEAR, STATE_GESTURE_STARTED, STATE_GESTURE_COMPLETED, STATE_GESTURE_CANCELED}) public @interface State {} Loading @@ -56,14 +58,14 @@ abstract class GestureMatcher { // handler for asynchronous operations like timeouts private final Handler mHandler; private final StateChangeListener mListener; private StateChangeListener mListener; // Use this to transition to new states after a delay. // e.g. cancel or complete after some timeout. // Convenience functions for tapTimeout and doubleTapTimeout are already defined here. protected final DelayedTransition mDelayedTransition; GestureMatcher(int gestureId, Handler handler, StateChangeListener listener) { protected GestureMatcher(int gestureId, Handler handler, StateChangeListener listener) { mGestureId = gestureId; mHandler = handler; mDelayedTransition = new DelayedTransition(); Loading @@ -75,12 +77,12 @@ abstract class GestureMatcher { * information should override this method to reset their own state information and call * super.clear(). */ protected void clear() { public void clear() { mState = STATE_CLEAR; cancelPendingTransitions(); } public int getState() { public final int getState() { return mState; } Loading @@ -92,8 +94,10 @@ abstract class GestureMatcher { @State int state, MotionEvent event, MotionEvent rawEvent, int policyFlags) { mState = state; cancelPendingTransitions(); if (mListener != null) { mListener.onStateChanged(mGestureId, mState, event, rawEvent, policyFlags); } } /** Indicates that there is evidence to suggest that this gesture has started. */ protected final void startGesture(MotionEvent event, MotionEvent rawEvent, int policyFlags) { Loading @@ -110,6 +114,10 @@ abstract class GestureMatcher { setState(STATE_GESTURE_COMPLETED, event, rawEvent, policyFlags); } public final void setListener(@NonNull StateChangeListener listener) { mListener = listener; } public int getGestureId() { return mGestureId; } Loading Loading @@ -272,7 +280,7 @@ abstract class GestureMatcher { completeAfter(ViewConfiguration.getDoubleTapTimeout(), event, rawEvent, policyFlags); } public static String getStateSymbolicName(@State int state) { static String getStateSymbolicName(@State int state) { switch (state) { case STATE_CLEAR: return "STATE_CLEAR"; Loading @@ -291,7 +299,7 @@ abstract class GestureMatcher { * Returns a readable name for this matcher that can be displayed to the user and in system * logs. */ abstract String getGestureName(); protected abstract String getGestureName(); /** * Returns a String representation of this matcher. Each matcher can override this method to add Loading Loading @@ -363,7 +371,7 @@ abstract class GestureMatcher { } /** Interface to allow a class to listen for state changes in a specific gesture matcher */ interface StateChangeListener { public interface StateChangeListener { void onStateChanged( int gestureId, int state, MotionEvent event, MotionEvent rawEvent, int policyFlags); Loading services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerMultiTap.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ class MultiFingerMultiTap extends GestureMatcher { } @Override protected void clear() { public void clear() { mCompletedTapCount = 0; mIsTargetFingerCountReached = false; for (int i = 0; i < mBases.length; i++) { Loading services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerSwipe.java +2 −2 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ class MultiFingerSwipe extends GestureMatcher { } @Override protected void clear() { public void clear() { mTargetFingerCountReached = false; mCurrentFingerCount = 0; for (int i = 0; i < mTargetFingerCount; ++i) { Loading Loading @@ -489,7 +489,7 @@ class MultiFingerSwipe extends GestureMatcher { } @Override String getGestureName() { protected String getGestureName() { StringBuilder builder = new StringBuilder(); builder.append(mTargetFingerCount).append("-finger "); builder.append("Swipe ").append(directionToString(mDirection)); Loading services/accessibility/java/com/android/server/accessibility/gestures/MultiTap.java +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ class MultiTap extends GestureMatcher { } @Override protected void clear() { public void clear() { mCurrentTaps = 0; mBaseX = Float.NaN; mBaseY = Float.NaN; Loading services/accessibility/java/com/android/server/accessibility/gestures/SecondFingerMultiTap.java +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class SecondFingerMultiTap extends GestureMatcher { } @Override protected void clear() { public void clear() { mCurrentTaps = 0; mBaseX = Float.NaN; mBaseY = Float.NaN; Loading Loading
services/accessibility/java/com/android/server/accessibility/gestures/GestureMatcher.java +21 −13 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.accessibility.gestures; import static com.android.server.accessibility.gestures.TouchExplorer.DEBUG; import android.annotation.IntDef; import android.annotation.NonNull; import android.os.Handler; import android.util.Slog; import android.view.MotionEvent; Loading @@ -31,21 +32,22 @@ import android.view.ViewConfiguration; * onUp, etc methods as necessary. If you don't override a method your matcher will do nothing in * response to that type of event. Finally, be sure to give your gesture a name by overriding * getGestureName(). * @hide */ abstract class GestureMatcher { public abstract class GestureMatcher { // Potential states for this individual gesture matcher. // In STATE_CLEAR, this matcher is accepting new motion events but has not formally signaled // that there is enough data to judge that a gesture has started. static final int STATE_CLEAR = 0; public static final int STATE_CLEAR = 0; // In STATE_GESTURE_STARTED, this matcher continues to accept motion events and it has signaled // to the gesture manifold that what looks like the specified gesture has started. static final int STATE_GESTURE_STARTED = 1; public static final int STATE_GESTURE_STARTED = 1; // In STATE_GESTURE_COMPLETED, this matcher has successfully matched the specified gesture. and // will not accept motion events until it is cleared. static final int STATE_GESTURE_COMPLETED = 2; public static final int STATE_GESTURE_COMPLETED = 2; // In STATE_GESTURE_CANCELED, this matcher will not accept new motion events because it is // impossible that this set of motion events will match the specified gesture. static final int STATE_GESTURE_CANCELED = 3; public static final int STATE_GESTURE_CANCELED = 3; @IntDef({STATE_CLEAR, STATE_GESTURE_STARTED, STATE_GESTURE_COMPLETED, STATE_GESTURE_CANCELED}) public @interface State {} Loading @@ -56,14 +58,14 @@ abstract class GestureMatcher { // handler for asynchronous operations like timeouts private final Handler mHandler; private final StateChangeListener mListener; private StateChangeListener mListener; // Use this to transition to new states after a delay. // e.g. cancel or complete after some timeout. // Convenience functions for tapTimeout and doubleTapTimeout are already defined here. protected final DelayedTransition mDelayedTransition; GestureMatcher(int gestureId, Handler handler, StateChangeListener listener) { protected GestureMatcher(int gestureId, Handler handler, StateChangeListener listener) { mGestureId = gestureId; mHandler = handler; mDelayedTransition = new DelayedTransition(); Loading @@ -75,12 +77,12 @@ abstract class GestureMatcher { * information should override this method to reset their own state information and call * super.clear(). */ protected void clear() { public void clear() { mState = STATE_CLEAR; cancelPendingTransitions(); } public int getState() { public final int getState() { return mState; } Loading @@ -92,8 +94,10 @@ abstract class GestureMatcher { @State int state, MotionEvent event, MotionEvent rawEvent, int policyFlags) { mState = state; cancelPendingTransitions(); if (mListener != null) { mListener.onStateChanged(mGestureId, mState, event, rawEvent, policyFlags); } } /** Indicates that there is evidence to suggest that this gesture has started. */ protected final void startGesture(MotionEvent event, MotionEvent rawEvent, int policyFlags) { Loading @@ -110,6 +114,10 @@ abstract class GestureMatcher { setState(STATE_GESTURE_COMPLETED, event, rawEvent, policyFlags); } public final void setListener(@NonNull StateChangeListener listener) { mListener = listener; } public int getGestureId() { return mGestureId; } Loading Loading @@ -272,7 +280,7 @@ abstract class GestureMatcher { completeAfter(ViewConfiguration.getDoubleTapTimeout(), event, rawEvent, policyFlags); } public static String getStateSymbolicName(@State int state) { static String getStateSymbolicName(@State int state) { switch (state) { case STATE_CLEAR: return "STATE_CLEAR"; Loading @@ -291,7 +299,7 @@ abstract class GestureMatcher { * Returns a readable name for this matcher that can be displayed to the user and in system * logs. */ abstract String getGestureName(); protected abstract String getGestureName(); /** * Returns a String representation of this matcher. Each matcher can override this method to add Loading Loading @@ -363,7 +371,7 @@ abstract class GestureMatcher { } /** Interface to allow a class to listen for state changes in a specific gesture matcher */ interface StateChangeListener { public interface StateChangeListener { void onStateChanged( int gestureId, int state, MotionEvent event, MotionEvent rawEvent, int policyFlags); Loading
services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerMultiTap.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ class MultiFingerMultiTap extends GestureMatcher { } @Override protected void clear() { public void clear() { mCompletedTapCount = 0; mIsTargetFingerCountReached = false; for (int i = 0; i < mBases.length; i++) { Loading
services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerSwipe.java +2 −2 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ class MultiFingerSwipe extends GestureMatcher { } @Override protected void clear() { public void clear() { mTargetFingerCountReached = false; mCurrentFingerCount = 0; for (int i = 0; i < mTargetFingerCount; ++i) { Loading Loading @@ -489,7 +489,7 @@ class MultiFingerSwipe extends GestureMatcher { } @Override String getGestureName() { protected String getGestureName() { StringBuilder builder = new StringBuilder(); builder.append(mTargetFingerCount).append("-finger "); builder.append("Swipe ").append(directionToString(mDirection)); Loading
services/accessibility/java/com/android/server/accessibility/gestures/MultiTap.java +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ class MultiTap extends GestureMatcher { } @Override protected void clear() { public void clear() { mCurrentTaps = 0; mBaseX = Float.NaN; mBaseY = Float.NaN; Loading
services/accessibility/java/com/android/server/accessibility/gestures/SecondFingerMultiTap.java +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class SecondFingerMultiTap extends GestureMatcher { } @Override protected void clear() { public void clear() { mCurrentTaps = 0; mBaseX = Float.NaN; mBaseY = Float.NaN; Loading