diff options
| author | 2023-05-26 06:58:37 +0000 | |
|---|---|---|
| committer | 2023-07-10 14:51:04 +0000 | |
| commit | 46c55f2975d969a43e91cd33081b01405b11f5a0 (patch) | |
| tree | d22e04fe77af38e0d4820a89037cebf900ec9440 | |
| parent | c7f002fd681cc62d9a415e17b0eeb83679c69e1d (diff) | |
feat(non linear font scaling): scale status bar icons when font scaling changed
When font scaling changed to larger, such as 200%, the status bar notification/system icons would be too smaller, compared with clock/battery text size. Therefore, we also scale the status bar icons when font scaling changed.
Besides, we adjust OngoingPrivacyChip to ensure the image in chip also scaled with font scaling.
Bug: 282111042
Test: manually - video attached in bug
atest frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/
atest StatusBarIconViewTest
Change-Id: I9b876ec9703a3d7310c434b1c025c297e8d5a39d
19 files changed, 406 insertions, 76 deletions
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 24da59a378f8..b129321008d8 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -95,8 +95,10 @@ <dimen name="navigation_bar_height_landscape_car_mode">96dp</dimen> <!-- Width of the navigation bar when it is placed vertically on the screen in car mode --> <dimen name="navigation_bar_width_car_mode">96dp</dimen> - <!-- Height of notification icons in the status bar --> + <!-- Original dp height of notification icons in the status bar --> <dimen name="status_bar_icon_size">22dip</dimen> + <!-- New sp height of notification icons in the status bar --> + <dimen name="status_bar_icon_size_sp">22sp</dimen> <!-- Desired size of system icons in status bar. --> <dimen name="status_bar_system_icon_size">15dp</dimen> <!-- Intrinsic size of most system icons in status bar. This is the default value that diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 85e9792fc99b..34332a5c5363 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2298,6 +2298,7 @@ <java-symbol type="bool" name="config_alwaysUseCdmaRssi" /> <java-symbol type="dimen" name="status_bar_icon_size" /> + <java-symbol type="dimen" name="status_bar_icon_size_sp" /> <java-symbol type="dimen" name="status_bar_system_icon_size" /> <java-symbol type="dimen" name="status_bar_system_icon_intrinsic_size" /> <java-symbol type="drawable" name="list_selector_pressed_holo_dark" /> diff --git a/packages/SystemUI/res-keyguard/layout/status_bar_mobile_signal_group_inner.xml b/packages/SystemUI/res-keyguard/layout/status_bar_mobile_signal_group_inner.xml index c85449d0c570..8f1323db299d 100644 --- a/packages/SystemUI/res-keyguard/layout/status_bar_mobile_signal_group_inner.xml +++ b/packages/SystemUI/res-keyguard/layout/status_bar_mobile_signal_group_inner.xml @@ -30,12 +30,13 @@ <FrameLayout android:id="@+id/inout_container" - android:layout_height="17dp" + android:layout_height="@dimen/status_bar_mobile_inout_container_size" android:layout_width="wrap_content" android:layout_gravity="center_vertical"> <ImageView android:id="@+id/mobile_in" - android:layout_height="wrap_content" + android:layout_height="@dimen/status_bar_mobile_signal_size" + android:adjustViewBounds="true" android:layout_width="wrap_content" android:src="@drawable/ic_activity_down" android:visibility="gone" @@ -43,7 +44,8 @@ /> <ImageView android:id="@+id/mobile_out" - android:layout_height="wrap_content" + android:layout_height="@dimen/status_bar_mobile_signal_size" + android:adjustViewBounds="true" android:layout_width="wrap_content" android:src="@drawable/ic_activity_up" android:paddingEnd="2dp" @@ -52,11 +54,12 @@ </FrameLayout> <ImageView android:id="@+id/mobile_type" - android:layout_height="wrap_content" + android:layout_height="@dimen/status_bar_mobile_signal_size" android:layout_width="wrap_content" android:layout_gravity="center_vertical" - android:paddingStart="2.5dp" - android:paddingEnd="1dp" + android:adjustViewBounds="true" + android:paddingStart="2.5sp" + android:paddingEnd="1sp" android:visibility="gone" /> <Space android:id="@+id/mobile_roaming_space" @@ -70,14 +73,14 @@ android:layout_gravity="center_vertical"> <com.android.systemui.statusbar.AnimatedImageView android:id="@+id/mobile_signal" - android:layout_height="wrap_content" - android:layout_width="wrap_content" + android:layout_height="@dimen/status_bar_mobile_signal_size" + android:layout_width="@dimen/status_bar_mobile_signal_size" systemui:hasOverlappingRendering="false" /> <ImageView android:id="@+id/mobile_roaming" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_width="@dimen/status_bar_mobile_signal_size" + android:layout_height="@dimen/status_bar_mobile_signal_size" android:layout_gravity="top|start" android:src="@drawable/stat_sys_roaming" android:contentDescription="@string/data_connection_roaming" diff --git a/packages/SystemUI/res/layout/heads_up_status_bar_layout.xml b/packages/SystemUI/res/layout/heads_up_status_bar_layout.xml index bacb5c13d407..49744e75eeb6 100644 --- a/packages/SystemUI/res/layout/heads_up_status_bar_layout.xml +++ b/packages/SystemUI/res/layout/heads_up_status_bar_layout.xml @@ -27,8 +27,8 @@ view. --> <Space android:id="@+id/icon_placeholder" - android:layout_width="@dimen/status_bar_icon_drawing_size" - android:layout_height="@dimen/status_bar_icon_drawing_size" + android:layout_width="@dimen/status_bar_icon_size_sp" + android:layout_height="@dimen/status_bar_icon_size_sp" android:layout_gravity="center_vertical" /> <TextView diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index 331307a0d9f4..0ab921f4d555 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -32,7 +32,7 @@ <ImageView android:id="@+id/notification_lights_out" - android:layout_width="@dimen/status_bar_icon_size" + android:layout_width="@dimen/status_bar_icon_size_sp" android:layout_height="match_parent" android:paddingStart="@dimen/status_bar_padding_start" android:paddingBottom="2dip" diff --git a/packages/SystemUI/res/layout/status_bar_wifi_group_inner.xml b/packages/SystemUI/res/layout/status_bar_wifi_group_inner.xml index 0ea0653ab89f..4c5cd7dda0c0 100644 --- a/packages/SystemUI/res/layout/status_bar_wifi_group_inner.xml +++ b/packages/SystemUI/res/layout/status_bar_wifi_group_inner.xml @@ -24,16 +24,17 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" - android:layout_marginStart="2.5dp" + android:layout_marginStart="2.5sp" > <FrameLayout android:id="@+id/inout_container" - android:layout_height="17dp" + android:layout_height="@dimen/status_bar_wifi_inout_container_size" android:layout_width="wrap_content" android:gravity="center_vertical" > <ImageView android:id="@+id/wifi_in" - android:layout_height="wrap_content" + android:layout_height="@dimen/status_bar_wifi_signal_size" + android:adjustViewBounds="true" android:layout_width="wrap_content" android:src="@drawable/ic_activity_down" android:visibility="gone" @@ -41,7 +42,8 @@ /> <ImageView android:id="@+id/wifi_out" - android:layout_height="wrap_content" + android:layout_height="@dimen/status_bar_wifi_signal_size" + android:adjustViewBounds="true" android:layout_width="wrap_content" android:src="@drawable/ic_activity_up" android:paddingEnd="2dp" @@ -75,7 +77,7 @@ <View android:id="@+id/wifi_airplane_spacer" android:layout_width="@dimen/status_bar_airplane_spacer_width" - android:layout_height="4dp" + android:layout_height="wrap_content" android:visibility="gone" /> </com.android.keyguard.AlphaOptimizedLinearLayout> diff --git a/packages/SystemUI/res/values-sw720dp/dimens.xml b/packages/SystemUI/res/values-sw720dp/dimens.xml index d053a7a0d0bb..28f98f4821fa 100644 --- a/packages/SystemUI/res/values-sw720dp/dimens.xml +++ b/packages/SystemUI/res/values-sw720dp/dimens.xml @@ -20,7 +20,7 @@ <dimen name="status_bar_icons_padding_start">10dp</dimen> <!-- gap on either side of status bar notification icons --> - <dimen name="status_bar_icon_horizontal_margin">1dp</dimen> + <dimen name="status_bar_icon_horizontal_margin">1sp</dimen> <dimen name="controls_header_horizontal_padding">28dp</dimen> <dimen name="controls_content_margin_horizontal">40dp</dimen> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 3bd7a0664d5a..e1e6c9902650 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -121,24 +121,26 @@ <dimen name="navigation_edge_cancelled_arrow_height">0dp</dimen> <dimen name="navigation_edge_cancelled_edge_corners">6dp</dimen> - <!-- Height of notification icons in the status bar --> + <!-- New sp height of notification icons in the status bar --> + <dimen name="status_bar_icon_size_sp">@*android:dimen/status_bar_icon_size_sp</dimen> + <!-- Original dp height of notification icons in the status bar --> <dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen> <!-- Default horizontal drawable padding for status bar icons. --> - <dimen name="status_bar_horizontal_padding">2.5dp</dimen> + <dimen name="status_bar_horizontal_padding">2.5sp</dimen> <!-- Height of the battery icon in the status bar. --> - <dimen name="status_bar_battery_icon_height">13.0dp</dimen> + <dimen name="status_bar_battery_icon_height">13.0sp</dimen> <!-- Width of the battery icon in the status bar. The battery drawable assumes a 12x20 canvas, - so the width of the icon should be 13.0dp * (12.0 / 20.0) --> - <dimen name="status_bar_battery_icon_width">7.8dp</dimen> + so the width of the icon should be 13.0sp * (12.0 / 20.0) --> + <dimen name="status_bar_battery_icon_width">7.8sp</dimen> - <!-- The battery icon is 13dp tall, but the other system icons are 15dp tall (see + <!-- The battery icon is 13sp tall, but the other system icons are 15sp tall (see @*android:dimen/status_bar_system_icon_size) with some top and bottom padding embedded in the drawables themselves. So, the battery icon may need an extra 1dp of spacing so that its bottom still aligns with the bottom of all the other system icons. See b/258672854. --> - <dimen name="status_bar_battery_extra_vertical_spacing">1dp</dimen> + <dimen name="status_bar_battery_extra_vertical_spacing">1sp</dimen> <!-- The font size for the clock in the status bar. --> <dimen name="status_bar_clock_size">14sp</dimen> @@ -153,19 +155,26 @@ <dimen name="status_bar_left_clock_starting_padding">0dp</dimen> <!-- End padding for left-aligned status bar clock --> - <dimen name="status_bar_left_clock_end_padding">2dp</dimen> + <dimen name="status_bar_left_clock_end_padding">2sp</dimen> <!-- Spacing after the wifi signals that is present if there are any icons following it. --> - <dimen name="status_bar_wifi_signal_spacer_width">2.5dp</dimen> + <dimen name="status_bar_wifi_signal_spacer_width">2.5sp</dimen> + <!-- Size of the view displaying the wifi inout icon in the status bar. --> + <dimen name="status_bar_wifi_inout_container_size">17sp</dimen> <!-- Size of the view displaying the wifi signal icon in the status bar. --> - <dimen name="status_bar_wifi_signal_size">@*android:dimen/status_bar_system_icon_size</dimen> + <dimen name="status_bar_wifi_signal_size">13sp</dimen> + + <!-- Size of the view displaying the mobile inout icon in the status bar. --> + <dimen name="status_bar_mobile_inout_container_size">17sp</dimen> + <!-- Size of the view displaying the mobile signal icon in the status bar. --> + <dimen name="status_bar_mobile_signal_size">13sp</dimen> <!-- Spacing before the airplane mode icon if there are any icons preceding it. --> - <dimen name="status_bar_airplane_spacer_width">4dp</dimen> + <dimen name="status_bar_airplane_spacer_width">4sp</dimen> <!-- Spacing between system icons. --> - <dimen name="status_bar_system_icon_spacing">0dp</dimen> + <dimen name="status_bar_system_icon_spacing">0sp</dimen> <!-- The amount to scale each of the status bar icons by. A value of 1 means no scaling. --> <item name="status_bar_icon_scale_factor" format="float" type="dimen">1.0</item> @@ -335,7 +344,7 @@ <dimen name="status_bar_icons_padding_top">8dp</dimen> <!-- gap on either side of status bar notification icons --> - <dimen name="status_bar_icon_horizontal_margin">0dp</dimen> + <dimen name="status_bar_icon_horizontal_margin">0sp</dimen> <!-- the padding on the start of the statusbar --> <dimen name="status_bar_padding_start">8dp</dimen> @@ -347,10 +356,10 @@ <dimen name="status_bar_padding_top">0dp</dimen> <!-- the radius of the overflow dot in the status bar --> - <dimen name="overflow_dot_radius">2dp</dimen> + <dimen name="overflow_dot_radius">2sp</dimen> <!-- the padding between dots in the icon overflow --> - <dimen name="overflow_icon_dot_padding">3dp</dimen> + <dimen name="overflow_icon_dot_padding">3sp</dimen> <!-- Dimensions related to screenshots --> @@ -838,7 +847,7 @@ <!-- Padding between the mobile signal indicator and the start icon when the roaming icon is displayed in the upper left corner. --> - <dimen name="roaming_icon_start_padding">2dp</dimen> + <dimen name="roaming_icon_start_padding">2sp</dimen> <!-- Extra padding between the mobile data type icon and the strength indicator when the data type icon is wide for the tile in quick settings. --> @@ -1064,7 +1073,7 @@ <!-- Margin between icons of Ongoing App Ops chip --> <dimen name="ongoing_appops_chip_icon_margin">4dp</dimen> <!-- Icon size of Ongoing App Ops chip --> - <dimen name="ongoing_appops_chip_icon_size">16dp</dimen> + <dimen name="ongoing_appops_chip_icon_size">16sp</dimen> <!-- Radius of Ongoing App Ops chip corners --> <dimen name="ongoing_appops_chip_bg_corner_radius">28dp</dimen> <!-- One or two privacy items --> diff --git a/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt b/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt index c3b5db42e08d..310d23407d5d 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt @@ -15,6 +15,8 @@ package com.android.systemui.privacy import android.content.Context +import android.content.pm.ActivityInfo +import android.content.res.Configuration import android.util.AttributeSet import android.view.Gravity.CENTER_VERTICAL import android.view.Gravity.END @@ -35,6 +37,7 @@ class OngoingPrivacyChip @JvmOverloads constructor( defStyleRes: Int = 0 ) : LaunchableFrameLayout(context, attrs, defStyleAttrs, defStyleRes), BackgroundAnimatableView { + private var configuration: Configuration private var iconMargin = 0 private var iconSize = 0 private var iconColor = 0 @@ -54,6 +57,7 @@ class OngoingPrivacyChip @JvmOverloads constructor( clipChildren = true clipToPadding = true iconsContainer = requireViewById(R.id.icons_container) + configuration = Configuration(context.resources.configuration) updateResources() } @@ -102,6 +106,17 @@ class OngoingPrivacyChip @JvmOverloads constructor( R.string.ongoing_privacy_chip_content_multiple_apps, typesText) } + override fun onConfigurationChanged(newConfig: Configuration?) { + super.onConfigurationChanged(newConfig) + if (newConfig != null) { + val diff = newConfig.diff(configuration) + configuration.setTo(newConfig) + if (diff.and(ActivityInfo.CONFIG_DENSITY.or(ActivityInfo.CONFIG_FONT_SCALE)) != 0) { + updateResources() + } + } + } + private fun updateResources() { iconMargin = context.resources .getDimensionPixelSize(R.dimen.ongoing_appops_chip_icon_margin) @@ -110,8 +125,11 @@ class OngoingPrivacyChip @JvmOverloads constructor( iconColor = Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary) + val height = context.resources + .getDimensionPixelSize(R.dimen.ongoing_appops_chip_height) val padding = context.resources .getDimensionPixelSize(R.dimen.ongoing_appops_chip_side_padding) + iconsContainer.layoutParams.height = height iconsContainer.setPaddingRelative(padding, 0, padding, 0) iconsContainer.background = context.getDrawable(R.drawable.statusbar_privacy_chip_bg) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index 4356a3fb29d8..cff71d2edd23 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -26,6 +26,7 @@ import android.annotation.IntDef; import android.app.ActivityManager; import android.app.Notification; import android.content.Context; +import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.res.ColorStateList; import android.content.res.Configuration; @@ -46,12 +47,14 @@ import android.util.Log; import android.util.Property; import android.util.TypedValue; import android.view.ViewDebug; +import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.animation.Interpolator; import androidx.core.graphics.ColorUtils; import com.android.app.animation.Interpolators; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.util.ContrastColorUtil; import com.android.systemui.R; @@ -131,8 +134,11 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi }; private int mStatusBarIconDrawingSizeIncreased = 1; - private int mStatusBarIconDrawingSize = 1; - private int mStatusBarIconSize = 1; + @VisibleForTesting int mStatusBarIconDrawingSize = 1; + + @VisibleForTesting int mOriginalStatusBarIconSize = 1; + @VisibleForTesting int mNewStatusBarIconSize = 1; + @VisibleForTesting float mScaleToFitNewIconSize = 1; private StatusBarIcon mIcon; @ViewDebug.ExportedProperty private String mSlot; private Drawable mNumberBackground; @@ -142,7 +148,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi private String mNumberText; private StatusBarNotification mNotification; private final boolean mBlocked; - private int mDensity; + private Configuration mConfiguration; private boolean mNightMode; private float mIconScale = 1.0f; private final Paint mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG); @@ -196,9 +202,8 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi mNumberPain.setAntiAlias(true); setNotification(sbn); setScaleType(ScaleType.CENTER); - mDensity = context.getResources().getDisplayMetrics().densityDpi; - Configuration configuration = context.getResources().getConfiguration(); - mNightMode = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) + mConfiguration = new Configuration(context.getResources().getConfiguration()); + mNightMode = (mConfiguration.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; initializeDecorColor(); reloadDimens(); @@ -206,7 +211,8 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } /** Should always be preceded by {@link #reloadDimens()} */ - private void maybeUpdateIconScaleDimens() { + @VisibleForTesting + public void maybeUpdateIconScaleDimens() { // We do not resize and scale system icons (on the right), only notification icons (on the // left). if (isNotification()) { @@ -217,22 +223,63 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } private void updateIconScaleForNotifications() { + float iconScale; + // we need to scale the image size to be same as the original size + // (fit mOriginalStatusBarIconSize), then we can scale it with mScaleToFitNewIconSize + // to fit mNewStatusBarIconSize + float scaleToOriginalDrawingSize = 1.0f; + ViewGroup.LayoutParams lp = getLayoutParams(); + if (getDrawable() != null && (lp != null && lp.width > 0 && lp.height > 0)) { + final int iconViewWidth = lp.width; + final int iconViewHeight = lp.height; + // first we estimate the image exact size when put the drawable in scaled iconView size, + // then we can compute the scaleToOriginalDrawingSize to make the image size fit in + // mOriginalStatusBarIconSize + final int drawableWidth = getDrawable().getIntrinsicWidth(); + final int drawableHeight = getDrawable().getIntrinsicHeight(); + float scaleToFitIconView = Math.min( + (float) iconViewWidth / drawableWidth, + (float) iconViewHeight / drawableHeight); + // if the drawable size <= the icon view size, the drawable won't be scaled + if (scaleToFitIconView > 1.0f) { + scaleToFitIconView = 1.0f; + } + final float scaledImageWidth = drawableWidth * scaleToFitIconView; + final float scaledImageHeight = drawableHeight * scaleToFitIconView; + // if the scaled image size <= mOriginalStatusBarIconSize, we don't need to enlarge it + scaleToOriginalDrawingSize = Math.min( + (float) mOriginalStatusBarIconSize / scaledImageWidth, + (float) mOriginalStatusBarIconSize / scaledImageHeight); + if (scaleToOriginalDrawingSize > 1.0f) { + scaleToOriginalDrawingSize = 1.0f; + } + } + iconScale = scaleToOriginalDrawingSize; + final float imageBounds = mIncreasedSize ? mStatusBarIconDrawingSizeIncreased : mStatusBarIconDrawingSize; - final int outerBounds = mStatusBarIconSize; - mIconScale = imageBounds / (float)outerBounds; + final int originalOuterBounds = mOriginalStatusBarIconSize; + iconScale = iconScale * (imageBounds / (float) originalOuterBounds); + + // scale image to fit new icon size + mIconScale = iconScale * mScaleToFitNewIconSize; + updatePivot(); } // Makes sure that all icons are scaled to the same height (15dp). If we cannot get a height // for the icon, it uses the default SCALE (15f / 17f) which is the old behavior private void updateIconScaleForSystemIcons() { + float iconScale; float iconHeight = getIconHeight(); if (iconHeight != 0) { - mIconScale = mSystemIconDesiredHeight / iconHeight; + iconScale = mSystemIconDesiredHeight / iconHeight; } else { - mIconScale = mSystemIconDefaultScale; + iconScale = mSystemIconDefaultScale; } + + // scale image to fit new icon size + mIconScale = iconScale * mScaleToFitNewIconSize; } private float getIconHeight() { @@ -255,12 +302,10 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - int density = newConfig.densityDpi; - if (density != mDensity) { - mDensity = density; - reloadDimens(); - updateDrawable(); - maybeUpdateIconScaleDimens(); + final int configDiff = newConfig.diff(mConfiguration); + mConfiguration.setTo(newConfig); + if ((configDiff & (ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_FONT_SCALE)) != 0) { + updateIconDimens(); } boolean nightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; @@ -270,11 +315,22 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } } + /** + * Update the icon dimens and drawable with current resources + */ + public void updateIconDimens() { + reloadDimens(); + updateDrawable(); + maybeUpdateIconScaleDimens(); + } + private void reloadDimens() { boolean applyRadius = mDotRadius == mStaticDotRadius; Resources res = getResources(); mStaticDotRadius = res.getDimensionPixelSize(R.dimen.overflow_dot_radius); - mStatusBarIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size); + mOriginalStatusBarIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size); + mNewStatusBarIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size_sp); + mScaleToFitNewIconSize = (float) mNewStatusBarIconSize / mOriginalStatusBarIconSize; mStatusBarIconDrawingSizeIncreased = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size_dark); mStatusBarIconDrawingSize = @@ -483,11 +539,29 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + if (!isNotification()) { + // for system icons, calculated measured width from super is for image drawable real + // width (17dp). We may scale the image with font scale, so we also need to scale the + // measured width so that scaled measured width and image width would be fit. + int measuredWidth = getMeasuredWidth(); + int measuredHeight = getMeasuredHeight(); + setMeasuredDimension((int) (measuredWidth * mScaleToFitNewIconSize), measuredHeight); + } + } + + @Override protected void onDraw(Canvas canvas) { + // In this method, for width/height division computation we intend to discard the + // fractional part as the original behavior. if (mIconAppearAmount > 0.0f) { canvas.save(); + int px = getWidth() / 2; + int py = getHeight() / 2; canvas.scale(mIconScale * mIconAppearAmount, mIconScale * mIconAppearAmount, - getWidth() / 2, getHeight() / 2); + (float) px, (float) py); super.onDraw(canvas); canvas.restore(); } @@ -504,10 +578,15 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi } else { float fadeOutAmount = mDotAppearAmount - 1.0f; alpha = alpha * (1.0f - fadeOutAmount); - radius = NotificationUtils.interpolate(mDotRadius, getWidth() / 4, fadeOutAmount); + int end = getWidth() / 4; + radius = NotificationUtils.interpolate(mDotRadius, (float) end, fadeOutAmount); } mDotPaint.setAlpha((int) (alpha * 255)); - canvas.drawCircle(mStatusBarIconSize / 2, getHeight() / 2, radius, mDotPaint); + int cx = mNewStatusBarIconSize / 2; + int cy = getHeight() / 2; + canvas.drawCircle( + (float) cx, (float) cy, + radius, mDotPaint); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java index fdad101ae0f6..d6f6c2c281de 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java @@ -135,7 +135,7 @@ public class StatusBarMobileView extends BaseStatusBarFrameLayout implements Dar mDotView = new StatusBarIconView(mContext, mSlot, null); mDotView.setVisibleState(STATE_DOT); - int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size); + int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size_sp); LayoutParams lp = new LayoutParams(width, width); lp.gravity = Gravity.CENTER_VERTICAL | Gravity.START; addView(mDotView, lp); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java index decc70d175b8..8d7214d6bd75 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarWifiView.java @@ -164,7 +164,7 @@ public class StatusBarWifiView extends BaseStatusBarFrameLayout implements DarkR mDotView = new StatusBarIconView(mContext, mSlot, null); mDotView.setVisibleState(STATE_DOT); - int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size); + int width = mContext.getResources().getDimensionPixelSize(R.dimen.status_bar_icon_size_sp); LayoutParams lp = new LayoutParams(width, width); lp.gravity = Gravity.CENTER_VERTICAL | Gravity.START; addView(mDotView, lp); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 2fd244e1357f..0fde3ab3d19c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -239,7 +239,7 @@ public class NotificationIconAreaController implements private void reloadDimens(Context context) { Resources res = context.getResources(); - mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); + mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size_sp); mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_horizontal_margin); mAodIconAppearTranslation = res.getDimensionPixelSize( R.dimen.shelf_appear_translation); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java index bef422ce3004..15ca37a222e5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -339,6 +339,7 @@ public class NotificationIconContainer extends ViewGroup { } } if (child instanceof StatusBarIconView) { + ((StatusBarIconView) child).updateIconDimens(); ((StatusBarIconView) child).setDozing(mDozing, false, 0); } } @@ -537,9 +538,10 @@ public class NotificationIconContainer extends ViewGroup { IconState iconState = mIconStates.get(mIsolatedIcon); if (iconState != null) { // Most of the time the icon isn't yet added when this is called but only happening - // later - iconState.setXTranslation(mIsolatedIconLocation.left - mAbsolutePosition[0] - - (1 - mIsolatedIcon.getIconScale()) * mIsolatedIcon.getWidth() / 2.0f); + // later. The isolated icon position left should equal to the mIsolatedIconLocation + // to ensure the icon be put at the center of the HUN icon placeholder, + // {@See HeadsUpAppearanceController#updateIsolatedIconLocation}. + iconState.setXTranslation(mIsolatedIconLocation.left - mAbsolutePosition[0]); iconState.visibleState = StatusBarIconView.STATE_ICON; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java index b14fe90cd1b3..59583ddf3e34 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java @@ -370,7 +370,7 @@ public interface StatusBarIconController { private final MobileIconsViewModel mMobileIconsViewModel; protected final Context mContext; - protected final int mIconSize; + protected int mIconSize; // Whether or not these icons show up in dumpsys protected boolean mShouldLog = false; private StatusBarIconController mController; @@ -395,10 +395,10 @@ public interface StatusBarIconController { mStatusBarPipelineFlags = statusBarPipelineFlags; mMobileContextProvider = mobileContextProvider; mContext = group.getContext(); - mIconSize = mContext.getResources().getDimensionPixelSize( - com.android.internal.R.dimen.status_bar_icon_size); mLocation = location; + reloadDimens(); + if (statusBarPipelineFlags.runNewMobileIconsBackend()) { // This starts the flow for the new pipeline, and will notify us of changes if // {@link StatusBarPipelineFlags#useNewMobileIcons} is also true. @@ -609,13 +609,9 @@ public interface StatusBarIconController { mGroup.removeAllViews(); } - protected void onDensityOrFontScaleChanged() { - for (int i = 0; i < mGroup.getChildCount(); i++) { - View child = mGroup.getChildAt(i); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize); - child.setLayoutParams(lp); - } + protected void reloadDimens() { + mIconSize = mContext.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.status_bar_icon_size_sp); } private void setHeightAndCenter(ImageView imageView, int height) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java index 3a184239ac43..80d5651a65dc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java @@ -109,6 +109,7 @@ public class StatusBarIconControllerImpl implements Tunable, } group.setController(this); + group.reloadDimens(); mIconGroups.add(group); List<Slot> allSlots = mStatusBarIconList.getSlots(); for (int i = 0; i < allSlots.size(); i++) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java index 604b1f5008db..3074abec860d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java @@ -103,7 +103,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { private void initDimens() { // This is the same value that StatusBarIconView uses mIconDotFrameWidth = getResources().getDimensionPixelSize( - com.android.internal.R.dimen.status_bar_icon_size); + com.android.internal.R.dimen.status_bar_icon_size_sp); mDotPadding = getResources().getDimensionPixelSize(R.dimen.overflow_icon_dot_padding); mIconSpacing = getResources().getDimensionPixelSize(R.dimen.status_bar_system_icon_spacing); int radius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt index 1a1340484bfc..83738544ee84 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/view/ModernStatusBarView.kt @@ -118,7 +118,7 @@ open class ModernStatusBarView(context: Context, attrs: AttributeSet?) : it.visibleState = STATE_DOT } - val width = mContext.resources.getDimensionPixelSize(R.dimen.status_bar_icon_size) + val width = mContext.resources.getDimensionPixelSize(R.dimen.status_bar_icon_size_sp) val lp = LayoutParams(width, width) lp.gravity = Gravity.CENTER_VERTICAL or Gravity.START addView(dotView, lp) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java index 1b1f4e41f200..8d016e30c0c1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java @@ -45,6 +45,7 @@ import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.UserHandle; import android.service.notification.StatusBarNotification; +import android.view.ViewGroup; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -65,6 +66,8 @@ import org.mockito.ArgumentMatcher; @RunWith(AndroidJUnit4.class) public class StatusBarIconViewTest extends SysuiTestCase { + private static final int TEST_STATUS_BAR_HEIGHT = 150; + @Rule public ExpectedException mThrown = ExpectedException.none(); @@ -184,4 +187,218 @@ public class StatusBarIconViewTest extends SysuiTestCase { // no crash, good } + + @Test + public void testUpdateIconScale_constrainedDrawableSizeLessThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // the icon view layout size would be 60x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, dpIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 50x50. When put the drawable into iconView whose + // layout size is 60x150, the drawable size would not be constrained and thus keep 50x50 + setIconDrawableWithSize(/* width= */ 50, /* height= */ 50); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN both the constrained drawable width/height are less than dpIconSize, + // THEN the icon is scaled down from dpIconSize to fit the dpDrawingSize + float scaleToFitDrawingSize = (float) dpDrawingSize / dpIconSize; + assertEquals(scaleToFitDrawingSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_constrainedDrawableHeightLargerThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // the icon view layout size would be 60x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, dpIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 50x100. When put the drawable into iconView whose + // layout size is 60x150, the drawable size would not be constrained and thus keep 50x100 + setIconDrawableWithSize(/* width= */ 50, /* height= */ 100); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN constrained drawable larger side length 100 >= dpIconSize + // THEN the icon is scaled down from larger side length 100 to ensure both side + // length fit in dpDrawingSize. + float scaleToFitDrawingSize = (float) dpDrawingSize / 100; + assertEquals(scaleToFitDrawingSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_constrainedDrawableWidthLargerThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // the icon view layout size would be 60x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, dpIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 100x50. When put the drawable into iconView whose + // layout size is 60x150, the drawable size would be constrained to 60x30 + setIconDrawableWithSize(/* width= */ 100, /* height= */ 50); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN constrained drawable larger side length 60 >= dpIconSize + // THEN the icon is scaled down from larger side length 60 to ensure both side + // length fit in dpDrawingSize. + float scaleToFitDrawingSize = (float) dpDrawingSize / 60; + assertEquals(scaleToFitDrawingSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_smallerFontAndConstrainedDrawableSizeLessThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // smaller font scaling causes the spIconSize < dpIconSize + int spIconSize = 40; + // the icon view layout size would be 40x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, spIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 50x50. When put the drawable into iconView whose + // layout size is 40x150, the drawable size would be constrained to 40x40 + setIconDrawableWithSize(/* width= */ 50, /* height= */ 50); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN both the constrained drawable width/height are less than dpIconSize, + // THEN the icon is scaled down from dpIconSize to fit the dpDrawingSize + float scaleToFitDrawingSize = (float) dpDrawingSize / dpIconSize; + // THEN the scaled icon should be scaled down further to fit spIconSize + float scaleToFitSpIconSize = (float) spIconSize / dpIconSize; + assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_smallerFontAndConstrainedDrawableHeightLargerThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // smaller font scaling causes the spIconSize < dpIconSize + int spIconSize = 40; + // the icon view layout size would be 40x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, spIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 50x100. When put the drawable into iconView whose + // layout size is 40x150, the drawable size would be constrained to 40x80 + setIconDrawableWithSize(/* width= */ 50, /* height= */ 100); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN constrained drawable larger side length 80 >= dpIconSize + // THEN the icon is scaled down from larger side length 80 to ensure both side + // length fit in dpDrawingSize. + float scaleToFitDrawingSize = (float) dpDrawingSize / 80; + // THEN the scaled icon should be scaled down further to fit spIconSize + float scaleToFitSpIconSize = (float) spIconSize / dpIconSize; + assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_largerFontAndConstrainedDrawableSizeLessThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // larger font scaling causes the spIconSize > dpIconSize + int spIconSize = 80; + // the icon view layout size would be 80x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, spIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 50x50. When put the drawable into iconView whose + // layout size is 80x150, the drawable size would not be constrained and thus keep 50x50 + setIconDrawableWithSize(/* width= */ 50, /* height= */ 50); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN both the constrained drawable width/height are less than dpIconSize, + // THEN the icon is scaled down from dpIconSize to fit the dpDrawingSize + float scaleToFitDrawingSize = (float) dpDrawingSize / dpIconSize; + // THEN the scaled icon should be scaled up to fit spIconSize + float scaleToFitSpIconSize = (float) spIconSize / dpIconSize; + assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_largerFontAndConstrainedDrawableHeightLargerThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // larger font scaling causes the spIconSize > dpIconSize + int spIconSize = 80; + // the icon view layout size would be 80x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, spIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 50x100. When put the drawable into iconView whose + // layout size is 80x150, the drawable size would not be constrained and thus keep 50x100 + setIconDrawableWithSize(/* width= */ 50, /* height= */ 100); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN constrained drawable larger side length 100 >= dpIconSize + // THEN the icon is scaled down from larger side length 100 to ensure both side + // length fit in dpDrawingSize. + float scaleToFitDrawingSize = (float) dpDrawingSize / 100; + // THEN the scaled icon should be scaled up to fit spIconSize + float scaleToFitSpIconSize = (float) spIconSize / dpIconSize; + assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, mIconView.getIconScale(), 0.01f); + } + + @Test + public void testUpdateIconScale_largerFontAndConstrainedDrawableWidthLargerThanDpIconSize() { + int dpIconSize = 60; + int dpDrawingSize = 30; + // larger font scaling causes the spIconSize > dpIconSize + int spIconSize = 80; + // the icon view layout size would be 80x150 + // (the height is always 150 due to TEST_STATUS_BAR_HEIGHT) + setUpIconView(dpIconSize, dpDrawingSize, spIconSize); + mIconView.setNotification(mock(StatusBarNotification.class)); + // the raw drawable size is 100x50. When put the drawable into iconView whose + // layout size is 80x150, the drawable size would not be constrained and thus keep 80x40 + setIconDrawableWithSize(/* width= */ 100, /* height= */ 50); + mIconView.maybeUpdateIconScaleDimens(); + + // WHEN constrained drawable larger side length 80 >= dpIconSize + // THEN the icon is scaled down from larger side length 80 to ensure both side + // length fit in dpDrawingSize. + float scaleToFitDrawingSize = (float) dpDrawingSize / 80; + // THEN the scaled icon should be scaled up to fit spIconSize + float scaleToFitSpIconSize = (float) spIconSize / dpIconSize; + assertEquals(scaleToFitDrawingSize * scaleToFitSpIconSize, + mIconView.getIconScale(), 0.01f); + } + + /** + * Setup iconView dimens for testing. The result icon view layout width would + * be spIconSize and height would be 150. + * + * @param dpIconSize corresponding to status_bar_icon_size + * @param dpDrawingSize corresponding to status_bar_icon_drawing_size + * @param spIconSize corresponding to status_bar_icon_size_sp under different font scaling + */ + private void setUpIconView(int dpIconSize, int dpDrawingSize, int spIconSize) { + mIconView.setIncreasedSize(false); + mIconView.mOriginalStatusBarIconSize = dpIconSize; + mIconView.mStatusBarIconDrawingSize = dpDrawingSize; + + mIconView.mNewStatusBarIconSize = spIconSize; + mIconView.mScaleToFitNewIconSize = (float) spIconSize / dpIconSize; + + // the layout width would be spIconSize + 2 * iconPadding, and we assume iconPadding + // is 0 here. + ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(spIconSize, TEST_STATUS_BAR_HEIGHT); + mIconView.setLayoutParams(lp); + } + + private void setIconDrawableWithSize(int width, int height) { + Bitmap bitmap = Bitmap.createBitmap( + width, height, Bitmap.Config.ARGB_8888); + Icon icon = Icon.createWithBitmap(bitmap); + mStatusBarIcon = new StatusBarIcon(UserHandle.ALL, "mockPackage", + icon, 0, 0, ""); + // Since we only want to verify icon scale logic here, we directly use + // {@link StatusBarIconView#setImageDrawable(Drawable)} to set the image drawable + // to iconView instead of call {@link StatusBarIconView#set(StatusBarIcon)}. It's to prevent + // the icon drawable size being scaled down when internally calling + // {@link StatusBarIconView#getIcon(Context,Context,StatusBarIcon)}. + mIconView.setImageDrawable(icon.loadDrawable(mContext)); + } } |