Ensure notification icons have enough contrast with background.

This uses the same color calculations as the system, except that
we use the extracted notification background instead of assuming
it is white.

Bug: 32410600
Change-Id: I7be8b9459ca38d01a6780758898541e69ec42576
This commit is contained in:
Tony Wickham
2017-01-27 08:45:49 -08:00
parent 5cfd1158ec
commit f79877c04c
6 changed files with 150 additions and 18 deletions

View File

@@ -61,6 +61,7 @@ public class NotificationFooterLayout extends LinearLayout {
LinearLayout.LayoutParams mIconLayoutParams;
private LinearLayout mIconRow;
private int mBackgroundColor;
private int mTextColor;
public NotificationFooterLayout(Context context) {
@@ -90,7 +91,8 @@ public class NotificationFooterLayout extends LinearLayout {
}
public void applyColors(IconPalette iconPalette) {
setBackgroundTintList(ColorStateList.valueOf(iconPalette.backgroundColor));
mBackgroundColor = iconPalette.backgroundColor;
setBackgroundTintList(ColorStateList.valueOf(mBackgroundColor));
findViewById(R.id.divider).setBackgroundColor(iconPalette.secondaryColor);
mTextColor = iconPalette.textColor;
}
@@ -130,7 +132,7 @@ public class NotificationFooterLayout extends LinearLayout {
private void addNotificationIconForInfo(NotificationInfo info, boolean fromOverflow) {
View icon = new View(getContext());
icon.setBackground(info.iconDrawable);
icon.setBackground(info.getIconForBackground(getContext(), mBackgroundColor));
icon.setOnClickListener(info);
int addIndex = mIconRow.getChildCount();
if (fromOverflow) {