Merge "Use the accent color for the hairline stroke of smart actions" into sc-dev

This commit is contained in:
Jeff DeCew
2021-03-06 13:58:42 +00:00
committed by Android (Google) Code Review
3 changed files with 20 additions and 10 deletions

View File

@@ -171,10 +171,10 @@
<color name="zen_introduction">#ffffffff</color> <color name="zen_introduction">#ffffffff</color>
<color name="smart_reply_button_text">@color/GM2_grey_700</color> <color name="smart_reply_button_text">@*android:color/notification_primary_text_color_light</color>
<color name="smart_reply_button_text_dark_bg">@*android:color/notification_primary_text_color_dark</color> <color name="smart_reply_button_text_dark_bg">@*android:color/notification_primary_text_color_dark</color>
<color name="smart_reply_button_background">#ffffffff</color> <color name="smart_reply_button_background">#ffffffff</color>
<color name="smart_reply_button_stroke">#ffdadce0</color> <color name="smart_reply_button_stroke">@*android:color/accent_device_default</color>
<!-- Biometric dialog colors --> <!-- Biometric dialog colors -->
<color name="biometric_dialog_dim_color">#80000000</color> <!-- 50% black --> <color name="biometric_dialog_dim_color">#80000000</color> <!-- 50% black -->

View File

@@ -876,10 +876,12 @@ public class NotificationContentView extends FrameLayout {
public void setBackgroundTintColor(int color) { public void setBackgroundTintColor(int color) {
if (mExpandedSmartReplyView != null) { if (mExpandedSmartReplyView != null) {
mExpandedSmartReplyView.setBackgroundTintColor(color); boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
mExpandedSmartReplyView.setBackgroundTintColor(color, colorized);
} }
if (mHeadsUpSmartReplyView != null) { if (mHeadsUpSmartReplyView != null) {
mHeadsUpSmartReplyView.setBackgroundTintColor(color); boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
mHeadsUpSmartReplyView.setBackgroundTintColor(color, colorized);
} }
} }
@@ -1509,7 +1511,9 @@ public class NotificationContentView extends FrameLayout {
smartReplyView.addPreInflatedButtons( smartReplyView.addPreInflatedButtons(
inflatedSmartReplyViewHolder.getSmartSuggestionButtons()); inflatedSmartReplyViewHolder.getSmartSuggestionButtons());
// Ensure the colors of the smart suggestion buttons are up-to-date. // Ensure the colors of the smart suggestion buttons are up-to-date.
smartReplyView.setBackgroundTintColor(entry.getRow().getCurrentBackgroundTint()); int backgroundColor = entry.getRow().getCurrentBackgroundTint();
boolean colorized = mNotificationEntry.getSbn().getNotification().isColorized();
smartReplyView.setBackgroundTintColor(backgroundColor, colorized);
smartReplyContainer.setVisibility(View.VISIBLE); smartReplyContainer.setVisibility(View.VISIBLE);
} }
return smartReplyView; return smartReplyView;

View File

@@ -92,6 +92,7 @@ public class SmartReplyView extends ViewGroup {
@ColorInt private int mCurrentStrokeColor; @ColorInt private int mCurrentStrokeColor;
@ColorInt private int mCurrentTextColor; @ColorInt private int mCurrentTextColor;
@ColorInt private int mCurrentRippleColor; @ColorInt private int mCurrentRippleColor;
private boolean mCurrentColorized;
private int mMaxSqueezeRemeasureAttempts; private int mMaxSqueezeRemeasureAttempts;
private int mMaxNumActions; private int mMaxNumActions;
private int mMinNumSystemGeneratedReplies; private int mMinNumSystemGeneratedReplies;
@@ -143,7 +144,7 @@ public class SmartReplyView extends ViewGroup {
mBreakIterator = BreakIterator.getLineInstance(); mBreakIterator = BreakIterator.getLineInstance();
setBackgroundTintColor(mDefaultBackgroundColor); setBackgroundTintColor(mDefaultBackgroundColor, false /* colorized */);
reallocateCandidateButtonQueueForSqueezing(); reallocateCandidateButtonQueueForSqueezing();
} }
@@ -182,7 +183,7 @@ public class SmartReplyView extends ViewGroup {
public void resetSmartSuggestions(View newSmartReplyContainer) { public void resetSmartSuggestions(View newSmartReplyContainer) {
mSmartReplyContainer = newSmartReplyContainer; mSmartReplyContainer = newSmartReplyContainer;
removeAllViews(); removeAllViews();
setBackgroundTintColor(mDefaultBackgroundColor); setBackgroundTintColor(mDefaultBackgroundColor, false /* colorized */);
} }
/** Add buttons to the {@link SmartReplyView} */ /** Add buttons to the {@link SmartReplyView} */
@@ -676,19 +677,24 @@ public class SmartReplyView extends ViewGroup {
return lp.show && super.drawChild(canvas, child, drawingTime); return lp.show && super.drawChild(canvas, child, drawingTime);
} }
public void setBackgroundTintColor(int backgroundColor) { /**
if (backgroundColor == mCurrentBackgroundColor) { * Set the current background color of the notification so that the smart reply buttons can
* match it, and calculate other colors (e.g. text, ripple, stroke)
*/
public void setBackgroundTintColor(int backgroundColor, boolean colorized) {
if (backgroundColor == mCurrentBackgroundColor && colorized == mCurrentColorized) {
// Same color ignoring. // Same color ignoring.
return; return;
} }
mCurrentBackgroundColor = backgroundColor; mCurrentBackgroundColor = backgroundColor;
mCurrentColorized = colorized;
final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor); final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor);
mCurrentTextColor = ContrastColorUtil.ensureTextContrast( mCurrentTextColor = ContrastColorUtil.ensureTextContrast(
dark ? mDefaultTextColorDarkBg : mDefaultTextColor, dark ? mDefaultTextColorDarkBg : mDefaultTextColor,
backgroundColor | 0xff000000, dark); backgroundColor | 0xff000000, dark);
mCurrentStrokeColor = ContrastColorUtil.ensureContrast( mCurrentStrokeColor = colorized ? mCurrentTextColor : ContrastColorUtil.ensureContrast(
mDefaultStrokeColor, backgroundColor | 0xff000000, dark, mMinStrokeContrast); mDefaultStrokeColor, backgroundColor | 0xff000000, dark, mMinStrokeContrast);
mCurrentRippleColor = dark ? mRippleColorDarkBg : mRippleColor; mCurrentRippleColor = dark ? mRippleColorDarkBg : mRippleColor;