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

Commit 3122ef7c authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "[Dual Shade] Send the QS clipping bounds to the NSSL inline" into main

parents 6454c647 7eb76559
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -39,9 +39,9 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationScrollViewModel
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -149,8 +149,9 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() {
    @Test
    fun onPanelShapeChanged() =
        testScope.runTest {
            val actual by
                collectLastValue(kosmos.notificationStackAppearanceInteractor.qsPanelShape)
            var actual: ShadeScrimShape? = null
            kosmos.notificationScrollViewModel.setQsScrimShapeConsumer { shape -> actual = shape }

            val expected =
                ShadeScrimShape(
                    bounds = ShadeScrimBounds(left = 10f, top = 0f, right = 710f, bottom = 600f),
@@ -160,7 +161,7 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() {

            underTest.onPanelShapeChanged(expected)

            assertThat(expected).isEqualTo(actual)
            assertThat(actual).isEqualTo(expected)
        }

    private fun TestScope.lockDevice() {
+3 −5
Original line number Diff line number Diff line
@@ -54,10 +54,10 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() {
            assertThat(stackBounds).isEqualTo(bounds2)
        }

    @Test
    fun setQsPanelShape() =
        testScope.runTest {
            val actual by collectLastValue(underTest.qsPanelShape)
            var actual: ShadeScrimShape? = null
            underTest.setQsPanelShapeConsumer { shape -> actual = shape }

            val expected1 =
                ShadeScrimShape(
@@ -65,11 +65,9 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() {
                    topRadius = 0,
                    bottomRadius = 10,
                )
            underTest.setQsPanelShape(expected1)
            assertThat(actual).isEqualTo(expected1)

            val expected2 = expected1.copy(topRadius = 10)
            underTest.setQsPanelShape(expected2)
            assertThat(expected2).isEqualTo(actual)
        }

@@ -97,7 +95,7 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() {
    fun setQsPanelShape_withImproperBounds_throwsException() =
        testScope.runTest {
            val invalidBounds = ShadeScrimBounds(top = 0f, bottom = -10f)
            underTest.setQsPanelShape(
            underTest.sendQsPanelShape(
                ShadeScrimShape(bounds = invalidBounds, topRadius = 10, bottomRadius = 10)
            )
        }
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ constructor(

    /** Notifies that the bounds of the QuickSettings panel have changed. */
    fun onPanelShapeChanged(shape: ShadeScrimShape?) {
        notificationStackAppearanceInteractor.setQsPanelShape(shape)
        notificationStackAppearanceInteractor.sendQsPanelShape(shape)
    }

    fun onScrimClicked() {
+6 −8
Original line number Diff line number Diff line
@@ -45,14 +45,6 @@ class NotificationPlaceholderRepository @Inject constructor() {
     */
    val notificationShadeScrimBounds = MutableStateFlow<ShadeScrimBounds?>(null)

    /**
     * The shape of the QuickSettings overlay panel. Used to clip Notification content when the QS
     * covers it.
     *
     * When `null`, it doesn't affect notification clipping.
     */
    val qsPanelShape = MutableStateFlow<ShadeScrimShape?>(null)

    /** height made available to the notifications in the size-constrained mode of lock screen. */
    val constrainedAvailableSpace = MutableStateFlow(0)

@@ -61,4 +53,10 @@ class NotificationPlaceholderRepository @Inject constructor() {

    /** A consumer of [AccessibilityScrollEvent]s. */
    var accessibilityScrollEventConsumer: Consumer<AccessibilityScrollEvent>? = null

    /**
     * A consumer of [ShadeScrimShape], to be updated when the bounds of the QuickSettings Overlay
     * panel changes.
     */
    var qsPanelShapeConsumer: ((ShadeScrimShape?) -> Unit)? = null
}
+15 −6
Original line number Diff line number Diff line
@@ -51,9 +51,6 @@ constructor(
    val notificationShadeScrimBounds: StateFlow<ShadeScrimBounds?> =
        placeholderRepository.notificationShadeScrimBounds.asStateFlow()

    /** The shape of the QuickSettingsShadeOverlay panel */
    val qsPanelShape: StateFlow<ShadeScrimShape?> = placeholderRepository.qsPanelShape.asStateFlow()

    /**
     * Whether the stack is expanding from GONE-with-HUN to SHADE
     *
@@ -128,10 +125,22 @@ constructor(
        placeholderRepository.notificationShadeScrimBounds.value = bounds
    }

    /** Sets the bounds of the QuickSettings overlay panel */
    fun setQsPanelShape(shape: ShadeScrimShape?) {
    /**
     * Sends the bounds of the QuickSettings panel to the consumer set by [setQsPanelShapeConsumer].
     *
     * Used to clip Notification content when the QuickSettings Overlay panel covers it. Sending
     * `null` resets the negative shape clipping of the Notification Stack.
     */
    fun sendQsPanelShape(shape: ShadeScrimShape?) {
        checkValidBounds(shape?.bounds)
        placeholderRepository.qsPanelShape.value = shape
        placeholderRepository.qsPanelShapeConsumer?.invoke(shape)
    }

    /**
     * Sets a consumer to be notified when the QuickSettings Overlay panel changes size or position.
     */
    fun setQsPanelShapeConsumer(consumer: ((ShadeScrimShape?) -> Unit)?) {
        placeholderRepository.qsPanelShapeConsumer = consumer
    }

    /** Updates the current scroll state of the notification shade. */
Loading