Merge "Tweaks to NotificationPanel animation"
diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java
index 4418e02..88c9155 100644
--- a/graphics/java/android/graphics/drawable/ColorDrawable.java
+++ b/graphics/java/android/graphics/drawable/ColorDrawable.java
@@ -111,8 +111,11 @@
alpha += alpha >> 7; // make it 0..256
int baseAlpha = mState.mBaseColor >>> 24;
int useAlpha = baseAlpha * alpha >> 8;
+ int oldUseColor = mState.mUseColor;
mState.mUseColor = (mState.mBaseColor << 8 >>> 8) | (useAlpha << 24);
- invalidateSelf();
+ if (oldUseColor != mState.mUseColor) {
+ invalidateSelf();
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
index d9cb4e8..4a1cafd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
@@ -28,6 +28,10 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.DecelerateInterpolator;
+import android.view.animation.Interpolator;
import android.widget.RelativeLayout;
import com.android.systemui.R;
@@ -52,6 +56,8 @@
ViewGroup mContentParent;
TabletStatusBar mBar;
View mClearButton;
+ static Interpolator sAccelerateInterpolator = new AccelerateInterpolator();
+ static Interpolator sDecelerateInterpolator = new DecelerateInterpolator();
// amount to slide mContentParent down by when mContentFrame is missing
float mContentFrameMissingTranslation;
@@ -117,8 +123,13 @@
mShowing = show;
if (show) {
setVisibility(View.VISIBLE);
+ // Don't start the animation until we've created the layer, which is done
+ // right before we are drawn
+ mContentParent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
+ } else {
+ mChoreo.startAnimation(show);
}
- mChoreo.startAnimation(show);
}
} else {
mShowing = show;
@@ -127,6 +138,20 @@
}
/**
+ * This is used only when we've created a hardware layer and are waiting until it's
+ * been created in order to start the appearing animation.
+ */
+ private ViewTreeObserver.OnPreDrawListener mPreDrawListener =
+ new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ getViewTreeObserver().removeOnPreDrawListener(this);
+ mChoreo.startAnimation(true);
+ return true;
+ }
+ };
+
+ /**
* Whether the panel is showing, or, if it's animating, whether it will be
* when the animation is done.
*/
@@ -330,8 +355,8 @@
AnimatorSet mContentAnim;
// should group this into a multi-property animation
- final static int OPEN_DURATION = 300;
- final static int CLOSE_DURATION = 300;
+ final static int OPEN_DURATION = 250;
+ final static int CLOSE_DURATION = 250;
// the panel will start to appear this many px from the end
final int HYPERSPACE_OFFRAMP = 200;
@@ -362,19 +387,15 @@
Animator posAnim = ObjectAnimator.ofFloat(mContentParent, "translationY",
start, end);
- posAnim.setInterpolator(appearing
- ? new android.view.animation.DecelerateInterpolator(1.0f)
- : new android.view.animation.AccelerateInterpolator(1.0f));
+ posAnim.setInterpolator(appearing ? sDecelerateInterpolator : sAccelerateInterpolator);
if (mContentAnim != null && mContentAnim.isRunning()) {
mContentAnim.cancel();
}
Animator fadeAnim = ObjectAnimator.ofFloat(mContentParent, "alpha",
- mContentParent.getAlpha(), appearing ? 1.0f : 0.0f);
- fadeAnim.setInterpolator(appearing
- ? new android.view.animation.AccelerateInterpolator(2.0f)
- : new android.view.animation.DecelerateInterpolator(2.0f));
+ appearing ? 1.0f : 0.0f);
+ fadeAnim.setInterpolator(appearing ? sAccelerateInterpolator : sDecelerateInterpolator);
mContentAnim = new AnimatorSet();
mContentAnim
@@ -389,8 +410,6 @@
if (DEBUG) Slog.d(TAG, "startAnimation(appearing=" + appearing + ")");
createAnimation(appearing);
-
- mContentParent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mContentAnim.start();
mVisible = appearing;