diff options
| author | 2023-03-24 18:58:50 +0000 | |
|---|---|---|
| committer | 2023-03-29 10:06:47 +0000 | |
| commit | 57977c90a6ba05404b89f2838bc96661bbcb4208 (patch) | |
| tree | 59d815f6df7c4d680232f6e9dff2748874bd2281 | |
| parent | fbb43217c7d5c6fd19cca0513d1c23989eb22843 (diff) | |
Make max notification icon values resources instead of hard-coded vals.
This will allow us to customize these values based on device type/screen
orientation/size etc as needed.
Bug: 254068247
Test: atest NotificationIconContainerTest
Test: manually verified that nothing is changed in the behavior of the
icon container
Change-Id: I304b623e5c15c947cd2ddfe6b5fe977cbadd0e54
| -rw-r--r-- | packages/SystemUI/res/values/integers.xml | 8 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java | 25 |
2 files changed, 24 insertions, 9 deletions
diff --git a/packages/SystemUI/res/values/integers.xml b/packages/SystemUI/res/values/integers.xml index 8d4431520c75..befbfab7dbc3 100644 --- a/packages/SystemUI/res/values/integers.xml +++ b/packages/SystemUI/res/values/integers.xml @@ -37,4 +37,12 @@ <dimen name="percent_displacement_at_fade_out" format="float">0.1066</dimen> <integer name="qs_carrier_max_em">7</integer> + + <!-- Maximum number of notification icons shown on the Always on Display + (excluding overflow dot) --> + <integer name="max_notif_icons_on_aod">3</integer> + <!-- Maximum number of notification icons shown on the lockscreen (excluding overflow dot) --> + <integer name="max_notif_icons_on_lockscreen">3</integer> + <!-- Maximum number of notification icons shown in the status bar (excluding overflow dot) --> + <integer name="max_notif_static_icons">4</integer> </resources>
\ No newline at end of file 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 4ee2de11abdf..006a029de8e0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -136,11 +136,13 @@ public class NotificationIconContainer extends ViewGroup { } }.setDuration(CONTENT_FADE_DURATION); - private static final int MAX_ICONS_ON_AOD = 3; + /* Maximum number of icons on AOD when also showing overflow dot. */ + private int mMaxIconsOnAod; /* Maximum number of icons in short shelf on lockscreen when also showing overflow dot. */ - public static final int MAX_ICONS_ON_LOCKSCREEN = 3; - public static final int MAX_STATIC_ICONS = 4; + private int mMaxIconsOnLockscreen; + /* Maximum number of icons in the status bar when also showing overflow dot. */ + private int mMaxStaticIcons; private boolean mIsStaticLayout = true; private final HashMap<View, IconState> mIconStates = new HashMap<>(); @@ -174,14 +176,19 @@ public class NotificationIconContainer extends ViewGroup { public NotificationIconContainer(Context context, AttributeSet attrs) { super(context, attrs); - initDimens(); + initResources(); setWillNotDraw(!(DEBUG || DEBUG_OVERFLOW)); } - private void initDimens() { + private void initResources() { + mMaxIconsOnAod = getResources().getInteger(R.integer.max_notif_icons_on_aod); + mMaxIconsOnLockscreen = getResources().getInteger(R.integer.max_notif_icons_on_lockscreen); + mMaxStaticIcons = getResources().getInteger(R.integer.max_notif_static_icons); + mDotPadding = getResources().getDimensionPixelSize(R.dimen.overflow_icon_dot_padding); mStaticDotRadius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius); mStaticDotDiameter = 2 * mStaticDotRadius; + final Context themedContext = new ContextThemeWrapper(getContext(), com.android.internal.R.style.Theme_DeviceDefault_DayNight); mThemedTextColorPrimary = Utils.getColorAttr(themedContext, @@ -225,7 +232,7 @@ public class NotificationIconContainer extends ViewGroup { @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - initDimens(); + initResources(); } @Override @@ -424,7 +431,7 @@ public class NotificationIconContainer extends ViewGroup { return 0f; } final float contentWidth = - mIconSize * MathUtils.min(numIcons, MAX_ICONS_ON_LOCKSCREEN + 1); + mIconSize * MathUtils.min(numIcons, mMaxIconsOnLockscreen + 1); return getActualPaddingStart() + contentWidth + getActualPaddingEnd(); @@ -539,8 +546,8 @@ public class NotificationIconContainer extends ViewGroup { } private int getMaxVisibleIcons(int childCount) { - return mOnLockScreen ? MAX_ICONS_ON_AOD : - mIsStaticLayout ? MAX_STATIC_ICONS : childCount; + return mOnLockScreen ? mMaxIconsOnAod : + mIsStaticLayout ? mMaxStaticIcons : childCount; } private float getLayoutEnd() { |