Merge "Updated the styling for notifications" into pi-dev
am: 51856fde2b
Change-Id: I8d7b12955763d4d286119e976901fb55cb7a023e
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 5d21be5..d3c1e99 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3118,7 +3118,6 @@
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.
@@ -4387,8 +4386,7 @@
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(
@@ -4595,21 +4593,13 @@
}
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);
@@ -4706,7 +4696,7 @@
setTextViewColorPrimary(contentView, R.id.app_name_text);
} else {
contentView.setTextColor(R.id.app_name_text,
- ambient ? resolveAmbientColor() : resolveContrastColor());
+ ambient ? resolveAmbientColor() : getSecondaryTextColor());
}
}
@@ -5234,7 +5224,14 @@
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);
@@ -5270,14 +5267,11 @@
}
int color;
- int background = mBackgroundColorHint;
- if (mBackgroundColorHint == COLOR_INVALID) {
- background = mContext.getColor(
- com.android.internal.R.color.notification_material_background_color);
- }
+ 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);
@@ -5517,8 +5511,7 @@
if (isColorized()) {
return mBackgroundColor != COLOR_INVALID ? mBackgroundColor : mN.color;
} else {
- return mBackgroundColorHint != COLOR_INVALID ? mBackgroundColorHint
- : COLOR_DEFAULT;
+ return COLOR_DEFAULT;
}
}
@@ -5555,18 +5548,6 @@
}
/**
- * 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.
* This is needed for legacy apps that are baking in their remoteviews into the
@@ -5972,7 +5953,7 @@
* @hide
*/
public abstract boolean areNotificationsVisiblyDifferent(Style other);
-
+
/**
* @return the the text that should be displayed in the statusBar when heads-upped.
* If {@code null} is returned, the default implementation will be used.
@@ -7498,8 +7479,7 @@
}
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);
}
}
@@ -7513,8 +7493,9 @@
return view;
}
- private int getPrimaryHighlightColor() {
- return mBuilder.getPrimaryHighlightColor();
+ private int getActionColor() {
+ return mBuilder.isColorized() ? mBuilder.getPrimaryTextColor()
+ : mBuilder.resolveContrastColor();
}
private RemoteViews makeMediaBigContentView() {
@@ -7534,7 +7515,7 @@
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);
}
}
diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/NotificationColorUtil.java
index 933cc7a..577fa17 100644
--- a/core/java/com/android/internal/util/NotificationColorUtil.java
+++ b/core/java/com/android/internal/util/NotificationColorUtil.java
@@ -443,7 +443,7 @@
*/
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;
}
@@ -475,20 +475,15 @@
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)));
}
@@ -552,6 +547,17 @@
}
}
+ 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);
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 722102e..449d3e7 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -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>
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index fa3cf2f..b8a046f 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -473,7 +473,7 @@
<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>
@@ -482,7 +482,6 @@
</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>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 9d65a60..a7e97cb 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2117,7 +2117,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" />
@@ -2967,6 +2966,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" />
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 5b038b1..906ca4a 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -79,9 +79,6 @@
<!-- The color of the material notification background when dark -->
<color name="notification_material_background_dark_color">#ff333333</color>
- <!-- The color of the material notification background when low priority -->
- <color name="notification_material_background_low_priority_color">#fff5f5f5</color>
-
<!-- The color of the dividing line between grouped notifications. -->
<color name="notification_divider_color">#FF616161</color>
@@ -91,9 +88,6 @@
<!-- The color of the ripples on the untinted notifications -->
<color name="notification_ripple_untinted_color">#28000000</color>
- <!-- The color of the ripples on the low priority notifications -->
- <color name="notification_ripple_color_low_priority">#30000000</color>
-
<!-- The color of the ripples on the tinted notifications -->
<color name="notification_ripple_tinted_color">#30ffffff</color>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 8c28af5..8b6b5fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -99,7 +99,6 @@
private static final Interpolator ACTIVATE_INVERSE_ALPHA_INTERPOLATOR
= new PathInterpolator(0, 0, 0.5f, 1);
private final int mTintedRippleColor;
- private final int mLowPriorityRippleColor;
protected final int mNormalRippleColor;
private final AccessibilityManager mAccessibilityManager;
private final DoubleTapHelper mDoubleTapHelper;
@@ -134,7 +133,6 @@
private float mAppearAnimationFraction = -1.0f;
private float mAppearAnimationTranslation;
private final int mNormalColor;
- private final int mLowPriorityColor;
private boolean mIsBelowSpeedBump;
private FalsingManager mFalsingManager;
@@ -191,12 +189,8 @@
setClipChildren(false);
setClipToPadding(false);
mNormalColor = context.getColor(R.color.notification_material_background_color);
- mLowPriorityColor = context.getColor(
- R.color.notification_material_background_low_priority_color);
mTintedRippleColor = context.getColor(
R.color.notification_ripple_tinted_color);
- mLowPriorityRippleColor = context.getColor(
- R.color.notification_ripple_color_low_priority);
mNormalRippleColor = context.getColor(
R.color.notification_ripple_untinted_color);
mFalsingManager = FalsingManager.getInstance(context);
@@ -997,8 +991,6 @@
}
if (withTint && mBgTint != NO_COLOR) {
return mBgTint;
- } else if (mIsBelowSpeedBump) {
- return mLowPriorityColor;
} else {
return mNormalColor;
}
@@ -1007,8 +999,6 @@
protected int getRippleColor() {
if (mBgTint != 0) {
return mTintedRippleColor;
- } else if (mIsBelowSpeedBump) {
- return mLowPriorityRippleColor;
} else {
return mNormalRippleColor;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java
index 1127075..886d6f1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java
@@ -75,7 +75,7 @@
if (shouldApply) {
// lets gray it out
int grey = view.getContext().getColor(
- com.android.internal.R.color.notification_icon_default_color);
+ com.android.internal.R.color.notification_default_color_light);
imageView.getDrawable().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
} else {
// lets reset it
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index 5bb85e2..603902a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -165,7 +165,7 @@
mDensity = context.getResources().getDisplayMetrics().densityDpi;
if (mNotification != null) {
setDecorColor(getContext().getColor(
- com.android.internal.R.color.notification_icon_default_color));
+ com.android.internal.R.color.notification_default_color_light));
}
reloadDimens();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
index 80854ec..2b7949b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
@@ -76,7 +76,6 @@
* notification.
*/
private final Context mPackageContext;
- private boolean mIsLowPriority;
public MediaNotificationProcessor(Context context, Context packageContext) {
this(context, packageContext, new ImageGradientColorizer());
@@ -146,10 +145,7 @@
int foregroundColor = selectForegroundColor(backgroundColor, palette);
builder.setColorPalette(backgroundColor, foregroundColor);
} else {
- int id = mIsLowPriority
- ? R.color.notification_material_background_low_priority_color
- : R.color.notification_material_background_color;
- backgroundColor = mContext.getColor(id);
+ backgroundColor = mContext.getColor(R.color.notification_material_background_color);
}
Bitmap colorized = mColorizer.colorize(drawable, backgroundColor,
mContext.getResources().getConfiguration().getLayoutDirection() ==
@@ -307,8 +303,4 @@
private boolean isWhite(float[] hslColor) {
return hslColor[2] >= WHITE_MIN_LIGHTNESS;
}
-
- public void setIsLowPriority(boolean isLowPriority) {
- mIsLowPriority = isLowPriority;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
index 251e04b..78df77f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
@@ -122,9 +122,9 @@
mHeaderText = mView.findViewById(com.android.internal.R.id.header_text);
mExpandButton = mView.findViewById(com.android.internal.R.id.expand_button);
mWorkProfileImage = mView.findViewById(com.android.internal.R.id.profile_badge);
- mColor = resolveColor(mExpandButton);
mNotificationHeader = mView.findViewById(com.android.internal.R.id.notification_header);
mNotificationHeader.setShowExpandButtonAtEnd(mShowExpandButtonAtEnd);
+ mColor = mNotificationHeader.getOriginalIconColor();
getDozer().setColor(mColor);
}
@@ -132,16 +132,6 @@
mNotificationHeader.setAppOpsOnClickListener(row.getAppOpsOnClickListener());
}
- private int resolveColor(ImageView icon) {
- if (icon != null && icon.getDrawable() != null) {
- ColorFilter filter = icon.getDrawable().getColorFilter();
- if (filter instanceof PorterDuffColorFilter) {
- return ((PorterDuffColorFilter) filter).getColor();
- }
- }
- return 0;
- }
-
@Override
public void onContentUpdated(ExpandableNotificationRow row) {
super.onContentUpdated(row);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
index f5110a2d..0143d01 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationInflater.java
@@ -584,15 +584,9 @@
mSbn.getNotification());
Context packageContext = mSbn.getPackageContext(mContext);
Notification notification = mSbn.getNotification();
- if (mIsLowPriority) {
- int backgroundColor = mContext.getColor(
- R.color.notification_material_background_low_priority_color);
- recoveredBuilder.setBackgroundColorHint(backgroundColor);
- }
if (notification.isMediaNotification()) {
MediaNotificationProcessor processor = new MediaNotificationProcessor(mContext,
packageContext);
- processor.setIsLowPriority(mIsLowPriority);
processor.processNotification(notification, recoveredBuilder);
}
return createRemoteViews(mReInflateFlags,