Merge "Reinspect notification for dark mode when updated" into lmp-mr1-dev
This commit is contained in:
@@ -246,6 +246,7 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
public void notifyContentUpdated() {
|
public void notifyContentUpdated() {
|
||||||
selectLayout(false /* animate */, true /* force */);
|
selectLayout(false /* animate */, true /* force */);
|
||||||
if (mContractedChild != null) {
|
if (mContractedChild != null) {
|
||||||
|
mContractedWrapper.notifyContentUpdated();
|
||||||
mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
|
mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.graphics.ColorMatrix;
|
|||||||
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.ColorMatrixColorFilter;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
@@ -40,17 +41,18 @@ import com.android.systemui.statusbar.phone.NotificationPanelView;
|
|||||||
*/
|
*/
|
||||||
public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
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 ColorMatrix mGrayscaleColorMatrix = new ColorMatrix();
|
||||||
private final PorterDuffColorFilter mIconColorFilter = new PorterDuffColorFilter(
|
private final PorterDuffColorFilter mIconColorFilter = new PorterDuffColorFilter(
|
||||||
0, PorterDuff.Mode.SRC_ATOP);
|
0, PorterDuff.Mode.SRC_ATOP);
|
||||||
private final int mIconDarkAlpha;
|
private final int mIconDarkAlpha;
|
||||||
private final int mIconBackgroundColor;
|
|
||||||
private final int mIconBackgroundDarkColor;
|
private final int mIconBackgroundDarkColor;
|
||||||
private final Interpolator mLinearOutSlowInInterpolator;
|
private final Interpolator mLinearOutSlowInInterpolator;
|
||||||
|
|
||||||
|
private int mIconBackgroundColor;
|
||||||
|
private ViewInvertHelper mInvertHelper;
|
||||||
|
private ImageView mIcon;
|
||||||
|
protected ImageView mPicture;
|
||||||
|
|
||||||
protected NotificationTemplateViewWrapper(Context ctx, View view) {
|
protected NotificationTemplateViewWrapper(Context ctx, View view) {
|
||||||
super(view);
|
super(view);
|
||||||
mIconDarkAlpha = ctx.getResources().getInteger(R.integer.doze_small_icon_alpha);
|
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);
|
ctx.getResources().getColor(R.color.doze_small_icon_background_color);
|
||||||
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(ctx,
|
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(ctx,
|
||||||
android.R.interpolator.linear_out_slow_in);
|
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
|
mInvertHelper = mainColumn != null
|
||||||
? new ViewInvertHelper(mainColumn, NotificationPanelView.DOZE_ANIMATION_DURATION)
|
? new ViewInvertHelper(mainColumn, NotificationPanelView.DOZE_ANIMATION_DURATION)
|
||||||
: null;
|
: null;
|
||||||
ImageView largeIcon = (ImageView) view.findViewById(com.android.internal.R.id.icon);
|
ImageView largeIcon = (ImageView) mView.findViewById(com.android.internal.R.id.icon);
|
||||||
ImageView rightIcon = (ImageView) view.findViewById(com.android.internal.R.id.right_icon);
|
ImageView rightIcon = (ImageView) mView.findViewById(com.android.internal.R.id.right_icon);
|
||||||
mIcon = resolveIcon(largeIcon, rightIcon);
|
mIcon = resolveIcon(largeIcon, rightIcon);
|
||||||
mPicture = resolvePicture(largeIcon);
|
mPicture = resolvePicture(largeIcon);
|
||||||
mIconBackgroundColor = resolveBackgroundColor(mIcon);
|
mIconBackgroundColor = resolveBackgroundColor(mIcon);
|
||||||
@@ -91,6 +97,14 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyContentUpdated() {
|
||||||
|
super.notifyContentUpdated();
|
||||||
|
|
||||||
|
// Reinspect the notification.
|
||||||
|
resolveViews();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDark(boolean dark, boolean fade, long delay) {
|
public void setDark(boolean dark, boolean fade, long delay) {
|
||||||
if (mInvertHelper != null) {
|
if (mInvertHelper != null) {
|
||||||
@@ -180,7 +194,13 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
|||||||
private void updateIconColorFilter(ImageView target, float intensity) {
|
private void updateIconColorFilter(ImageView target, float intensity) {
|
||||||
int color = interpolateColor(mIconBackgroundColor, mIconBackgroundDarkColor, intensity);
|
int color = interpolateColor(mIconBackgroundColor, mIconBackgroundDarkColor, intensity);
|
||||||
mIconColorFilter.setColor(color);
|
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) {
|
private void updateIconAlpha(ImageView target, boolean dark) {
|
||||||
|
|||||||
@@ -53,4 +53,9 @@ public abstract class NotificationViewWrapper {
|
|||||||
* @param delay if fading, the delay of the animation
|
* @param delay if fading, the delay of the animation
|
||||||
*/
|
*/
|
||||||
public abstract void setDark(boolean dark, boolean fade, long delay);
|
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() {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user