Add new orientation attribute to GestureOverlayView. This can be used to prevent the overlay from interfering with vertically/horizontally scrolling views underneath the overlay.
This commit is contained in:
@@ -46799,6 +46799,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</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"
|
<method name="getUncertainGestureColor"
|
||||||
return="int"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -47008,6 +47019,19 @@
|
|||||||
<parameter name="gestureStrokeWidth" type="float">
|
<parameter name="gestureStrokeWidth" type="float">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</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"
|
<method name="setUncertainGestureColor"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -47043,6 +47067,28 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</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>
|
</class>
|
||||||
<interface name="GestureOverlayView.OnGestureListener"
|
<interface name="GestureOverlayView.OnGestureListener"
|
||||||
abstract="true"
|
abstract="true"
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
public static final int GESTURE_STROKE_TYPE_SINGLE = 0;
|
public static final int GESTURE_STROKE_TYPE_SINGLE = 0;
|
||||||
public static final int GESTURE_STROKE_TYPE_MULTIPLE = 1;
|
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 int FADE_ANIMATION_RATE = 16;
|
||||||
private static final boolean GESTURE_RENDERING_ANTIALIAS = true;
|
private static final boolean GESTURE_RENDERING_ANTIALIAS = true;
|
||||||
private static final boolean DITHER_FLAG = true;
|
private static final boolean DITHER_FLAG = true;
|
||||||
@@ -76,6 +79,8 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
private float mGestureStrokeSquarenessTreshold = 0.275f;
|
private float mGestureStrokeSquarenessTreshold = 0.275f;
|
||||||
private float mGestureStrokeAngleThreshold = 40.0f;
|
private float mGestureStrokeAngleThreshold = 40.0f;
|
||||||
|
|
||||||
|
private int mOrientation = ORIENTATION_VERTICAL;
|
||||||
|
|
||||||
private final Rect mInvalidRect = new Rect();
|
private final Rect mInvalidRect = new Rect();
|
||||||
private final Path mPath = new Path();
|
private final Path mPath = new Path();
|
||||||
|
|
||||||
@@ -150,6 +155,7 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
mInterceptEvents);
|
mInterceptEvents);
|
||||||
mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled,
|
mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled,
|
||||||
mFadeEnabled);
|
mFadeEnabled);
|
||||||
|
mOrientation = a.getInt(R.styleable.GestureOverlayView_orientation, mOrientation);
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
@@ -176,6 +182,14 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
return mStrokeBuffer;
|
return mStrokeBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOrientation() {
|
||||||
|
return mOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrientation(int orientation) {
|
||||||
|
mOrientation = orientation;
|
||||||
|
}
|
||||||
|
|
||||||
public void setGestureColor(int color) {
|
public void setGestureColor(int color) {
|
||||||
mCertainGestureColor = color;
|
mCertainGestureColor = color;
|
||||||
}
|
}
|
||||||
@@ -415,7 +429,7 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
private boolean processEvent(MotionEvent event) {
|
private boolean processEvent(MotionEvent event) {
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
touchStart(event);
|
touchDown(event);
|
||||||
invalidate();
|
invalidate();
|
||||||
return true;
|
return true;
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
@@ -445,7 +459,7 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void touchStart(MotionEvent event) {
|
private void touchDown(MotionEvent event) {
|
||||||
mIsListeningForGestures = true;
|
mIsListeningForGestures = true;
|
||||||
|
|
||||||
float x = event.getX();
|
float x = event.getX();
|
||||||
@@ -548,7 +562,9 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (box.squareness > mGestureStrokeSquarenessTreshold ||
|
if (box.squareness > mGestureStrokeSquarenessTreshold ||
|
||||||
angle < mGestureStrokeAngleThreshold) {
|
(mOrientation == ORIENTATION_VERTICAL ?
|
||||||
|
angle < mGestureStrokeAngleThreshold :
|
||||||
|
angle > mGestureStrokeAngleThreshold)) {
|
||||||
|
|
||||||
mIsGesturing = true;
|
mIsGesturing = true;
|
||||||
setCurrentColor(mCertainGestureColor);
|
setCurrentColor(mCertainGestureColor);
|
||||||
@@ -606,7 +622,7 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
|
actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
|
||||||
mCurrentGesture);
|
mCurrentGesture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FadeOutRunnable implements Runnable {
|
private class FadeOutRunnable implements Runnable {
|
||||||
boolean fireActionPerformed;
|
boolean fireActionPerformed;
|
||||||
|
|||||||
@@ -2109,6 +2109,9 @@
|
|||||||
<attr name="eventsInterceptionEnabled" format="boolean" />
|
<attr name="eventsInterceptionEnabled" format="boolean" />
|
||||||
<!-- Defines whether the gesture will automatically fade out after being recognized. -->
|
<!-- Defines whether the gesture will automatically fade out after being recognized. -->
|
||||||
<attr name="fadeEnabled" format="boolean" />
|
<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>
|
</declare-styleable>
|
||||||
|
|
||||||
<!-- ======================================= -->
|
<!-- ======================================= -->
|
||||||
|
|||||||
Reference in New Issue
Block a user