summaryrefslogtreecommitdiff
path: root/core/java/android/app
diff options
context:
space:
mode:
authorJeff DeCew <jeffdq@google.com>2021-09-09 13:38:48 -0400
committerJeff DeCew <jeffdq@google.com>2021-09-09 15:00:00 -0400
commit050a0d0d64a33d16584319929456552ecc151a42 (patch)
tree518fe19b8c620982724e40c86a384a897ea0d3f1 /core/java/android/app
parent5cb7307ebb1f7daff7e0123d853ec52c49553171 (diff)
Reduce the color contrast requirements for the emphasized action button fill color.
This reduces the contrast requirement between the notification background and the button fill from 3:1 to 1.3:1 Fixes: 196393060 Test: manual testing using the go/notify2-apk and the CallStyle color customizer Test: android.app.NotificationTest Change-Id: I0fc3b7ae1ede7afd28974c59fa2a58d7fea2e9de
Diffstat (limited to 'core/java/android/app')
-rw-r--r--core/java/android/app/Notification.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 91605b78a56b..719025f9e215 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1884,6 +1884,14 @@ public class Notification implements Parcelable
* clicks. To launch an activity in those cases, provide a {@link PendingIntent} for the
* activity itself.
*
+ * <p>How an Action is displayed, including whether the {@code icon}, {@code text}, or
+ * both are displayed or required, depends on where and how the action is used, and the
+ * {@link Style} applied to the Notification.
+ *
+ * <p>When the {@code title} is a {@link android.text.Spanned}, any colors set by a
+ * {@link ForegroundColorSpan} or {@link TextAppearanceSpan} may be removed or displayed
+ * with an altered in luminance to ensure proper contrast within the Notification.
+ *
* @param icon icon to show for this action
* @param title the title of the action
* @param intent the {@link PendingIntent} to fire when users trigger this action
@@ -6128,7 +6136,7 @@ public class Notification implements Parcelable
// Check for a full-length span color to use as the button fill color.
Integer fullLengthColor = getFullLengthSpanColor(title);
if (fullLengthColor != null) {
- // Ensure the custom button fill has 3:1 contrast w/ notification bg.
+ // Ensure the custom button fill has 1.3:1 contrast w/ notification bg.
int notifBackgroundColor = getColors(p).getBackgroundColor();
buttonFillColor = ensureButtonFillContrast(
fullLengthColor, notifBackgroundColor);
@@ -6296,7 +6304,7 @@ public class Notification implements Parcelable
}
/**
- * Finds a button fill color with sufficient contrast over bg (3:1) that has the same hue
+ * Finds a button fill color with sufficient contrast over bg (1.3:1) that has the same hue
* as the original color, but is lightened or darkened depending on whether the background
* is dark or light.
*
@@ -6305,8 +6313,8 @@ public class Notification implements Parcelable
@VisibleForTesting
public static int ensureButtonFillContrast(int color, int bg) {
return isColorDark(bg)
- ? ContrastColorUtil.findContrastColorAgainstDark(color, bg, true, 3)
- : ContrastColorUtil.findContrastColor(color, bg, true, 3);
+ ? ContrastColorUtil.findContrastColorAgainstDark(color, bg, true, 1.3)
+ : ContrastColorUtil.findContrastColor(color, bg, true, 1.3);
}