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

Commit 2eb1fd9c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Selectively expand notifications inside bundles" into main

parents ceb82666 1f1577dd
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import com.android.systemui.res.R
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.statusbar.notification.AssistantFeedbackController
import com.android.systemui.statusbar.notification.collection.NotifCollection
import com.android.systemui.statusbar.notification.collection.NotifPipeline
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
@@ -39,6 +40,7 @@ internal constructor(
    @ShadeDisplayAware context: Context,
    private var mAssistantFeedbackController: AssistantFeedbackController,
    private var mSectionStyleProvider: SectionStyleProvider,
    private val notifCollection: NotifCollection,
) : Coordinator {

    private var entryToExpand: NotificationEntry? = null
@@ -74,13 +76,14 @@ internal constructor(
    }

    private fun onAfterRenderEntry(entry: NotificationEntry, controller: NotifRowController) {
        val isBundledSingleton = entry.isBundled
                && (!entry.sbn.isGroup || notifCollection.isOnlyChildInGroup(entry))
        // If mAlwaysExpandNonGroupedNotification is false, then only expand the
        // very first notification if it's not a child of grouped notifications and when
        // mAutoExpandFirstNotification is true.
        controller.setSystemExpanded(
            !entry.isBundled &&
                (mAlwaysExpandNonGroupedNotification ||
                    (mAutoExpandFirstNotification && entry == entryToExpand))
        controller.setSystemExpanded(isBundledSingleton
                || (!entry.isBundled && (mAlwaysExpandNonGroupedNotification ||
                    (mAutoExpandFirstNotification && entry == entryToExpand)))
        )
        // Show/hide the feedback icon
        controller.setFeedbackIcon(mAssistantFeedbackController.getFeedbackIcon(entry.ranking))
+5 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ public class NotificationChildrenContainer extends ViewGroup
    @VisibleForTesting
    static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED = 2;
    @VisibleForTesting
    static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED_BUNDLED = 5;
    @VisibleForTesting
    static final int NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED = 5;
    public static final int NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED = 8;
    private static final AnimationProperties ALPHA_FADE_IN = new AnimationProperties() {
@@ -1038,6 +1040,9 @@ public class NotificationChildrenContainer extends ViewGroup
        if (isBundle()) {
            return NUMBER_OF_CHILDREN_BUNDLE_COLLAPSED;
        } else {
            if (getContainingNotification().getEntryAdapter().isBundled()) {
                return NUMBER_OF_CHILDREN_WHEN_COLLAPSED_BUNDLED;
            }
            return NUMBER_OF_CHILDREN_WHEN_COLLAPSED;
        }
    }
+33 −8
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.notification.collection.coordinator

import android.app.NotificationChannel
import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -28,8 +29,10 @@ import com.android.systemui.statusbar.notification.collection.buildNotificationE
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderEntryListener
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener
import com.android.systemui.statusbar.notification.collection.notifCollection
import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider
import com.android.systemui.statusbar.notification.collection.render.NotifRowController
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
@@ -69,8 +72,8 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
    @Before
    fun setUp() {
        initMocks(this)
        coordinator =
            RowAppearanceCoordinator(mContext, assistantFeedbackController, sectionStyleProvider)
        coordinator = RowAppearanceCoordinator(
            mContext, assistantFeedbackController, sectionStyleProvider, kosmos.notifCollection)
        coordinator.attach(pipeline)
        beforeRenderListListener = withArgCaptor {
            verify(pipeline).addOnBeforeRenderListListener(capture())
@@ -89,7 +92,7 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
    }

    @Test
    fun testSetSystemExpandedOnlyOnFirst() {
    fun testSetSystemExpandedOnlyOnFirstIfNotBundle() {
        whenever(sectionStyleProvider.isMinimizedSection(eq(section1))).thenReturn(false)
        whenever(sectionStyleProvider.isMinimizedSection(eq(section1))).thenReturn(false)
        beforeRenderListListener.onBeforeRenderList(listOf(entry1, entry2))
@@ -111,12 +114,34 @@ class RowAppearanceCoordinatorTest : SysuiTestCase() {
    }

    @Test
    fun testSetSystemExpandedNeverIfBundled() {
        whenever(sectionStyleProvider.isMinimizedSection(eq(section1))).thenReturn(false)
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_NotInGroup() {
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        beforeRenderListListener.onBeforeRenderList(listOf(entry1, entry3))
        afterRenderEntryListener.onAfterRenderEntry(entry1, controller1)
        verify(controller1).setSystemExpanded(eq(true))
        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(eq(true))
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_SingleNotifInGroup() {
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(true)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(eq(true))
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun testSetSystemExpanded_Bundled_NotMultiChildGroup() {
        entry3.sbn.overrideGroupKey = "bundled"
        whenever(sectionStyleProvider.isMinimizedSection(eq(section3))).thenReturn(false)
        whenever(kosmos.notifCollection.isOnlyChildInGroup(entry3)).thenReturn(false)

        beforeRenderListListener.onBeforeRenderList(listOf(entry3))
        afterRenderEntryListener.onAfterRenderEntry(entry3, controller3)
        verify(controller3).setSystemExpanded(eq(false))
    }