Loading core/java/android/app/Notification.java +21 −40 Original line number Diff line number Diff line Loading @@ -3118,7 +3118,6 @@ public class Notification implements Parcelable private int mActionBarColor = COLOR_INVALID; private int mBackgroundColor = COLOR_INVALID; private int mForegroundColor = COLOR_INVALID; private int mBackgroundColorHint = COLOR_INVALID; /** * A temporary location where actions are stored. If != null the view originally has action * but doesn't have any for this inflation. Loading Loading @@ -4387,8 +4386,7 @@ public class Notification implements Parcelable backgroundColor); mSecondaryTextColor = NotificationColorUtil.resolveSecondaryColor(mContext, backgroundColor); if (backgroundColor != COLOR_DEFAULT && (mBackgroundColorHint != COLOR_INVALID || isColorized())) { if (backgroundColor != COLOR_DEFAULT && isColorized()) { mPrimaryTextColor = NotificationColorUtil.findAlphaToMeetContrast( mPrimaryTextColor, backgroundColor, 4.5); mSecondaryTextColor = NotificationColorUtil.findAlphaToMeetContrast( Loading Loading @@ -4595,21 +4593,13 @@ public class Notification implements Parcelable } private void bindExpandButton(RemoteViews contentView) { int color = getPrimaryHighlightColor(); int color = isColorized() ? getPrimaryTextColor() : getSecondaryTextColor(); contentView.setDrawableTint(R.id.expand_button, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setInt(R.id.notification_header, "setOriginalNotificationColor", color); } /** * @return the color that is used as the first primary highlight color. This is applied * in several places like the action buttons or the app name in the header. */ private int getPrimaryHighlightColor() { return isColorized() ? getPrimaryTextColor() : resolveContrastColor(); } private void bindHeaderChronometerAndTime(RemoteViews contentView) { if (showsTimeOrChronometer()) { contentView.setViewVisibility(R.id.time_divider, View.VISIBLE); Loading Loading @@ -4706,7 +4696,7 @@ public class Notification implements Parcelable setTextViewColorPrimary(contentView, R.id.app_name_text); } else { contentView.setTextColor(R.id.app_name_text, ambient ? resolveAmbientColor() : resolveContrastColor()); ambient ? resolveAmbientColor() : getSecondaryTextColor()); } } Loading Loading @@ -5234,7 +5224,14 @@ public class Notification implements Parcelable private void processSmallIconColor(Icon smallIcon, RemoteViews contentView, boolean ambient) { boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); int color = ambient ? resolveAmbientColor() : getPrimaryHighlightColor(); int color; if (ambient) { color = resolveAmbientColor(); } else if (isColorized()) { color = getPrimaryTextColor(); } else { color = resolveContrastColor(); } if (colorable) { contentView.setDrawableTint(R.id.icon, false, color, PorterDuff.Mode.SRC_ATOP); Loading Loading @@ -5270,14 +5267,11 @@ public class Notification implements Parcelable } int color; int background = mBackgroundColorHint; if (mBackgroundColorHint == COLOR_INVALID) { background = mContext.getColor( int background = mContext.getColor( com.android.internal.R.color.notification_material_background_color); } if (mN.color == COLOR_DEFAULT) { ensureColors(); color = mSecondaryTextColor; color = NotificationColorUtil.resolveDefaultColor(mContext, background); } else { color = NotificationColorUtil.resolveContrastColor(mContext, mN.color, background, mInNightMode); Loading Loading @@ -5517,8 +5511,7 @@ public class Notification implements Parcelable if (isColorized()) { return mBackgroundColor != COLOR_INVALID ? mBackgroundColor : mN.color; } else { return mBackgroundColorHint != COLOR_INVALID ? mBackgroundColorHint : COLOR_DEFAULT; return COLOR_DEFAULT; } } Loading Loading @@ -5554,18 +5547,6 @@ public class Notification implements Parcelable ensureColors(); } /** * Sets the background color for this notification to be a different one then the default. * This is mainly used to calculate contrast and won't necessarily be applied to the * background. * * @hide */ public void setBackgroundColorHint(int backgroundColor) { mBackgroundColorHint = backgroundColor; } /** * Forces all styled remoteViews to be built from scratch and not use any cached * RemoteViews. Loading Loading @@ -7498,8 +7479,7 @@ public class Notification implements Parcelable } final Action action = mBuilder.mActions.get(mActionsToShowInCompact[i]); final RemoteViews button = generateMediaActionButton(action, getPrimaryHighlightColor()); final RemoteViews button = generateMediaActionButton(action, getActionColor()); view.addView(com.android.internal.R.id.media_actions, button); } } Loading @@ -7513,8 +7493,9 @@ public class Notification implements Parcelable return view; } private int getPrimaryHighlightColor() { return mBuilder.getPrimaryHighlightColor(); private int getActionColor() { return mBuilder.isColorized() ? mBuilder.getPrimaryTextColor() : mBuilder.resolveContrastColor(); } private RemoteViews makeMediaBigContentView() { Loading @@ -7534,7 +7515,7 @@ public class Notification implements Parcelable big.removeAllViews(com.android.internal.R.id.media_actions); for (int i = 0; i < actionCount; i++) { final RemoteViews button = generateMediaActionButton(mBuilder.mActions.get(i), getPrimaryHighlightColor()); getActionColor()); big.addView(com.android.internal.R.id.media_actions, button); } } Loading core/java/com/android/internal/util/NotificationColorUtil.java +13 −7 Original line number Diff line number Diff line Loading @@ -443,7 +443,7 @@ public class NotificationColorUtil { */ public static int resolveColor(Context context, int color) { if (color == Notification.COLOR_DEFAULT) { return context.getColor(com.android.internal.R.color.notification_icon_default_color); return context.getColor(com.android.internal.R.color.notification_default_color_light); } return color; } Loading Loading @@ -475,20 +475,15 @@ public class NotificationColorUtil { int backgroundColor, boolean isDark) { final int resolvedColor = resolveColor(context, notificationColor); final int actionBg = context.getColor( com.android.internal.R.color.notification_action_list); int color = resolvedColor; color = NotificationColorUtil.ensureLargeTextContrast(color, actionBg, isDark); color = NotificationColorUtil.ensureTextContrast(color, backgroundColor, isDark); if (color != resolvedColor) { if (DEBUG){ Log.w(TAG, String.format( "Enhanced contrast of notification for %s %s (over action)" "Enhanced contrast of notification for %s" + " and %s (over background) by changing #%s to %s", context.getPackageName(), NotificationColorUtil.contrastChange(resolvedColor, color, actionBg), NotificationColorUtil.contrastChange(resolvedColor, color, backgroundColor), Integer.toHexString(resolvedColor), Integer.toHexString(color))); } Loading Loading @@ -552,6 +547,17 @@ public class NotificationColorUtil { } } public static int resolveDefaultColor(Context context, int backgroundColor) { boolean useDark = shouldUseDark(backgroundColor); if (useDark) { return context.getColor( com.android.internal.R.color.notification_default_color_light); } else { return context.getColor( com.android.internal.R.color.notification_default_color_dark); } } public static int resolveActionBarColor(Context context, int backgroundColor) { if (backgroundColor == Notification.COLOR_DEFAULT) { return context.getColor(com.android.internal.R.color.notification_action_list); Loading core/res/res/values/colors.xml +4 −3 Original line number Diff line number Diff line Loading @@ -130,13 +130,14 @@ <drawable name="notification_template_divider_media">#29ffffff</drawable> <color name="notification_primary_text_color_light">@color/primary_text_default_material_light</color> <color name="notification_primary_text_color_dark">@color/primary_text_default_material_dark</color> <color name="notification_secondary_text_color_light">@color/secondary_text_material_light</color> <color name="notification_secondary_text_color_dark">@color/secondary_text_material_dark</color> <color name="notification_secondary_text_color_light">@color/primary_text_default_material_light</color> <color name="notification_secondary_text_color_dark">@color/primary_text_default_material_dark</color> <color name="notification_default_color_dark">@color/primary_text_default_material_light</color> <color name="notification_default_color_light">#a3202124</color> <color name="notification_material_background_color">#ffffffff</color> <color name="notification_default_color">#757575</color> <!-- Gray 600 --> <color name="notification_icon_default_color">@color/notification_default_color</color> <color name="notification_progress_background_color">@color/secondary_text_material_light</color> Loading core/res/res/values/styles_material.xml +1 −2 Original line number Diff line number Diff line Loading @@ -473,7 +473,7 @@ please see styles_device_defaults.xml. <style name="TextAppearance.Material.Notification.Reply" /> <style name="TextAppearance.Material.Notification.Title"> <item name="textColor">@color/notification_primary_text_color_light</item> <item name="fontFamily">sans-serif-medium</item> <item name="textSize">@dimen/notification_title_text_size</item> </style> Loading @@ -482,7 +482,6 @@ please see styles_device_defaults.xml. </style> <style name="TextAppearance.Material.Notification.Info"> <item name="textColor">@color/notification_secondary_text_color_light</item> <item name="textSize">@dimen/notification_subtext_size</item> </style> Loading core/res/res/values/symbols.xml +2 −1 Original line number Diff line number Diff line Loading @@ -2116,7 +2116,6 @@ <java-symbol type="layout" name="notification_template_material_big_text" /> <java-symbol type="layout" name="notification_template_header" /> <java-symbol type="layout" name="notification_material_media_action" /> <java-symbol type="color" name="notification_icon_default_color" /> <java-symbol type="color" name="notification_progress_background_color" /> <java-symbol type="id" name="media_actions" /> Loading Loading @@ -2966,6 +2965,8 @@ <java-symbol type="color" name="notification_primary_text_color_dark" /> <java-symbol type="color" name="notification_secondary_text_color_light" /> <java-symbol type="color" name="notification_secondary_text_color_dark" /> <java-symbol type="color" name="notification_default_color_light" /> <java-symbol type="color" name="notification_default_color_dark" /> <java-symbol type="string" name="app_category_game" /> <java-symbol type="string" name="app_category_audio" /> Loading Loading
core/java/android/app/Notification.java +21 −40 Original line number Diff line number Diff line Loading @@ -3118,7 +3118,6 @@ public class Notification implements Parcelable private int mActionBarColor = COLOR_INVALID; private int mBackgroundColor = COLOR_INVALID; private int mForegroundColor = COLOR_INVALID; private int mBackgroundColorHint = COLOR_INVALID; /** * A temporary location where actions are stored. If != null the view originally has action * but doesn't have any for this inflation. Loading Loading @@ -4387,8 +4386,7 @@ public class Notification implements Parcelable backgroundColor); mSecondaryTextColor = NotificationColorUtil.resolveSecondaryColor(mContext, backgroundColor); if (backgroundColor != COLOR_DEFAULT && (mBackgroundColorHint != COLOR_INVALID || isColorized())) { if (backgroundColor != COLOR_DEFAULT && isColorized()) { mPrimaryTextColor = NotificationColorUtil.findAlphaToMeetContrast( mPrimaryTextColor, backgroundColor, 4.5); mSecondaryTextColor = NotificationColorUtil.findAlphaToMeetContrast( Loading Loading @@ -4595,21 +4593,13 @@ public class Notification implements Parcelable } private void bindExpandButton(RemoteViews contentView) { int color = getPrimaryHighlightColor(); int color = isColorized() ? getPrimaryTextColor() : getSecondaryTextColor(); contentView.setDrawableTint(R.id.expand_button, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setInt(R.id.notification_header, "setOriginalNotificationColor", color); } /** * @return the color that is used as the first primary highlight color. This is applied * in several places like the action buttons or the app name in the header. */ private int getPrimaryHighlightColor() { return isColorized() ? getPrimaryTextColor() : resolveContrastColor(); } private void bindHeaderChronometerAndTime(RemoteViews contentView) { if (showsTimeOrChronometer()) { contentView.setViewVisibility(R.id.time_divider, View.VISIBLE); Loading Loading @@ -4706,7 +4696,7 @@ public class Notification implements Parcelable setTextViewColorPrimary(contentView, R.id.app_name_text); } else { contentView.setTextColor(R.id.app_name_text, ambient ? resolveAmbientColor() : resolveContrastColor()); ambient ? resolveAmbientColor() : getSecondaryTextColor()); } } Loading Loading @@ -5234,7 +5224,14 @@ public class Notification implements Parcelable private void processSmallIconColor(Icon smallIcon, RemoteViews contentView, boolean ambient) { boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon); int color = ambient ? resolveAmbientColor() : getPrimaryHighlightColor(); int color; if (ambient) { color = resolveAmbientColor(); } else if (isColorized()) { color = getPrimaryTextColor(); } else { color = resolveContrastColor(); } if (colorable) { contentView.setDrawableTint(R.id.icon, false, color, PorterDuff.Mode.SRC_ATOP); Loading Loading @@ -5270,14 +5267,11 @@ public class Notification implements Parcelable } int color; int background = mBackgroundColorHint; if (mBackgroundColorHint == COLOR_INVALID) { background = mContext.getColor( int background = mContext.getColor( com.android.internal.R.color.notification_material_background_color); } if (mN.color == COLOR_DEFAULT) { ensureColors(); color = mSecondaryTextColor; color = NotificationColorUtil.resolveDefaultColor(mContext, background); } else { color = NotificationColorUtil.resolveContrastColor(mContext, mN.color, background, mInNightMode); Loading Loading @@ -5517,8 +5511,7 @@ public class Notification implements Parcelable if (isColorized()) { return mBackgroundColor != COLOR_INVALID ? mBackgroundColor : mN.color; } else { return mBackgroundColorHint != COLOR_INVALID ? mBackgroundColorHint : COLOR_DEFAULT; return COLOR_DEFAULT; } } Loading Loading @@ -5554,18 +5547,6 @@ public class Notification implements Parcelable ensureColors(); } /** * Sets the background color for this notification to be a different one then the default. * This is mainly used to calculate contrast and won't necessarily be applied to the * background. * * @hide */ public void setBackgroundColorHint(int backgroundColor) { mBackgroundColorHint = backgroundColor; } /** * Forces all styled remoteViews to be built from scratch and not use any cached * RemoteViews. Loading Loading @@ -7498,8 +7479,7 @@ public class Notification implements Parcelable } final Action action = mBuilder.mActions.get(mActionsToShowInCompact[i]); final RemoteViews button = generateMediaActionButton(action, getPrimaryHighlightColor()); final RemoteViews button = generateMediaActionButton(action, getActionColor()); view.addView(com.android.internal.R.id.media_actions, button); } } Loading @@ -7513,8 +7493,9 @@ public class Notification implements Parcelable return view; } private int getPrimaryHighlightColor() { return mBuilder.getPrimaryHighlightColor(); private int getActionColor() { return mBuilder.isColorized() ? mBuilder.getPrimaryTextColor() : mBuilder.resolveContrastColor(); } private RemoteViews makeMediaBigContentView() { Loading @@ -7534,7 +7515,7 @@ public class Notification implements Parcelable big.removeAllViews(com.android.internal.R.id.media_actions); for (int i = 0; i < actionCount; i++) { final RemoteViews button = generateMediaActionButton(mBuilder.mActions.get(i), getPrimaryHighlightColor()); getActionColor()); big.addView(com.android.internal.R.id.media_actions, button); } } Loading
core/java/com/android/internal/util/NotificationColorUtil.java +13 −7 Original line number Diff line number Diff line Loading @@ -443,7 +443,7 @@ public class NotificationColorUtil { */ public static int resolveColor(Context context, int color) { if (color == Notification.COLOR_DEFAULT) { return context.getColor(com.android.internal.R.color.notification_icon_default_color); return context.getColor(com.android.internal.R.color.notification_default_color_light); } return color; } Loading Loading @@ -475,20 +475,15 @@ public class NotificationColorUtil { int backgroundColor, boolean isDark) { final int resolvedColor = resolveColor(context, notificationColor); final int actionBg = context.getColor( com.android.internal.R.color.notification_action_list); int color = resolvedColor; color = NotificationColorUtil.ensureLargeTextContrast(color, actionBg, isDark); color = NotificationColorUtil.ensureTextContrast(color, backgroundColor, isDark); if (color != resolvedColor) { if (DEBUG){ Log.w(TAG, String.format( "Enhanced contrast of notification for %s %s (over action)" "Enhanced contrast of notification for %s" + " and %s (over background) by changing #%s to %s", context.getPackageName(), NotificationColorUtil.contrastChange(resolvedColor, color, actionBg), NotificationColorUtil.contrastChange(resolvedColor, color, backgroundColor), Integer.toHexString(resolvedColor), Integer.toHexString(color))); } Loading Loading @@ -552,6 +547,17 @@ public class NotificationColorUtil { } } public static int resolveDefaultColor(Context context, int backgroundColor) { boolean useDark = shouldUseDark(backgroundColor); if (useDark) { return context.getColor( com.android.internal.R.color.notification_default_color_light); } else { return context.getColor( com.android.internal.R.color.notification_default_color_dark); } } public static int resolveActionBarColor(Context context, int backgroundColor) { if (backgroundColor == Notification.COLOR_DEFAULT) { return context.getColor(com.android.internal.R.color.notification_action_list); Loading
core/res/res/values/colors.xml +4 −3 Original line number Diff line number Diff line Loading @@ -130,13 +130,14 @@ <drawable name="notification_template_divider_media">#29ffffff</drawable> <color name="notification_primary_text_color_light">@color/primary_text_default_material_light</color> <color name="notification_primary_text_color_dark">@color/primary_text_default_material_dark</color> <color name="notification_secondary_text_color_light">@color/secondary_text_material_light</color> <color name="notification_secondary_text_color_dark">@color/secondary_text_material_dark</color> <color name="notification_secondary_text_color_light">@color/primary_text_default_material_light</color> <color name="notification_secondary_text_color_dark">@color/primary_text_default_material_dark</color> <color name="notification_default_color_dark">@color/primary_text_default_material_light</color> <color name="notification_default_color_light">#a3202124</color> <color name="notification_material_background_color">#ffffffff</color> <color name="notification_default_color">#757575</color> <!-- Gray 600 --> <color name="notification_icon_default_color">@color/notification_default_color</color> <color name="notification_progress_background_color">@color/secondary_text_material_light</color> Loading
core/res/res/values/styles_material.xml +1 −2 Original line number Diff line number Diff line Loading @@ -473,7 +473,7 @@ please see styles_device_defaults.xml. <style name="TextAppearance.Material.Notification.Reply" /> <style name="TextAppearance.Material.Notification.Title"> <item name="textColor">@color/notification_primary_text_color_light</item> <item name="fontFamily">sans-serif-medium</item> <item name="textSize">@dimen/notification_title_text_size</item> </style> Loading @@ -482,7 +482,6 @@ please see styles_device_defaults.xml. </style> <style name="TextAppearance.Material.Notification.Info"> <item name="textColor">@color/notification_secondary_text_color_light</item> <item name="textSize">@dimen/notification_subtext_size</item> </style> Loading
core/res/res/values/symbols.xml +2 −1 Original line number Diff line number Diff line Loading @@ -2116,7 +2116,6 @@ <java-symbol type="layout" name="notification_template_material_big_text" /> <java-symbol type="layout" name="notification_template_header" /> <java-symbol type="layout" name="notification_material_media_action" /> <java-symbol type="color" name="notification_icon_default_color" /> <java-symbol type="color" name="notification_progress_background_color" /> <java-symbol type="id" name="media_actions" /> Loading Loading @@ -2966,6 +2965,8 @@ <java-symbol type="color" name="notification_primary_text_color_dark" /> <java-symbol type="color" name="notification_secondary_text_color_light" /> <java-symbol type="color" name="notification_secondary_text_color_dark" /> <java-symbol type="color" name="notification_default_color_light" /> <java-symbol type="color" name="notification_default_color_dark" /> <java-symbol type="string" name="app_category_game" /> <java-symbol type="string" name="app_category_audio" /> Loading