diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 327d4fe7e363c..f771cbd89e4bd 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -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", diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/NotificationColorUtil.java index 0f1307873f282..318bccf68f576 100644 --- a/core/java/com/android/internal/util/NotificationColorUtil.java +++ b/core/java/com/android/internal/util/NotificationColorUtil.java @@ -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 diff --git a/core/java/com/android/internal/widget/MessagingGroup.java b/core/java/com/android/internal/widget/MessagingGroup.java index b9a8864600c7e..7116f3a92576c 100644 --- a/core/java/com/android/internal/widget/MessagingGroup.java +++ b/core/java/com/android/internal/widget/MessagingGroup.java @@ -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; diff --git a/core/java/com/android/internal/widget/MessagingLayout.java b/core/java/com/android/internal/widget/MessagingLayout.java index 538ea11b6aa9f..79576bd600443 100644 --- a/core/java/com/android/internal/widget/MessagingLayout.java +++ b/core/java/com/android/internal/widget/MessagingLayout.java @@ -73,6 +73,8 @@ public class MessagingLayout extends FrameLayout { private ArrayList 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) { diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index 095a632c4acd1..79a7b903f82fd 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -137,7 +137,7 @@ @color/primary_text_default_material_light @color/primary_text_default_material_dark @color/primary_text_default_material_light - 0.30 + 0.38 @color/primary_text_default_material_dark @color/primary_text_default_material_light #a3202124 diff --git a/packages/SystemUI/res/drawable/smart_reply_button_background.xml b/packages/SystemUI/res/drawable/smart_reply_button_background.xml index 93adaa00e73c4..31119a90a7885 100644 --- a/packages/SystemUI/res/drawable/smart_reply_button_background.xml +++ b/packages/SystemUI/res/drawable/smart_reply_button_background.xml @@ -26,7 +26,8 @@ android:insetBottom="8dp"> - + diff --git a/packages/SystemUI/res/layout/smart_reply_button.xml b/packages/SystemUI/res/layout/smart_reply_button.xml index a490c4b8ba609..9faed18287180 100644 --- a/packages/SystemUI/res/layout/smart_reply_button.xml +++ b/packages/SystemUI/res/layout/smart_reply_button.xml @@ -19,6 +19,7 @@