diff options
| -rw-r--r-- | core/java/android/app/Notification.java | 14 | ||||
| -rw-r--r-- | core/java/com/android/internal/util/NotificationColorUtil.java | 22 |
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]); } |