* commit '4a5129c83b92e7ae198f4b9a3018c8cdcba5dd86': Fix colored icons in doze mode
This commit is contained in:
@@ -3056,6 +3056,11 @@ public class Notification implements Parcelable
|
|||||||
* Apply any necessary background to smallIcons being used in the largeIcon spot.
|
* Apply any necessary background to smallIcons being used in the largeIcon spot.
|
||||||
*/
|
*/
|
||||||
private void processSmallIconAsLarge(int largeIconId, RemoteViews contentView) {
|
private void processSmallIconAsLarge(int largeIconId, RemoteViews contentView) {
|
||||||
|
if (!isLegacy()) {
|
||||||
|
contentView.setDrawableParameters(R.id.icon, false, -1,
|
||||||
|
0xFFFFFFFF,
|
||||||
|
PorterDuff.Mode.SRC_ATOP, -1);
|
||||||
|
}
|
||||||
if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, largeIconId)) {
|
if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, largeIconId)) {
|
||||||
applyLargeIconBackground(contentView);
|
applyLargeIconBackground(contentView);
|
||||||
}
|
}
|
||||||
@@ -3103,11 +3108,12 @@ public class Notification implements Parcelable
|
|||||||
*/
|
*/
|
||||||
private void processSmallRightIcon(int smallIconDrawableId,
|
private void processSmallRightIcon(int smallIconDrawableId,
|
||||||
RemoteViews contentView) {
|
RemoteViews contentView) {
|
||||||
if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, smallIconDrawableId)) {
|
if (!isLegacy()) {
|
||||||
contentView.setDrawableParameters(R.id.right_icon, false, -1,
|
contentView.setDrawableParameters(R.id.right_icon, false, -1,
|
||||||
0xFFFFFFFF,
|
0xFFFFFFFF,
|
||||||
PorterDuff.Mode.SRC_ATOP, -1);
|
PorterDuff.Mode.SRC_ATOP, -1);
|
||||||
|
}
|
||||||
|
if (!isLegacy() || mColorUtil.isGrayscaleIcon(mContext, smallIconDrawableId)) {
|
||||||
contentView.setInt(R.id.right_icon,
|
contentView.setInt(R.id.right_icon,
|
||||||
"setBackgroundResource",
|
"setBackgroundResource",
|
||||||
R.drawable.notification_icon_legacy_bg);
|
R.drawable.notification_icon_legacy_bg);
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
|||||||
private ImageView mIcon;
|
private ImageView mIcon;
|
||||||
protected ImageView mPicture;
|
protected ImageView mPicture;
|
||||||
|
|
||||||
|
/** Whether the icon needs to be forced grayscale when in dark mode. */
|
||||||
|
private boolean mIconForceGraysaleWhenDark;
|
||||||
|
|
||||||
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);
|
||||||
@@ -73,11 +76,15 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
|||||||
mIcon = resolveIcon(largeIcon, rightIcon);
|
mIcon = resolveIcon(largeIcon, rightIcon);
|
||||||
mPicture = resolvePicture(largeIcon);
|
mPicture = resolvePicture(largeIcon);
|
||||||
mIconBackgroundColor = resolveBackgroundColor(mIcon);
|
mIconBackgroundColor = resolveBackgroundColor(mIcon);
|
||||||
|
|
||||||
|
// If the icon already has a color filter, we assume that we already forced the icon to be
|
||||||
|
// white when we created the notification.
|
||||||
|
mIconForceGraysaleWhenDark = mIcon != null && mIcon.getDrawable().getColorFilter() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageView resolveIcon(ImageView largeIcon, ImageView rightIcon) {
|
private ImageView resolveIcon(ImageView largeIcon, ImageView rightIcon) {
|
||||||
return largeIcon != null && largeIcon.getBackground() != null ? largeIcon
|
return largeIcon != null && largeIcon.getBackground() != null ? largeIcon
|
||||||
: rightIcon != null && rightIcon.getBackground() != null ? rightIcon
|
: rightIcon != null && rightIcon.getVisibility() == View.VISIBLE ? rightIcon
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,9 +125,15 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
|||||||
if (fade) {
|
if (fade) {
|
||||||
fadeIconColorFilter(mIcon, dark, delay);
|
fadeIconColorFilter(mIcon, dark, delay);
|
||||||
fadeIconAlpha(mIcon, dark, delay);
|
fadeIconAlpha(mIcon, dark, delay);
|
||||||
|
if (!mIconForceGraysaleWhenDark) {
|
||||||
|
fadeGrayscale(mIcon, dark, delay);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
updateIconColorFilter(mIcon, dark);
|
updateIconColorFilter(mIcon, dark);
|
||||||
updateIconAlpha(mIcon, dark);
|
updateIconAlpha(mIcon, dark);
|
||||||
|
if (!mIconForceGraysaleWhenDark) {
|
||||||
|
updateGrayscale(mIcon, dark);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setPictureGrayscale(dark, fade, delay);
|
setPictureGrayscale(dark, fade, delay);
|
||||||
@@ -196,8 +209,8 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
|
|||||||
mIconColorFilter.setColor(color);
|
mIconColorFilter.setColor(color);
|
||||||
Drawable background = target.getBackground();
|
Drawable background = target.getBackground();
|
||||||
|
|
||||||
// The notification might have been modified during the animation, so background might be
|
// The background might be null for legacy notifications. Also, the notification might have
|
||||||
// null here.
|
// been modified during the animation, so background might be null here.
|
||||||
if (background != null) {
|
if (background != null) {
|
||||||
background.mutate().setColorFilter(mIconColorFilter);
|
background.mutate().setColorFilter(mIconColorFilter);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user