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

Commit 213e816d authored by Jeff DeCew's avatar Jeff DeCew
Browse files

[flexiglass] Fix notification scrim rounding in split shade

Bug: 329664815
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I8b7c50f90af54bcb89d0f7ed6ade6433b3948a2f
parent aae2cb64
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ fun SceneScope.NotificationScrollingStack(

    val contentHeight = viewModel.intrinsicContentHeight.collectAsState()

    val stackRounding = viewModel.stackRounding.collectAsState()
    val stackRounding = viewModel.stackRounding.collectAsState(StackRounding())

    // the offset for the notifications scrim. Its upper bound is 0, and its lower bound is
    // calculated in minScrimOffset. The scrim is the same height as the screen minus the
+2 −1
Original line number Diff line number Diff line
@@ -363,7 +363,8 @@ private fun SceneScope.SplitShade(
                NotificationScrollingStack(
                    viewModel = viewModel.notifications,
                    maxScrimTop = { 0f },
                    modifier = Modifier.weight(1f).fillMaxHeight(),
                    modifier =
                        Modifier.weight(1f).fillMaxHeight().padding(bottom = navBarBottomHeight),
                )
            }
        }
+17 −3
Original line number Diff line number Diff line
@@ -20,9 +20,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds
import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
import org.junit.Test
@@ -30,10 +33,9 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@android.platform.test.annotations.EnabledOnRavenwood
class NotificationStackAppearanceInteractorTest : SysuiTestCase() {

    private val kosmos = Kosmos()
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val underTest = kosmos.notificationStackAppearanceInteractor

@@ -59,6 +61,18 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() {
            assertThat(stackBounds).isEqualTo(bounds2)
        }

    @Test
    fun stackRounding() =
        testScope.runTest {
            val stackRounding by collectLastValue(underTest.stackRounding)

            kosmos.shadeRepository.setShadeMode(ShadeMode.Single)
            assertThat(stackRounding).isEqualTo(StackRounding(roundTop = true, roundBottom = false))

            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            assertThat(stackRounding).isEqualTo(StackRounding(roundTop = true, roundBottom = true))
        }

    @Test(expected = IllegalStateException::class)
    fun setStackBounds_withImproperBounds_throwsException() =
        testScope.runTest {
+0 −5
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.notification.stack.data.repository

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds
import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow

@@ -29,10 +28,6 @@ class NotificationStackAppearanceRepository @Inject constructor() {
    /** The bounds of the notification stack in the current scene. */
    val stackBounds = MutableStateFlow(StackBounds())

    /** The whether the corners of the notification stack should be rounded */
    // TODO: replace with the logic from QSController
    val stackRounding = MutableStateFlow(StackRounding(roundTop = true, roundBottom = false))

    /**
     * The height in px of the contents of notification stack. Depending on the number of
     * notifications, this can exceed the space available on screen to show notifications, at which
+24 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
package com.android.systemui.statusbar.notification.stack.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.data.repository.NotificationStackAppearanceRepository
import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds
import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding
@@ -25,6 +27,9 @@ import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf

/** An interactor which controls the appearance of the NSSL */
@SysUISingleton
@@ -32,12 +37,30 @@ class NotificationStackAppearanceInteractor
@Inject
constructor(
    private val repository: NotificationStackAppearanceRepository,
    shadeInteractor: ShadeInteractor,
) {
    /** The bounds of the notification stack in the current scene. */
    val stackBounds: StateFlow<StackBounds> = repository.stackBounds.asStateFlow()

    /**
     * Whether the stack is expanding from GONE-with-HUN to SHADE
     *
     * TODO(b/296118689): implement this to match legacy QSController logic
     */
    private val isExpandingFromHeadsUp: Flow<Boolean> = flowOf(false)

    /** The rounding of the notification stack. */
    val stackRounding: StateFlow<StackRounding> = repository.stackRounding.asStateFlow()
    val stackRounding: Flow<StackRounding> =
        combine(
                shadeInteractor.shadeMode,
                isExpandingFromHeadsUp,
            ) { shadeMode, isExpandingFromHeadsUp ->
                StackRounding(
                    roundTop = !(shadeMode == ShadeMode.Split && isExpandingFromHeadsUp),
                    roundBottom = shadeMode != ShadeMode.Single,
                )
            }
            .distinctUntilChanged()

    /**
     * The height in px of the contents of notification stack. Depending on the number of
Loading