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

Commit 14d035c9 authored by Kenny Guy's avatar Kenny Guy
Browse files

Fix colorized messaging layout and smart replies.

Modify messaging style and smart replies view to
cope with colorized backgrounds.

Bug: 78928664
Bug: 77927019
Test: atest SystemUITests (with patch from ag/3992401)
Test: visual - see bug for screenshots

Change-Id: Iee66931574fb48d0340986bf520532f798ef59fc
parent 67890e0e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -7015,7 +7015,12 @@ public class Notification implements Parcelable
            contentView.setViewLayoutMarginEnd(R.id.notification_messaging,
                    bindResult.getIconMarginEnd());
            contentView.setInt(R.id.status_bar_latest_event_content, "setLayoutColor",
                    mBuilder.resolveContrastColor());
                    mBuilder.isColorized() ? mBuilder.getPrimaryTextColor()
                            : mBuilder.resolveContrastColor());
            contentView.setInt(R.id.status_bar_latest_event_content, "setSenderTextColor",
                    mBuilder.getPrimaryTextColor());
            contentView.setInt(R.id.status_bar_latest_event_content, "setMessageTextColor",
                    mBuilder.getSecondaryTextColor());
            contentView.setBoolean(R.id.status_bar_latest_event_content, "setDisplayImagesAtEnd",
                    displayImagesAtEnd);
            contentView.setIcon(R.id.status_bar_latest_event_content, "setLargeIcon",
+16 −3
Original line number Diff line number Diff line
@@ -418,10 +418,23 @@ public class NotificationColorUtil {
     *
     * @param isBgDarker {@code true} if {@code bg} is darker than {@code color}.
     */
    private static int ensureTextContrast(int color, int bg, boolean isBgDarker) {
    public static int ensureTextContrast(int color, int bg, boolean isBgDarker) {
        return ensureContrast(color, bg, isBgDarker, 4.5);
    }

    /**
     * Finds a color with sufficient contrast over bg that has the same or darker hue as the
     * original color, depending on the value of {@code isBgDarker}.
     *
     * @param color the color to start searching from
     * @param bg the color to ensure contrast against
     * @param isBgDarker {@code true} if {@code bg} is darker than {@code color}
     * @param minRatio the minimum contrast ratio required
     */
    public static int ensureContrast(int color, int bg, boolean isBgDarker, double minRatio) {
        return isBgDarker
                ? findContrastColorAgainstDark(color, bg, true, 4.5)
                : findContrastColor(color, bg, true, 4.5);
                ? findContrastColorAgainstDark(color, bg, true, minRatio)
                : findContrastColor(color, bg, true, minRatio);
    }

    /** Finds a background color for a text view with given text color and hint text color, that
+7 −6
Original line number Diff line number Diff line
@@ -148,8 +148,6 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
        }
        mAvatarView.setVisibility(VISIBLE);
        mSenderName.setVisibility(TextUtils.isEmpty(nameOverride) ? GONE : VISIBLE);
        mTextColor = getNormalTextColor();
        mSendingTextColor = calculateSendingTextColor();
    }

    public void setSending(boolean sending) {
@@ -160,10 +158,6 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
        }
    }

    private int getNormalTextColor() {
        return mContext.getColor(R.color.notification_secondary_text_color_light);
    }

    private int calculateSendingTextColor() {
        TypedValue alphaValue = new TypedValue();
        mContext.getResources().getValue(
@@ -363,6 +357,13 @@ public class MessagingGroup extends LinearLayout implements MessagingLinearLayou
        }
    }

    public void setTextColors(int senderTextColor, int messageTextColor) {
        mTextColor = messageTextColor;
        mSendingTextColor = calculateSendingTextColor();
        updateMessageColor();
        mSenderName.setTextColor(senderTextColor);
    }

    public void setLayoutColor(int layoutColor) {
        if (layoutColor != mLayoutColor){
            mLayoutColor = layoutColor;
+13 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ public class MessagingLayout extends FrameLayout {
    private ArrayList<MessagingGroup> mGroups = new ArrayList<>();
    private TextView mTitleView;
    private int mLayoutColor;
    private int mSenderTextColor;
    private int mMessageTextColor;
    private int mAvatarSize;
    private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    private Paint mTextPaint = new Paint();
@@ -301,6 +303,16 @@ public class MessagingLayout extends FrameLayout {
        mIsOneToOne = oneToOne;
    }

    @RemotableViewMethod
    public void setSenderTextColor(int color) {
        mSenderTextColor = color;
    }

    @RemotableViewMethod
    public void setMessageTextColor(int color) {
        mMessageTextColor = color;
    }

    public void setUser(Person user) {
        mUser = user;
        if (mUser.getIcon() == null) {
@@ -344,6 +356,7 @@ public class MessagingLayout extends FrameLayout {
            }
            newGroup.setDisplayImagesAtEnd(mDisplayImagesAtEnd);
            newGroup.setLayoutColor(mLayoutColor);
            newGroup.setTextColors(mSenderTextColor, mMessageTextColor);
            Person sender = senders.get(groupIndex);
            CharSequence nameOverride = null;
            if (sender != mUser && mNameReplacement != null) {
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@
    <color name="notification_primary_text_color_light">@color/primary_text_default_material_light</color>
    <color name="notification_primary_text_color_dark">@color/primary_text_default_material_dark</color>
    <color name="notification_secondary_text_color_light">@color/primary_text_default_material_light</color>
    <item name="notification_secondary_text_disabled_alpha" format="float" type="dimen">0.30</item>
    <item name="notification_secondary_text_disabled_alpha" format="float" type="dimen">0.38</item>
    <color name="notification_secondary_text_color_dark">@color/primary_text_default_material_dark</color>
    <color name="notification_default_color_dark">@color/primary_text_default_material_light</color>
    <color name="notification_default_color_light">#a3202124</color>
Loading