From c7f002fd681cc62d9a415e17b0eeb83679c69e1d Mon Sep 17 00:00:00 2001 From: Roy Chou Date: Tue, 13 Jun 2023 14:28:00 +0000 Subject: [PATCH] chore(non linear font scaling): remove mAlwaysScaleIcon in StatusBarIconView The constructor StatusBarIconView(Context context, AttributeSet attrs) to set mAlwaysScaleIcon be true is never used, so mAlwaysScaleIcon is always false in StatusBarIconView lifetime. Therefore, we remove mAlwaysScaleIcon and the constructor so that we don't need to consider mAlwaysScaleIcon value in future cl. Besides, we add private method isNotification() to wrap the check whether mNotification exists. Bug: 282111042 Test: pass the build Change-Id: I5eaea511718bd70681840948b54b2f178cf0e85e --- .../systemui/statusbar/StatusBarIconView.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index 91c08a062b546..4356a3fb29d80 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -41,7 +41,6 @@ import android.os.Trace; import android.os.UserHandle; import android.service.notification.StatusBarNotification; import android.text.TextUtils; -import android.util.AttributeSet; import android.util.FloatProperty; import android.util.Log; import android.util.Property; @@ -131,7 +130,6 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } }; - private boolean mAlwaysScaleIcon; private int mStatusBarIconDrawingSizeIncreased = 1; private int mStatusBarIconDrawingSize = 1; private int mStatusBarIconSize = 1; @@ -207,21 +205,11 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi maybeUpdateIconScaleDimens(); } - public StatusBarIconView(Context context, AttributeSet attrs) { - super(context, attrs); - mDozer = new NotificationIconDozeHelper(context); - mBlocked = false; - mAlwaysScaleIcon = true; - reloadDimens(); - maybeUpdateIconScaleDimens(); - mDensity = context.getResources().getDisplayMetrics().densityDpi; - } - /** Should always be preceded by {@link #reloadDimens()} */ private void maybeUpdateIconScaleDimens() { // We do not resize and scale system icons (on the right), only notification icons (on the // left). - if (mNotification != null || mAlwaysScaleIcon) { + if (isNotification()) { updateIconScaleForNotifications(); } else { updateIconScaleForSystemIcons(); @@ -309,6 +297,10 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi maybeUpdateIconScaleDimens(); } + private boolean isNotification() { + return mNotification != null; + } + private static boolean streq(String a, String b) { if (a == b) { return true; @@ -416,7 +408,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi Drawable getIcon(StatusBarIcon icon) { Context notifContext = getContext(); - if (mNotification != null) { + if (isNotification()) { notifContext = mNotification.getPackageContext(getContext()); } return getIcon(getContext(), notifContext != null ? notifContext : getContext(), icon); @@ -471,7 +463,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); - if (mNotification != null) { + if (isNotification()) { event.setParcelableData(mNotification.getNotification()); } } @@ -624,7 +616,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } private void initializeDecorColor() { - if (mNotification != null) { + if (isNotification()) { setDecorColor(getContext().getColor(mNightMode ? com.android.internal.R.color.notification_default_color_dark : com.android.internal.R.color.notification_default_color_light));