Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 622c64a9 authored by Selim Cinek's avatar Selim Cinek
Browse files

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
parent df5501b0
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -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
                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;
+17 −5
Original line number Diff line number Diff line
@@ -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]);
    }