Notification history UI buff

Fixes: 182155974
Test: visual test
Change-Id: I028381407504b3cf390987a6fa11c041fddf6198
This commit is contained in:
Jay Aliomer
2021-03-30 14:16:50 -04:00
parent 8a2e489ac8
commit 5d10dbc732
6 changed files with 69 additions and 33 deletions

View File

@@ -34,6 +34,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.os.UserManager;
@@ -110,6 +111,7 @@ public class NotificationSbnAdapter extends
int position) {
final StatusBarNotification sbn = mValues.get(position);
if (sbn != null) {
holder.setIconBackground(loadBackground(sbn));
holder.setIcon(loadIcon(sbn));
holder.setPackageLabel(loadPackageLabel(sbn.getPackageName()).toString());
holder.setTitle(getTitleString(sbn.getNotification()));
@@ -140,6 +142,19 @@ public class NotificationSbnAdapter extends
}
}
private Drawable loadBackground(StatusBarNotification sbn) {
Drawable bg = mContext.getDrawable(R.drawable.circle);
int color = sbn.getNotification().color;
if (color == COLOR_DEFAULT) {
color = Utils.getColorAttrDefaultColor(
mContext, com.android.internal.R.attr.colorAccent);
}
color = ContrastColorUtil.resolveContrastColor(
mContext, color, mBackgroundColor, mInNightMode);
bg.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
return bg;
}
@Override
public int getItemCount() {
return mValues.size();
@@ -229,7 +244,7 @@ public class NotificationSbnAdapter extends
return null;
}
draw.mutate();
draw.setColorFilter(getContrastedColor(sbn.getNotification()), PorterDuff.Mode.SRC_ATOP);
draw.setColorFilter(mBackgroundColor, PorterDuff.Mode.SRC_ATOP);
return draw;
}
@@ -240,13 +255,4 @@ public class NotificationSbnAdapter extends
}
return userId;
}
private int getContrastedColor(Notification n) {
int rawColor = n.color;
if (rawColor != COLOR_DEFAULT) {
rawColor |= 0xFF000000; // no alpha for custom colors
}
return ContrastColorUtil.resolveContrastColor(
mContext, rawColor, mBackgroundColor, mInNightMode);
}
}

View File

@@ -75,6 +75,10 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
mIcon.setImageDrawable(icon);
}
void setIconBackground(Drawable background) {
mIcon.setBackground(background);
}
void setPackageLabel(String pkg) {
mPkgName.setText(pkg);
}