summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zhao Dong <zhao.dong20@zte.com.cn> 2020-08-27 12:39:31 +0800
committer Jay Aliomer <aaliomer@google.com> 2020-09-01 13:56:56 +0000
commit41b2784da0d67784dce4a11fbe4f49170a56014b (patch)
tree5b1a40c6331c8eb46b3e34400f5f0d5521183ab9
parent7c8bda083150b77406c67fd3bfdaf5eb820ed30c (diff)
Apply theme by using notification context
Apply theme by using notification context instead of SystemUI context when loading notification icon drawable. When loading notification icon for StatusBarIconView, use notification's context as parameter, then applyTheme will find theme resource in notification package and avoid finding wrong theme resource in SystemUI for other apply's drawable resources. Bug: 158126029 Change-Id: Iaf8d8c6ff4af988233a1a331b255f6a4b44ca6cb
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index f4af9ae21b75..04b591334276 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -388,17 +388,21 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
}
private Drawable getIcon(StatusBarIcon icon) {
- return getIcon(getContext(), icon);
+ Context notifContext = mNotification != null ?
+ mNotification.getPackageContext(getContext()) : getContext();
+ return getIcon(getContext(), notifContext, icon);
}
/**
* Returns the right icon to use for this item
*
- * @param context Context to use to get resources
+ * @param sysuiContext Context to use to get scale factor
+ * @param context Context to use to get resources of notification icon
* @return Drawable for this item, or null if the package or item could not
* be found
*/
- public static Drawable getIcon(Context context, StatusBarIcon statusBarIcon) {
+ public static Drawable getIcon(Context sysuiContext,
+ Context context, StatusBarIcon statusBarIcon) {
int userId = statusBarIcon.user.getIdentifier();
if (userId == UserHandle.USER_ALL) {
userId = UserHandle.USER_SYSTEM;
@@ -407,7 +411,8 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
Drawable icon = statusBarIcon.icon.loadDrawableAsUser(context, userId);
TypedValue typedValue = new TypedValue();
- context.getResources().getValue(R.dimen.status_bar_icon_scale_factor, typedValue, true);
+ sysuiContext.getResources().getValue(R.dimen.status_bar_icon_scale_factor,
+ typedValue, true);
float scaleFactor = typedValue.getFloat();
// No need to scale the icon, so return it as is.