Merge "Reinspect notification for dark mode when updated" into lmp-mr1-dev

This commit is contained in:
Jorim Jaggi
2014-12-09 15:11:20 +00:00
committed by Android (Google) Code Review
3 changed files with 34 additions and 8 deletions

View File

@@ -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 */);
}
}

View File

@@ -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);
@@ -91,6 +97,14 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
return 0;
}
@Override
public void notifyContentUpdated() {
super.notifyContentUpdated();
// Reinspect the notification.
resolveViews();
}
@Override
public void setDark(boolean dark, boolean fade, long delay) {
if (mInvertHelper != null) {
@@ -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) {

View File

@@ -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() {}
}