Merge "Notification history UI buff" into sc-dev
This commit is contained in:
27
res/drawable/circle.xml
Normal file
27
res/drawable/circle.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2021 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M 12 0 C 18.627416998 0 24 5.37258300203 24 12 C 24 18.627416998 18.627416998 24 12 24 C 5.37258300203 24 0 18.627416998 0 12 C 0 5.37258300203 5.37258300203 0 12 0 Z" />
|
||||||
|
</vector>
|
@@ -26,35 +26,32 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:background="@drawable/button_ripple_radius"
|
android:background="@drawable/button_ripple_radius"
|
||||||
android:paddingTop="12dp"
|
android:paddingTop="12dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:paddingBottom="12dp"
|
android:paddingBottom="12dp"
|
||||||
android:paddingStart="16dp">
|
android:paddingStart="16dp">
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_gravity="center_vertical|start"
|
||||||
android:scaleType="centerInside"/>
|
android:scaleType="centerInside"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="32dp"
|
||||||
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label"
|
android:id="@+id/label"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
|
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"/>
|
||||||
android:paddingStart="8dp" />
|
|
||||||
</LinearLayout>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/count"
|
android:id="@+id/count"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:paddingStart="6dp"
|
|
||||||
android:layout_gravity="start|center_vertical"
|
android:layout_gravity="start|center_vertical"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/TextAppearance.NotificationHistory.Title"
|
android:textAppearance="@style/TextAppearance.NotificationHistory.Title"
|
||||||
@@ -76,6 +77,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="left|center_vertical"
|
android:layout_gravity="left|center_vertical"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:paddingTop="3dp"
|
android:paddingTop="3dp"
|
||||||
android:textAppearance="@style/TextAppearance.NotificationHistory.Text"
|
android:textAppearance="@style/TextAppearance.NotificationHistory.Text"
|
||||||
|
@@ -37,15 +37,14 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
android:layout_height="24dp"
|
||||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
android:layout_width="24dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="0dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:padding="4dp"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:adjustViewBounds="true"
|
android:scaleType="centerInside" />
|
||||||
android:tint="?android:attr/textColorPrimary"
|
|
||||||
android:scaleType="fitCenter" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/pkgname"
|
android:id="@+id/pkgname"
|
||||||
@@ -98,6 +97,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginBottom="6dp"
|
android:layout_marginBottom="6dp"
|
||||||
>
|
>
|
||||||
|
@@ -34,6 +34,7 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -110,6 +111,7 @@ public class NotificationSbnAdapter extends
|
|||||||
int position) {
|
int position) {
|
||||||
final StatusBarNotification sbn = mValues.get(position);
|
final StatusBarNotification sbn = mValues.get(position);
|
||||||
if (sbn != null) {
|
if (sbn != null) {
|
||||||
|
holder.setIconBackground(loadBackground(sbn));
|
||||||
holder.setIcon(loadIcon(sbn));
|
holder.setIcon(loadIcon(sbn));
|
||||||
holder.setPackageLabel(loadPackageLabel(sbn.getPackageName()).toString());
|
holder.setPackageLabel(loadPackageLabel(sbn.getPackageName()).toString());
|
||||||
holder.setTitle(getTitleString(sbn.getNotification()));
|
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
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mValues.size();
|
return mValues.size();
|
||||||
@@ -229,7 +244,7 @@ public class NotificationSbnAdapter extends
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
draw.mutate();
|
draw.mutate();
|
||||||
draw.setColorFilter(getContrastedColor(sbn.getNotification()), PorterDuff.Mode.SRC_ATOP);
|
draw.setColorFilter(mBackgroundColor, PorterDuff.Mode.SRC_ATOP);
|
||||||
return draw;
|
return draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,13 +255,4 @@ public class NotificationSbnAdapter extends
|
|||||||
}
|
}
|
||||||
return userId;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -75,6 +75,10 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
|
|||||||
mIcon.setImageDrawable(icon);
|
mIcon.setImageDrawable(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIconBackground(Drawable background) {
|
||||||
|
mIcon.setBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
void setPackageLabel(String pkg) {
|
void setPackageLabel(String pkg) {
|
||||||
mPkgName.setText(pkg);
|
mPkgName.setText(pkg);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user