summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2017-04-17 17:10:05 -0700
committer Selim Cinek <cinek@google.com> 2017-04-19 15:00:50 -0700
commit622c64a9ce8b5024c33fc9b0c722c5203950a13c (patch)
tree6cd7d62d0ed55ace52993276d380d0989e9adb6c
parentdf5501b0cc0e9a1a53ae42acb4a2974605034acf (diff)
Fixed the appearance of colorized fullscreenintent notifications
Previously the background would stay grey. Test: manual, add fullscreen intent colorized notification Change-Id: Ib9eefacba58256d2cb0c6f0d70cf0e9b5afdaf06 Fixes: 35968024
-rw-r--r--core/java/android/app/Notification.java14
-rw-r--r--core/java/com/android/internal/util/NotificationColorUtil.java22
2 files changed, 29 insertions, 7 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 8ed52a1bba59..52c7205493c0 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3742,6 +3742,11 @@ public class Notification implements Parcelable
return mActionBarColor;
}
+ private int getActionBarColorDeEmphasized() {
+ int backgroundColor = getBackgroundColor();
+ return NotificationColorUtil.getShiftedColor(backgroundColor, 12);
+ }
+
private void setTextViewColorSecondary(RemoteViews contentView, int id) {
ensureColors();
contentView.setTextColor(id, mSecondaryTextColor);
@@ -4302,8 +4307,13 @@ public class Notification implements Parcelable
// TODO: handle emphasized mode / actions right
if (emphazisedMode) {
// change the background bgColor
- int bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
- : R.color.notification_action_list_dark);
+ int bgColor;
+ if (isColorized()) {
+ bgColor = oddAction ? getActionBarColor() : getActionBarColorDeEmphasized();
+ } else {
+ bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
+ : R.color.notification_action_list_dark);
+ }
button.setDrawableParameters(R.id.button_holder, true, -1, bgColor,
PorterDuff.Mode.SRC_ATOP, -1);
CharSequence title = action.title;
diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/NotificationColorUtil.java
index 44b21b44e93b..5cb66e501393 100644
--- a/core/java/com/android/internal/util/NotificationColorUtil.java
+++ b/core/java/com/android/internal/util/NotificationColorUtil.java
@@ -460,13 +460,25 @@ public class NotificationColorUtil {
if (backgroundColor == Notification.COLOR_DEFAULT) {
return context.getColor(com.android.internal.R.color.notification_action_list);
}
- boolean useDark = shouldUseDark(backgroundColor);
+ return getShiftedColor(backgroundColor, 7);
+ }
+
+ /**
+ * Get a color that stays in the same tint, but darkens or lightens it by a certain
+ * amount.
+ * This also looks at the lightness of the provided color and shifts it appropriately.
+ *
+ * @param color the base color to use
+ * @param amount the amount from 1 to 100 how much to modify the color
+ * @return the now color that was modified
+ */
+ public static int getShiftedColor(int color, int amount) {
final double[] result = ColorUtilsFromCompat.getTempDouble3Array();
- ColorUtilsFromCompat.colorToLAB(backgroundColor, result);
- if (useDark && result[0] < 97 || !useDark && result[0] < 4) {
- result[0] = Math.min(100, result[0] + 7);
+ ColorUtilsFromCompat.colorToLAB(color, result);
+ if (result[0] >= 4) {
+ result[0] = Math.max(0, result[0] - amount);
} else {
- result[0] = Math.max(0, result[0] - 7);
+ result[0] = Math.min(100, result[0] + amount);
}
return ColorUtilsFromCompat.LABToColor(result[0], result[1], result[2]);
}