summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff DeCew <jeffdq@google.com> 2024-11-21 15:53:08 +0000
committer Ibrahim Yilmaz <iyz@google.com> 2024-11-25 14:03:16 +0000
commitd2c8e770f8d40d6f10bc5b4a9b05fadf8e555085 (patch)
tree06270a68a9f19845e95180663ed5ed4801159729
parent296b69bc6f3388a931d034d7eb3e56abb94286fa (diff)
[RONs] Update notification colors
The OS will generate a simple palette for colored notifications based on the provided color. The primary and secondary surfaces will be blended with a new "surface extreme" color at 90% and 80% opacity, respectively. The surface extreme color will be black when the provided color is not dark. Otherwise, it will be white. Bug: 369149914 Test: visual test, screenshot tests to come later Flag: android.app.ui_rich_ongoing Change-Id: Ie7bc9ab99d4cce82c6643036dec85d2d82e8234f
-rw-r--r--core/java/android/app/Notification.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 0e68cce7a8f5..cb3817bd4a36 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -14779,12 +14779,23 @@ public class Notification implements Parcelable
} else {
mBackgroundColor = rawColor;
}
- mPrimaryTextColor = ContrastColorUtil.findAlphaToMeetContrast(
- ContrastColorUtil.resolvePrimaryColor(ctx, mBackgroundColor, nightMode),
- mBackgroundColor, 4.5);
- mSecondaryTextColor = ContrastColorUtil.findAlphaToMeetContrast(
- ContrastColorUtil.resolveSecondaryColor(ctx, mBackgroundColor, nightMode),
- mBackgroundColor, 4.5);
+ if (Flags.uiRichOngoing()) {
+ boolean isBgDark = Notification.Builder.isColorDark(mBackgroundColor);
+ int onSurfaceColorExtreme = isBgDark ? Color.WHITE : Color.BLACK;
+ mPrimaryTextColor = ContrastColorUtil.ensureContrast(
+ ColorUtils.blendARGB(mBackgroundColor, onSurfaceColorExtreme, 0.9f),
+ mBackgroundColor, isBgDark, 4.5);
+ mSecondaryTextColor = ContrastColorUtil.ensureContrast(
+ ColorUtils.blendARGB(mBackgroundColor, onSurfaceColorExtreme, 0.8f),
+ mBackgroundColor, isBgDark, 4.5);
+ } else {
+ mPrimaryTextColor = ContrastColorUtil.findAlphaToMeetContrast(
+ ContrastColorUtil.resolvePrimaryColor(ctx, mBackgroundColor, nightMode),
+ mBackgroundColor, 4.5);
+ mSecondaryTextColor = ContrastColorUtil.findAlphaToMeetContrast(
+ ContrastColorUtil.resolveSecondaryColor(ctx,
+ mBackgroundColor, nightMode), mBackgroundColor, 4.5);
+ }
mContrastColor = mPrimaryTextColor;
mPrimaryAccentColor = mPrimaryTextColor;
mSecondaryAccentColor = mSecondaryTextColor;