Fix drawing bug: opaque invalidations should not be taken into account when the invalidated view is animating. Also add the ability to disable the auto-fade on the GestureOverlayView.
This commit is contained in:
@ -3518,17 +3518,6 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="donut_resource_pad33"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="16843391"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="donut_resource_pad4"
|
<field name="donut_resource_pad4"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
@ -4035,6 +4024,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="fadeEnabled"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="16843391"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="fadeOffset"
|
<field name="fadeOffset"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
@ -46821,6 +46821,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="isFadeEnabled"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
<method name="isGesturing"
|
<method name="isGesturing"
|
||||||
return="boolean"
|
return="boolean"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@ -46893,6 +46904,19 @@
|
|||||||
<parameter name="enabled" type="boolean">
|
<parameter name="enabled" type="boolean">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="setFadeEnabled"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="fadeEnabled" type="boolean">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="setGesture"
|
<method name="setGesture"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
@ -40,6 +40,7 @@ import java.util.ArrayList;
|
|||||||
* @attr ref android.R.styleable#GestureOverlayView_eventsInterceptionEnabled
|
* @attr ref android.R.styleable#GestureOverlayView_eventsInterceptionEnabled
|
||||||
* @attr ref android.R.styleable#GestureOverlayView_fadeDuration
|
* @attr ref android.R.styleable#GestureOverlayView_fadeDuration
|
||||||
* @attr ref android.R.styleable#GestureOverlayView_fadeOffset
|
* @attr ref android.R.styleable#GestureOverlayView_fadeOffset
|
||||||
|
* @attr ref android.R.styleable#GestureOverlayView_fadeEnabled
|
||||||
* @attr ref android.R.styleable#GestureOverlayView_gestureStrokeWidth
|
* @attr ref android.R.styleable#GestureOverlayView_gestureStrokeWidth
|
||||||
* @attr ref android.R.styleable#GestureOverlayView_gestureStrokeAngleThreshold
|
* @attr ref android.R.styleable#GestureOverlayView_gestureStrokeAngleThreshold
|
||||||
* @attr ref android.R.styleable#GestureOverlayView_gestureStrokeLengthThreshold
|
* @attr ref android.R.styleable#GestureOverlayView_gestureStrokeLengthThreshold
|
||||||
@ -62,6 +63,7 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
private long mFadeOffset = 420;
|
private long mFadeOffset = 420;
|
||||||
private long mFadingStart;
|
private long mFadingStart;
|
||||||
private boolean mFadingHasStarted;
|
private boolean mFadingHasStarted;
|
||||||
|
private boolean mFadeEnabled = true;
|
||||||
|
|
||||||
private int mCurrentColor;
|
private int mCurrentColor;
|
||||||
private int mCertainGestureColor = 0xFFFFFF00;
|
private int mCertainGestureColor = 0xFFFFFF00;
|
||||||
@ -146,6 +148,8 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
mGestureStrokeSquarenessTreshold);
|
mGestureStrokeSquarenessTreshold);
|
||||||
mInterceptEvents = a.getBoolean(R.styleable.GestureOverlayView_eventsInterceptionEnabled,
|
mInterceptEvents = a.getBoolean(R.styleable.GestureOverlayView_eventsInterceptionEnabled,
|
||||||
mInterceptEvents);
|
mInterceptEvents);
|
||||||
|
mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled,
|
||||||
|
mFadeEnabled);
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
@ -238,6 +242,14 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
mInterceptEvents = enabled;
|
mInterceptEvents = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFadeEnabled() {
|
||||||
|
return mFadeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFadeEnabled(boolean fadeEnabled) {
|
||||||
|
mFadeEnabled = fadeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public Gesture getGesture() {
|
public Gesture getGesture() {
|
||||||
return mCurrentGesture;
|
return mCurrentGesture;
|
||||||
}
|
}
|
||||||
@ -329,12 +341,14 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
private void clear(boolean animated, boolean fireActionPerformed) {
|
private void clear(boolean animated, boolean fireActionPerformed) {
|
||||||
setPaintAlpha(255);
|
setPaintAlpha(255);
|
||||||
if (animated && mCurrentGesture != null) {
|
if (animated && mCurrentGesture != null) {
|
||||||
|
if (mFadeEnabled) {
|
||||||
mFadingAlpha = 1.0f;
|
mFadingAlpha = 1.0f;
|
||||||
mIsFadingOut = true;
|
mIsFadingOut = true;
|
||||||
mFadingHasStarted = false;
|
mFadingHasStarted = false;
|
||||||
mFadingOut.fireActionPerformed = fireActionPerformed;
|
mFadingOut.fireActionPerformed = fireActionPerformed;
|
||||||
removeCallbacks(mFadingOut);
|
removeCallbacks(mFadingOut);
|
||||||
mFadingStart = AnimationUtils.currentAnimationTimeMillis() + mFadeOffset;
|
mFadingStart = AnimationUtils.currentAnimationTimeMillis() + mFadeOffset;
|
||||||
|
}
|
||||||
postDelayed(mFadingOut, mFadeOffset);
|
postDelayed(mFadingOut, mFadeOffset);
|
||||||
} else {
|
} else {
|
||||||
mPath.rewind();
|
mPath.rewind();
|
||||||
@ -584,6 +598,16 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
mIsGesturing = false;
|
mIsGesturing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fireOnGesturePerformed() {
|
||||||
|
final ArrayList<OnGesturePerformedListener> actionListeners =
|
||||||
|
mOnGesturePerformedListeners;
|
||||||
|
final int count = actionListeners.size();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
|
||||||
|
mCurrentGesture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class FadeOutRunnable implements Runnable {
|
private class FadeOutRunnable implements Runnable {
|
||||||
boolean fireActionPerformed;
|
boolean fireActionPerformed;
|
||||||
|
|
||||||
@ -594,13 +618,7 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
|
|
||||||
if (duration > mFadeDuration) {
|
if (duration > mFadeDuration) {
|
||||||
if (fireActionPerformed) {
|
if (fireActionPerformed) {
|
||||||
final ArrayList<OnGesturePerformedListener> actionListeners =
|
fireOnGesturePerformed();
|
||||||
mOnGesturePerformedListeners;
|
|
||||||
final int count = actionListeners.size();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
|
|
||||||
mCurrentGesture);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsFadingOut = false;
|
mIsFadingOut = false;
|
||||||
@ -618,6 +636,14 @@ public class GestureOverlayView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
} else if (!mFadeEnabled) {
|
||||||
|
fireOnGesturePerformed();
|
||||||
|
|
||||||
|
mIsFadingOut = false;
|
||||||
|
mFadingHasStarted = false;
|
||||||
|
mPath.rewind();
|
||||||
|
mCurrentGesture = null;
|
||||||
|
setPaintAlpha(255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2351,7 +2351,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
final boolean drawAnimation = (child.mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION;
|
final boolean drawAnimation = (child.mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION;
|
||||||
|
|
||||||
// Check whether the child that requests the invalidate is fully opaque
|
// Check whether the child that requests the invalidate is fully opaque
|
||||||
final boolean isOpaque = child.isOpaque();
|
final boolean isOpaque = child.isOpaque() && !drawAnimation &&
|
||||||
|
child.getAnimation() != null;
|
||||||
// Mark the child as dirty, using the appropriate flag
|
// Mark the child as dirty, using the appropriate flag
|
||||||
// Make sure we do not set both flags at the same time
|
// Make sure we do not set both flags at the same time
|
||||||
final int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY;
|
final int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY;
|
||||||
|
@ -2107,6 +2107,8 @@
|
|||||||
<!-- Defines whether the overlay should intercept the motion events when a gesture
|
<!-- Defines whether the overlay should intercept the motion events when a gesture
|
||||||
is recognized. -->
|
is recognized. -->
|
||||||
<attr name="eventsInterceptionEnabled" format="boolean" />
|
<attr name="eventsInterceptionEnabled" format="boolean" />
|
||||||
|
<!-- Defines whether the gesture will automatically fade out after being recognized. -->
|
||||||
|
<attr name="fadeEnabled" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<!-- ======================================= -->
|
<!-- ======================================= -->
|
||||||
|
@ -1112,6 +1112,7 @@
|
|||||||
<public type="attr" name="gestureStrokeSquarenessThreshold" />
|
<public type="attr" name="gestureStrokeSquarenessThreshold" />
|
||||||
<public type="attr" name="gestureStrokeAngleThreshold" />
|
<public type="attr" name="gestureStrokeAngleThreshold" />
|
||||||
<public type="attr" name="eventsInterceptionEnabled" />
|
<public type="attr" name="eventsInterceptionEnabled" />
|
||||||
|
<public type="attr" name="fadeEnabled" />
|
||||||
|
|
||||||
<public-padding type="attr" name="donut_resource_pad" end="0x0101029f" />
|
<public-padding type="attr" name="donut_resource_pad" end="0x0101029f" />
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user