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

Commit 7d3a2f38 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge changes Iee8b2412,I5a20074d,I69deceff into main

* changes:
  Use descriptive name for SBIV bundle icon slot
  Remove dead code from icon container
  add dump for status bar notif icon set
parents f81389bc 4db69dae
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -42,15 +42,14 @@ import org.mockito.Mockito.`when` as whenever
@RunWithLooper
class NotificationIconContainerTest : SysuiTestCase() {

    @get:Rule
    val setFlagsRule = SetFlagsRule()
    @get:Rule val setFlagsRule = SetFlagsRule()
    private val iconContainer = NotificationIconContainer(context, /* attrs= */ null)

    @Test
    fun calculateWidthFor_zeroIcons_widthIsZero() {
        assertEquals(
            /* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 0f),
            /* actual= */ 0f
            /* actual= */ 0f,
        )
    }

@@ -62,7 +61,7 @@ class NotificationIconContainerTest : SysuiTestCase() {

        assertEquals(
            /* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 1f),
            /* actual= */ 30f
            /* actual= */ 30f,
        )
    }

@@ -74,7 +73,7 @@ class NotificationIconContainerTest : SysuiTestCase() {

        assertEquals(
            /* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 4f),
            /* actual= */ 60f
            /* actual= */ 60f,
        )
    }

@@ -207,7 +206,6 @@ class NotificationIconContainerTest : SysuiTestCase() {
        assertTrue(iconContainer.areIconsOverflowing())
    }


    @Test
    @DisableFlags(Flags.FLAG_PHYSICAL_NOTIFICATION_MOVEMENT)
    fun calculateIconXTranslations_givenWidthNotEnoughForFourIcons_atCorrectXWithOverflowDotNonPhysical() {
@@ -240,9 +238,8 @@ class NotificationIconContainerTest : SysuiTestCase() {
        val forceOverflow =
            iconContainer.shouldForceOverflow(
                /* i= */ 10,
                /* speedBumpIndex= */ 11,
                /* iconAppearAmount= */ 0.1f,
                /* maxVisibleIcons= */ 5
                /* maxVisibleIcons= */ 5,
            )
        assertTrue(forceOverflow)
    }
@@ -252,9 +249,8 @@ class NotificationIconContainerTest : SysuiTestCase() {
        val forceOverflow =
            iconContainer.shouldForceOverflow(
                /* i= */ 0,
                /* speedBumpIndex= */ 11,
                /* iconAppearAmount= */ 0f,
                /* maxVisibleIcons= */ 5
                /* maxVisibleIcons= */ 5,
            )
        assertFalse(forceOverflow)
    }
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ class IconBuilder @Inject constructor(@Main private val context: Context) {

    @JvmOverloads
    fun createIconView(entry: BundleEntry, context: Context = this.context): StatusBarIconView {
        return StatusBarIconView(context, "${entry.bundleRepository.bundleType}", null)
        return StatusBarIconView(context, entry.key, null)
    }

    fun getIconContentDescription(n: Notification): CharSequence {
+5 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.content.res.Resources
import android.graphics.Rect
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.plugins.DarkIconDispatcher
import com.android.systemui.res.R
@@ -27,6 +28,7 @@ import com.android.systemui.statusbar.headsup.shared.StatusBarNoHunBehavior
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.icon.domain.interactor.StatusBarNotificationIconsInteractor
import com.android.systemui.statusbar.phone.domain.interactor.DarkIconInteractor
import com.android.systemui.util.kotlin.FlowDumperImpl
import com.android.systemui.util.kotlin.pairwise
import com.android.systemui.util.kotlin.sample
import com.android.systemui.util.ui.AnimatableEvent
@@ -50,12 +52,13 @@ class NotificationIconContainerStatusBarViewModel
constructor(
    @Background private val bgContext: CoroutineContext,
    private val darkIconInteractor: DarkIconInteractor,
    dumpManager: DumpManager,
    iconsInteractor: StatusBarNotificationIconsInteractor,
    headsUpIconInteractor: HeadsUpNotificationIconInteractor,
    keyguardInteractor: KeyguardInteractor,
    @Main resources: Resources,
    shadeInteractor: ShadeInteractor,
) {
) : FlowDumperImpl(dumpManager) {

    private val maxIcons = resources.getInteger(R.integer.max_notif_static_icons)

@@ -92,6 +95,7 @@ constructor(
            .flowOn(bgContext)
            .conflate()
            .distinctUntilChanged()
            .dumpWhileCollecting("icons")

    /** An Icon to show "isolated" in the IconContainer. */
    val isolatedIcon: Flow<AnimatedValue<NotificationIconInfo?>> =
+18 −25
Original line number Diff line number Diff line
@@ -132,17 +132,6 @@ public class NotificationIconContainer extends ViewGroup {
        }
    }.setDuration(CONTENT_FADE_DURATION);

    // TODO(b/278765923): Replace these with domain-agnostic state
    /* 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. */
    private int mMaxIconsOnLockscreen;
    /* Maximum number of icons in the status bar when also showing overflow dot. */
    private int mMaxStaticIcons;
    private boolean mDozing;
    private boolean mOnLockScreen;
    private int mSpeedBumpIndex = -1;

    private int mMaxIcons = Integer.MAX_VALUE;
    private boolean mOverrideIconColor;
    private boolean mUseInverseOverrideIconColor;
@@ -166,6 +155,8 @@ public class NotificationIconContainer extends ViewGroup {
    private IconState mFirstVisibleIconState;
    private float mVisualOverflowStart;
    private boolean mIsShowingOverflowDot;
    private int mFirstOverflowIndex;
    private boolean mWasOverflowForced;
    @Nullable private StatusBarIconView mIsolatedIcon;
    @Nullable private Rect mIsolatedIconLocation;
    private final int[] mAbsolutePosition = new int[2];
@@ -182,10 +173,6 @@ public class NotificationIconContainer extends ViewGroup {
    }

    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);
        int staticDotRadius = getResources().getDimensionPixelSize(R.dimen.overflow_dot_radius);
        mStaticDotDiameter = 2 * staticDotRadius;
@@ -293,7 +280,12 @@ public class NotificationIconContainer extends ViewGroup {
                + " overrideIconColor=" + mOverrideIconColor
                + ", maxIcons=" + mMaxIcons
                + ", isStaticLayout=" + mIsStaticLayout
                + ", iconSize=" + mIconSize
                + ", rightBound=" + getRightBound()
                + ", themedTextColorPrimary=#" + Integer.toHexString(mThemedTextColorPrimary)
                + ", showingOverflowDot=" + mIsShowingOverflowDot
                + ", firstOverflowIndex=" + mFirstOverflowIndex
                + ", wasOverflowForced=" + mWasOverflowForced
                + " }";
    }

@@ -456,8 +448,7 @@ public class NotificationIconContainer extends ViewGroup {
    }

    @VisibleForTesting
    boolean shouldForceOverflow(int i, int speedBumpIndex, float iconAppearAmount,
            int maxVisibleIcons) {
    boolean shouldForceOverflow(int i, float iconAppearAmount, int maxVisibleIcons) {
        return i >= maxVisibleIcons && iconAppearAmount > 0.0f;
    }

@@ -481,7 +472,9 @@ public class NotificationIconContainer extends ViewGroup {
     */
    public void calculateIconXTranslations() {
        float translationX = getLeftBound();
        int firstOverflowIndex = -1;
        mFirstOverflowIndex = -1;
        mIsShowingOverflowDot = false;
        mWasOverflowForced = false;
        int childCount = getChildCount();
        int maxVisibleIcons = mMaxIcons;
        float layoutRight = getRightBound();
@@ -503,24 +496,24 @@ public class NotificationIconContainer extends ViewGroup {
                    ? StatusBarIconView.STATE_HIDDEN
                    : StatusBarIconView.STATE_ICON;

            final boolean forceOverflow = shouldForceOverflow(i, mSpeedBumpIndex,
                    iconState.iconAppearAmount, maxVisibleIcons);
            final boolean forceOverflow =
                    shouldForceOverflow(i, iconState.iconAppearAmount, maxVisibleIcons);
            final boolean isOverflowing = forceOverflow || isOverflowing(
                    /* isLastChild= */ i == childCount - 1, translationX, layoutRight, mIconSize);

            // First icon to overflow.
            if (firstOverflowIndex == -1 && isOverflowing) {
                firstOverflowIndex = i;
            if (mFirstOverflowIndex == -1 && isOverflowing) {
                mFirstOverflowIndex = i;
                mWasOverflowForced = forceOverflow;
                mVisualOverflowStart = translationX;
            }

            final float drawingScale = getDrawingScale(view);
            translationX += iconState.iconAppearAmount * view.getWidth() * drawingScale;
        }
        mIsShowingOverflowDot = false;
        if (firstOverflowIndex != -1) {
        if (mFirstOverflowIndex != -1) {
            translationX = mVisualOverflowStart;
            for (int i = firstOverflowIndex; i < childCount; i++) {
            for (int i = mFirstOverflowIndex; i < childCount; i++) {
                View view = getChildAt(i);
                IconState iconState = mIconStates.get(view);
                int dotWidth = mStaticDotDiameter + mDotPadding;
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.icon.ui.viewmodel

import android.content.res.mainResources
import com.android.systemui.dump.dumpManager
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
@@ -30,6 +31,7 @@ val Kosmos.notificationIconContainerStatusBarViewModel by
        NotificationIconContainerStatusBarViewModel(
            bgContext = testDispatcher,
            darkIconInteractor = darkIconInteractor,
            dumpManager = dumpManager,
            iconsInteractor = statusBarNotificationIconsInteractor,
            headsUpIconInteractor = headsUpNotificationIconInteractor,
            keyguardInteractor = keyguardInteractor,