summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java92
1 files changed, 63 insertions, 29 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 02b9378..7b60307 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -43,6 +43,7 @@ import android.view.animation.LinearInterpolator;
import android.view.animation.PathInterpolator;
import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.NotificationPanelView;
/**
* Base class for both {@link ExpandableNotificationRow} and {@link NotificationOverflowContainer}
@@ -53,6 +54,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
private static final long DOUBLETAP_TIMEOUT_MS = 1200;
private static final int BACKGROUND_ANIMATION_LENGTH_MS = 220;
private static final int ACTIVATE_ANIMATION_LENGTH = 220;
+ private static final int DARK_ANIMATION_LENGTH = 170;
/**
* The amount of width, which is kept in the end when performing a disappear animation (also
@@ -84,6 +86,11 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
*/
private static final float VERTICAL_ANIMATION_START = 1.0f;
+ /**
+ * Scale for the background to animate from when exiting dark mode.
+ */
+ private static final float DARK_EXIT_SCALE_START = 0.93f;
+
private static final Interpolator ACTIVATE_INVERSE_INTERPOLATOR
= new PathInterpolator(0.6f, 0, 0.5f, 1);
private static final Interpolator ACTIVATE_INVERSE_ALPHA_INTERPOLATOR
@@ -94,7 +101,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
private boolean mDimmed;
private boolean mDark;
- private final Paint mDarkPaint = createDarkPaint();
private int mBgTint = 0;
private final int mRoundedRectCornerRadius;
@@ -332,40 +338,32 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
if (mDimmed != dimmed) {
mDimmed = dimmed;
if (fade) {
- fadeBackground();
+ fadeDimmedBackground();
} else {
updateBackground();
}
}
}
- public void setDark(boolean dark, boolean fade) {
- // TODO implement fade
- if (mDark != dark) {
- mDark = dark;
- if (mDark) {
- setLayerType(View.LAYER_TYPE_HARDWARE, mDarkPaint);
+ public void setDark(boolean dark, boolean fade, long delay) {
+ super.setDark(dark, fade, delay);
+ if (mDark == dark) {
+ return;
+ }
+ mDark = dark;
+ if (!dark && fade) {
+ if (mActivated) {
+ mBackgroundDimmed.setVisibility(View.VISIBLE);
+ mBackgroundNormal.setVisibility(View.VISIBLE);
} else {
- setLayerType(View.LAYER_TYPE_NONE, null);
+ mBackgroundDimmed.setVisibility(View.VISIBLE);
+ mBackgroundNormal.setVisibility(View.INVISIBLE);
}
+ fadeDarkToDimmed(delay);
+ } else {
+ updateBackground();
}
- }
-
- private static Paint createDarkPaint() {
- final Paint p = new Paint();
- final float[] invert = {
- -1f, 0f, 0f, 1f, 1f,
- 0f, -1f, 0f, 1f, 1f,
- 0f, 0f, -1f, 1f, 1f,
- 0f, 0f, 0f, 1f, 0f
- };
- final ColorMatrix m = new ColorMatrix(invert);
- final ColorMatrix grayscale = new ColorMatrix();
- grayscale.setSaturation(0);
- m.preConcat(grayscale);
- p.setColorFilter(new ColorMatrixColorFilter(m));
- return p;
- }
+ }
public void setShowingLegacyBackground(boolean showing) {
mShowingLegacyBackground = showing;
@@ -402,7 +400,39 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
mBackgroundNormal.setRippleColor(rippleColor);
}
- private void fadeBackground() {
+ /**
+ * Fades the dimmed background when exiting dark mode.
+ */
+ private void fadeDarkToDimmed(long delay) {
+ mBackgroundDimmed.setAlpha(0f);
+ mBackgroundDimmed.setPivotX(mBackgroundDimmed.getWidth() / 2f);
+ mBackgroundDimmed.setPivotY(getActualHeight() / 2f);
+ mBackgroundDimmed.setScaleX(DARK_EXIT_SCALE_START);
+ mBackgroundDimmed.setScaleY(DARK_EXIT_SCALE_START);
+ mBackgroundDimmed.animate()
+ .alpha(1f)
+ .scaleX(1f)
+ .scaleY(1f)
+ .setDuration(DARK_ANIMATION_LENGTH)
+ .setStartDelay(delay)
+ .setInterpolator(mLinearOutSlowInInterpolator)
+ .setListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ // Jump state if we are cancelled
+ mBackgroundDimmed.setScaleX(1f);
+ mBackgroundDimmed.setScaleY(1f);
+ mBackgroundDimmed.setAlpha(1f);
+ }
+ })
+ .start();
+ }
+
+ /**
+ * Fades the background when the dimmed state changes.
+ */
+ private void fadeDimmedBackground() {
+ mBackgroundDimmed.animate().cancel();
mBackgroundNormal.animate().cancel();
if (mDimmed) {
mBackgroundDimmed.setVisibility(View.VISIBLE);
@@ -443,11 +473,14 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
}
private void updateBackground() {
- if (mDimmed) {
+ cancelFadeAnimations();
+ if (mDark) {
+ mBackgroundDimmed.setVisibility(View.INVISIBLE);
+ mBackgroundNormal.setVisibility(View.INVISIBLE);
+ } else if (mDimmed) {
mBackgroundDimmed.setVisibility(View.VISIBLE);
mBackgroundNormal.setVisibility(View.INVISIBLE);
} else {
- cancelFadeAnimations();
mBackgroundDimmed.setVisibility(View.INVISIBLE);
mBackgroundNormal.setVisibility(View.VISIBLE);
mBackgroundNormal.setAlpha(1f);
@@ -459,6 +492,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
if (mBackgroundAnimator != null) {
mBackgroundAnimator.cancel();
}
+ mBackgroundDimmed.animate().cancel();
mBackgroundNormal.animate().cancel();
}