am e7c36dda
: Add new orientation attribute to GestureOverlayView. This can be used to prevent the overlay from interfering with vertically/horizontally scrolling views underneath the overlay.
Merge commit 'e7c36dda7ada30e02f3aa9d75f282a53402aeae7' * commit 'e7c36dda7ada30e02f3aa9d75f282a53402aeae7': 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:
committed by
The Android Open Source Project
commit
a788bf9207
@ -49975,6 +49975,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"
|
||||
@ -50184,6 +50195,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"
|
||||
@ -50219,6 +50243,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"
|
||||
|
@ -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_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 @@ public class GestureOverlayView extends FrameLayout {
|
||||
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 @@ public class GestureOverlayView extends FrameLayout {
|
||||
mInterceptEvents);
|
||||
mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled,
|
||||
mFadeEnabled);
|
||||
mOrientation = a.getInt(R.styleable.GestureOverlayView_orientation, mOrientation);
|
||||
|
||||
a.recycle();
|
||||
|
||||
@ -176,6 +182,14 @@ public class GestureOverlayView extends FrameLayout {
|
||||
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 @@ public class GestureOverlayView extends FrameLayout {
|
||||
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 @@ public class GestureOverlayView extends FrameLayout {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void touchStart(MotionEvent event) {
|
||||
private void touchDown(MotionEvent event) {
|
||||
mIsListeningForGestures = true;
|
||||
|
||||
float x = event.getX();
|
||||
@ -548,7 +562,9 @@ public class GestureOverlayView extends FrameLayout {
|
||||
}
|
||||
|
||||
if (box.squareness > mGestureStrokeSquarenessTreshold ||
|
||||
angle < mGestureStrokeAngleThreshold) {
|
||||
(mOrientation == ORIENTATION_VERTICAL ?
|
||||
angle < mGestureStrokeAngleThreshold :
|
||||
angle > mGestureStrokeAngleThreshold)) {
|
||||
|
||||
mIsGesturing = true;
|
||||
setCurrentColor(mCertainGestureColor);
|
||||
@ -606,7 +622,7 @@ public class GestureOverlayView extends FrameLayout {
|
||||
actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
|
||||
mCurrentGesture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class FadeOutRunnable implements Runnable {
|
||||
boolean fireActionPerformed;
|
||||
|
@ -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>
|
||||
|
||||
<!-- ======================================= -->
|
||||
|
Reference in New Issue
Block a user