summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2014-12-08 19:21:26 +0100
committerJorim Jaggi <jjaggi@google.com>2014-12-08 19:24:35 +0100
commitdacc924a65d68e7888d8771baa14141329265ebf (patch)
tree4cbf339ae70b8cf14a7da5984e33e288c3928e80 /packages
parent10ad761aa9e11f33c20e1b0fc3162973c650090f (diff)
downloadframeworks_base-dacc924a65d68e7888d8771baa14141329265ebf.zip
frameworks_base-dacc924a65d68e7888d8771baa14141329265ebf.tar.gz
frameworks_base-dacc924a65d68e7888d8771baa14141329265ebf.tar.bz2
Reinspect notification for dark mode when updated
Also protect against a crash that might happen when the notification is updated during an animation. Bug: 18572620 Change-Id: Ifd6279df395974f7afd0c708a6c87c64de935c62
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java5
3 files changed, 34 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 2934327..914b3d8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -246,6 +246,7 @@ public class NotificationContentView extends FrameLayout {
public void notifyContentUpdated() {
selectLayout(false /* animate */, true /* force */);
if (mContractedChild != null) {
+ mContractedWrapper.notifyContentUpdated();
mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java
index 5b6e1cd..fbcba0b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java
@@ -26,6 +26,7 @@ import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
+import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
@@ -40,17 +41,18 @@ import com.android.systemui.statusbar.phone.NotificationPanelView;
*/
public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
- private final ViewInvertHelper mInvertHelper;
- private final ImageView mIcon;
- protected final ImageView mPicture;
private final ColorMatrix mGrayscaleColorMatrix = new ColorMatrix();
private final PorterDuffColorFilter mIconColorFilter = new PorterDuffColorFilter(
0, PorterDuff.Mode.SRC_ATOP);
private final int mIconDarkAlpha;
- private final int mIconBackgroundColor;
private final int mIconBackgroundDarkColor;
private final Interpolator mLinearOutSlowInInterpolator;
+ private int mIconBackgroundColor;
+ private ViewInvertHelper mInvertHelper;
+ private ImageView mIcon;
+ protected ImageView mPicture;
+
protected NotificationTemplateViewWrapper(Context ctx, View view) {
super(view);
mIconDarkAlpha = ctx.getResources().getInteger(R.integer.doze_small_icon_alpha);
@@ -58,12 +60,16 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
ctx.getResources().getColor(R.color.doze_small_icon_background_color);
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(ctx,
android.R.interpolator.linear_out_slow_in);
- View mainColumn = view.findViewById(com.android.internal.R.id.notification_main_column);
+ resolveViews();
+ }
+
+ private void resolveViews() {
+ View mainColumn = mView.findViewById(com.android.internal.R.id.notification_main_column);
mInvertHelper = mainColumn != null
? new ViewInvertHelper(mainColumn, NotificationPanelView.DOZE_ANIMATION_DURATION)
: null;
- ImageView largeIcon = (ImageView) view.findViewById(com.android.internal.R.id.icon);
- ImageView rightIcon = (ImageView) view.findViewById(com.android.internal.R.id.right_icon);
+ ImageView largeIcon = (ImageView) mView.findViewById(com.android.internal.R.id.icon);
+ ImageView rightIcon = (ImageView) mView.findViewById(com.android.internal.R.id.right_icon);
mIcon = resolveIcon(largeIcon, rightIcon);
mPicture = resolvePicture(largeIcon);
mIconBackgroundColor = resolveBackgroundColor(mIcon);
@@ -92,6 +98,14 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
}
@Override
+ public void notifyContentUpdated() {
+ super.notifyContentUpdated();
+
+ // Reinspect the notification.
+ resolveViews();
+ }
+
+ @Override
public void setDark(boolean dark, boolean fade, long delay) {
if (mInvertHelper != null) {
if (fade) {
@@ -180,7 +194,13 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
private void updateIconColorFilter(ImageView target, float intensity) {
int color = interpolateColor(mIconBackgroundColor, mIconBackgroundDarkColor, intensity);
mIconColorFilter.setColor(color);
- target.getBackground().mutate().setColorFilter(mIconColorFilter);
+ Drawable background = target.getBackground();
+
+ // The notification might have been modified during the animation, so background might be
+ // null here.
+ if (background != null) {
+ background.mutate().setColorFilter(mIconColorFilter);
+ }
}
private void updateIconAlpha(ImageView target, boolean dark) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java
index 0a02573..78b9739 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java
@@ -53,4 +53,9 @@ public abstract class NotificationViewWrapper {
* @param delay if fading, the delay of the animation
*/
public abstract void setDark(boolean dark, boolean fade, long delay);
+
+ /**
+ * Notifies this wrapper that the content of the view might have changed.
+ */
+ public void notifyContentUpdated() {}
}