Merge "Tweaks to NotificationPanel animation"
This commit is contained in:
@@ -111,8 +111,11 @@ public class ColorDrawable extends Drawable {
|
|||||||
alpha += alpha >> 7; // make it 0..256
|
alpha += alpha >> 7; // make it 0..256
|
||||||
int baseAlpha = mState.mBaseColor >>> 24;
|
int baseAlpha = mState.mBaseColor >>> 24;
|
||||||
int useAlpha = baseAlpha * alpha >> 8;
|
int useAlpha = baseAlpha * alpha >> 8;
|
||||||
|
int oldUseColor = mState.mUseColor;
|
||||||
mState.mUseColor = (mState.mBaseColor << 8 >>> 8) | (useAlpha << 24);
|
mState.mUseColor = (mState.mBaseColor << 8 >>> 8) | (useAlpha << 24);
|
||||||
invalidateSelf();
|
if (oldUseColor != mState.mUseColor) {
|
||||||
|
invalidateSelf();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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 android.widget.RelativeLayout;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -52,6 +56,8 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
|
|||||||
ViewGroup mContentParent;
|
ViewGroup mContentParent;
|
||||||
TabletStatusBar mBar;
|
TabletStatusBar mBar;
|
||||||
View mClearButton;
|
View mClearButton;
|
||||||
|
static Interpolator sAccelerateInterpolator = new AccelerateInterpolator();
|
||||||
|
static Interpolator sDecelerateInterpolator = new DecelerateInterpolator();
|
||||||
|
|
||||||
// amount to slide mContentParent down by when mContentFrame is missing
|
// amount to slide mContentParent down by when mContentFrame is missing
|
||||||
float mContentFrameMissingTranslation;
|
float mContentFrameMissingTranslation;
|
||||||
@@ -117,8 +123,13 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
|
|||||||
mShowing = show;
|
mShowing = show;
|
||||||
if (show) {
|
if (show) {
|
||||||
setVisibility(View.VISIBLE);
|
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 {
|
} else {
|
||||||
mShowing = show;
|
mShowing = show;
|
||||||
@@ -126,6 +137,20 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Whether the panel is showing, or, if it's animating, whether it will be
|
||||||
* when the animation is done.
|
* when the animation is done.
|
||||||
@@ -330,8 +355,8 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
|
|||||||
AnimatorSet mContentAnim;
|
AnimatorSet mContentAnim;
|
||||||
|
|
||||||
// should group this into a multi-property animation
|
// should group this into a multi-property animation
|
||||||
final static int OPEN_DURATION = 300;
|
final static int OPEN_DURATION = 250;
|
||||||
final static int CLOSE_DURATION = 300;
|
final static int CLOSE_DURATION = 250;
|
||||||
|
|
||||||
// the panel will start to appear this many px from the end
|
// the panel will start to appear this many px from the end
|
||||||
final int HYPERSPACE_OFFRAMP = 200;
|
final int HYPERSPACE_OFFRAMP = 200;
|
||||||
@@ -362,19 +387,15 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
|
|||||||
|
|
||||||
Animator posAnim = ObjectAnimator.ofFloat(mContentParent, "translationY",
|
Animator posAnim = ObjectAnimator.ofFloat(mContentParent, "translationY",
|
||||||
start, end);
|
start, end);
|
||||||
posAnim.setInterpolator(appearing
|
posAnim.setInterpolator(appearing ? sDecelerateInterpolator : sAccelerateInterpolator);
|
||||||
? new android.view.animation.DecelerateInterpolator(1.0f)
|
|
||||||
: new android.view.animation.AccelerateInterpolator(1.0f));
|
|
||||||
|
|
||||||
if (mContentAnim != null && mContentAnim.isRunning()) {
|
if (mContentAnim != null && mContentAnim.isRunning()) {
|
||||||
mContentAnim.cancel();
|
mContentAnim.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
Animator fadeAnim = ObjectAnimator.ofFloat(mContentParent, "alpha",
|
Animator fadeAnim = ObjectAnimator.ofFloat(mContentParent, "alpha",
|
||||||
mContentParent.getAlpha(), appearing ? 1.0f : 0.0f);
|
appearing ? 1.0f : 0.0f);
|
||||||
fadeAnim.setInterpolator(appearing
|
fadeAnim.setInterpolator(appearing ? sAccelerateInterpolator : sDecelerateInterpolator);
|
||||||
? new android.view.animation.AccelerateInterpolator(2.0f)
|
|
||||||
: new android.view.animation.DecelerateInterpolator(2.0f));
|
|
||||||
|
|
||||||
mContentAnim = new AnimatorSet();
|
mContentAnim = new AnimatorSet();
|
||||||
mContentAnim
|
mContentAnim
|
||||||
@@ -389,8 +410,6 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
|
|||||||
if (DEBUG) Slog.d(TAG, "startAnimation(appearing=" + appearing + ")");
|
if (DEBUG) Slog.d(TAG, "startAnimation(appearing=" + appearing + ")");
|
||||||
|
|
||||||
createAnimation(appearing);
|
createAnimation(appearing);
|
||||||
|
|
||||||
mContentParent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
||||||
mContentAnim.start();
|
mContentAnim.start();
|
||||||
|
|
||||||
mVisible = appearing;
|
mVisible = appearing;
|
||||||
|
|||||||
Reference in New Issue
Block a user