diff options
author | Romain Guy <romainguy@android.com> | 2009-05-25 04:39:37 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-05-25 04:39:37 -0700 |
commit | ec25df9fbc685be384f8dd764fa224a4d923e9d8 (patch) | |
tree | 3d8c42a50b2286c7dc032f111da52971ff31cb99 /core/java/android/gesture | |
parent | ff686ce11e952a9001b1384d8e7d82127b0529a2 (diff) | |
download | frameworks_base-ec25df9fbc685be384f8dd764fa224a4d923e9d8.zip frameworks_base-ec25df9fbc685be384f8dd764fa224a4d923e9d8.tar.gz frameworks_base-ec25df9fbc685be384f8dd764fa224a4d923e9d8.tar.bz2 |
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.
Diffstat (limited to 'core/java/android/gesture')
-rwxr-xr-x | core/java/android/gesture/GestureOverlayView.java | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java index 3476e4d..4cdbd3e 100755 --- a/core/java/android/gesture/GestureOverlayView.java +++ b/core/java/android/gesture/GestureOverlayView.java @@ -40,6 +40,7 @@ import java.util.ArrayList; * @attr ref android.R.styleable#GestureOverlayView_eventsInterceptionEnabled * @attr ref android.R.styleable#GestureOverlayView_fadeDuration * @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_gestureStrokeAngleThreshold * @attr ref android.R.styleable#GestureOverlayView_gestureStrokeLengthThreshold @@ -62,6 +63,7 @@ public class GestureOverlayView extends FrameLayout { private long mFadeOffset = 420; private long mFadingStart; private boolean mFadingHasStarted; + private boolean mFadeEnabled = true; private int mCurrentColor; private int mCertainGestureColor = 0xFFFFFF00; @@ -146,6 +148,8 @@ public class GestureOverlayView extends FrameLayout { mGestureStrokeSquarenessTreshold); mInterceptEvents = a.getBoolean(R.styleable.GestureOverlayView_eventsInterceptionEnabled, mInterceptEvents); + mFadeEnabled = a.getBoolean(R.styleable.GestureOverlayView_fadeEnabled, + mFadeEnabled); a.recycle(); @@ -238,6 +242,14 @@ public class GestureOverlayView extends FrameLayout { mInterceptEvents = enabled; } + public boolean isFadeEnabled() { + return mFadeEnabled; + } + + public void setFadeEnabled(boolean fadeEnabled) { + mFadeEnabled = fadeEnabled; + } + public Gesture getGesture() { return mCurrentGesture; } @@ -329,12 +341,14 @@ public class GestureOverlayView extends FrameLayout { private void clear(boolean animated, boolean fireActionPerformed) { setPaintAlpha(255); if (animated && mCurrentGesture != null) { - mFadingAlpha = 1.0f; - mIsFadingOut = true; - mFadingHasStarted = false; - mFadingOut.fireActionPerformed = fireActionPerformed; - removeCallbacks(mFadingOut); - mFadingStart = AnimationUtils.currentAnimationTimeMillis() + mFadeOffset; + if (mFadeEnabled) { + mFadingAlpha = 1.0f; + mIsFadingOut = true; + mFadingHasStarted = false; + mFadingOut.fireActionPerformed = fireActionPerformed; + removeCallbacks(mFadingOut); + mFadingStart = AnimationUtils.currentAnimationTimeMillis() + mFadeOffset; + } postDelayed(mFadingOut, mFadeOffset); } else { mPath.rewind(); @@ -584,6 +598,16 @@ public class GestureOverlayView extends FrameLayout { 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 { boolean fireActionPerformed; @@ -594,13 +618,7 @@ public class GestureOverlayView extends FrameLayout { if (duration > mFadeDuration) { if (fireActionPerformed) { - final ArrayList<OnGesturePerformedListener> actionListeners = - mOnGesturePerformedListeners; - final int count = actionListeners.size(); - for (int i = 0; i < count; i++) { - actionListeners.get(i).onGesturePerformed(GestureOverlayView.this, - mCurrentGesture); - } + fireOnGesturePerformed(); } mIsFadingOut = false; @@ -618,6 +636,14 @@ public class GestureOverlayView extends FrameLayout { } invalidate(); + } else if (!mFadeEnabled) { + fireOnGesturePerformed(); + + mIsFadingOut = false; + mFadingHasStarted = false; + mPath.rewind(); + mCurrentGesture = null; + setPaintAlpha(255); } } } |