Merge "Make max notification icon values resources instead of hard-coded vals." into udc-dev

This commit is contained in:
Ioana Alexandru
2023-03-29 14:12:00 +00:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 9 deletions

View File

@@ -37,4 +37,12 @@
<dimen name="percent_displacement_at_fade_out" format="float">0.1066</dimen> <dimen name="percent_displacement_at_fade_out" format="float">0.1066</dimen>
<integer name="qs_carrier_max_em">7</integer> <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> </resources>

View File

@@ -136,11 +136,13 @@ public class NotificationIconContainer extends ViewGroup {
} }
}.setDuration(CONTENT_FADE_DURATION); }.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. */ /* Maximum number of icons in short shelf on lockscreen when also showing overflow dot. */
public static final int MAX_ICONS_ON_LOCKSCREEN = 3; private int mMaxIconsOnLockscreen;
public static final int MAX_STATIC_ICONS = 4; /* Maximum number of icons in the status bar when also showing overflow dot. */
private int mMaxStaticIcons;
private boolean mIsStaticLayout = true; private boolean mIsStaticLayout = true;
private final HashMap<View, IconState> mIconStates = new HashMap<>(); private final HashMap<View, IconState> mIconStates = new HashMap<>();
@@ -174,14 +176,19 @@ public class NotificationIconContainer extends ViewGroup {
public NotificationIconContainer(Context context, AttributeSet attrs) { public NotificationIconContainer(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
initDimens(); initResources();
setWillNotDraw(!(DEBUG || DEBUG_OVERFLOW)); 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); mDotPadding = getResources().getDimensionPixelSize(R.dimen.overflow_icon_dot_padding);
mStaticDotRadius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius); mStaticDotRadius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius);
mStaticDotDiameter = 2 * mStaticDotRadius; mStaticDotDiameter = 2 * mStaticDotRadius;
final Context themedContext = new ContextThemeWrapper(getContext(), final Context themedContext = new ContextThemeWrapper(getContext(),
com.android.internal.R.style.Theme_DeviceDefault_DayNight); com.android.internal.R.style.Theme_DeviceDefault_DayNight);
mThemedTextColorPrimary = Utils.getColorAttr(themedContext, mThemedTextColorPrimary = Utils.getColorAttr(themedContext,
@@ -225,7 +232,7 @@ public class NotificationIconContainer extends ViewGroup {
@Override @Override
protected void onConfigurationChanged(Configuration newConfig) { protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
initDimens(); initResources();
} }
@Override @Override
@@ -424,7 +431,7 @@ public class NotificationIconContainer extends ViewGroup {
return 0f; return 0f;
} }
final float contentWidth = final float contentWidth =
mIconSize * MathUtils.min(numIcons, MAX_ICONS_ON_LOCKSCREEN + 1); mIconSize * MathUtils.min(numIcons, mMaxIconsOnLockscreen + 1);
return getActualPaddingStart() return getActualPaddingStart()
+ contentWidth + contentWidth
+ getActualPaddingEnd(); + getActualPaddingEnd();
@@ -539,8 +546,8 @@ public class NotificationIconContainer extends ViewGroup {
} }
private int getMaxVisibleIcons(int childCount) { private int getMaxVisibleIcons(int childCount) {
return mOnLockScreen ? MAX_ICONS_ON_AOD : return mOnLockScreen ? mMaxIconsOnAod :
mIsStaticLayout ? MAX_STATIC_ICONS : childCount; mIsStaticLayout ? mMaxStaticIcons : childCount;
} }
private float getLayoutEnd() { private float getLayoutEnd() {