Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57977c90 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

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
parent fbb43217
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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
+16 −9
Original line number Diff line number Diff line
@@ -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() {