Add new orientation attribute to GestureOverlayView. This can be used to prevent the overlay from interfering with vertically/horizontally scrolling views underneath the overlay.
diff --git a/api/current.xml b/api/current.xml
index 8140589..bb1f871 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -46799,6 +46799,17 @@
visibility="public"
>
</method>
+<method name="getOrientation"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getUncertainGestureColor"
return="int"
abstract="false"
@@ -47008,6 +47019,19 @@
<parameter name="gestureStrokeWidth" type="float">
</parameter>
</method>
+<method name="setOrientation"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="orientation" type="int">
+</parameter>
+</method>
<method name="setUncertainGestureColor"
return="void"
abstract="false"
@@ -47043,6 +47067,28 @@
visibility="public"
>
</field>
+<field name="ORIENTATION_HORIZONTAL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ORIENTATION_VERTICAL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
</class>
<interface name="GestureOverlayView.OnGestureListener"
abstract="true"
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index 4cdbd3e..1a82095 100755
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -53,6 +53,9 @@
public static final int GESTURE_STROKE_TYPE_SINGLE = 0;
public static final int GESTURE_STROKE_TYPE_MULTIPLE = 1;
+ public static final int ORIENTATION_HORIZONTAL = 0;
+ public static final int ORIENTATION_VERTICAL = 1;
+
private static final int FADE_ANIMATION_RATE = 16;
private static final boolean GESTURE_RENDERING_ANTIALIAS = true;
private static final boolean DITHER_FLAG = true;
@@ -76,6 +79,8 @@
private float mGestureStrokeSquarenessTreshold = 0.275f;
private float mGestureStrokeAngleThreshold = 40.0f;
+ private int mOrientation = ORIENTATION_VERTICAL;
+
private final Rect mInvalidRect = new Rect();
private final Path mPath = new Path();
@@ -150,6 +155,7 @@
mInterceptEvents);
mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled,
mFadeEnabled);
+ mOrientation = a.getInt(R.styleable.GestureOverlayView_orientation, mOrientation);
a.recycle();
@@ -176,6 +182,14 @@
return mStrokeBuffer;
}
+ public int getOrientation() {
+ return mOrientation;
+ }
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ }
+
public void setGestureColor(int color) {
mCertainGestureColor = color;
}
@@ -415,7 +429,7 @@
private boolean processEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
- touchStart(event);
+ touchDown(event);
invalidate();
return true;
case MotionEvent.ACTION_MOVE:
@@ -445,7 +459,7 @@
return false;
}
- private void touchStart(MotionEvent event) {
+ private void touchDown(MotionEvent event) {
mIsListeningForGestures = true;
float x = event.getX();
@@ -548,7 +562,9 @@
}
if (box.squareness > mGestureStrokeSquarenessTreshold ||
- angle < mGestureStrokeAngleThreshold) {
+ (mOrientation == ORIENTATION_VERTICAL ?
+ angle < mGestureStrokeAngleThreshold :
+ angle > mGestureStrokeAngleThreshold)) {
mIsGesturing = true;
setCurrentColor(mCertainGestureColor);
@@ -606,7 +622,7 @@
actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
mCurrentGesture);
}
- }
+ }
private class FadeOutRunnable implements Runnable {
boolean fireActionPerformed;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index b54802b..cda7431 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2109,6 +2109,9 @@
<attr name="eventsInterceptionEnabled" format="boolean" />
<!-- Defines whether the gesture will automatically fade out after being recognized. -->
<attr name="fadeEnabled" format="boolean" />
+ <!-- Indicates whether horizontal (when the orientation is vertical) or vertical
+ (when orientation is horizontal) strokes automatically define a gesture. -->
+ <attr name="orientation" />
</declare-styleable>
<!-- ======================================= -->