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

Commit 872df7e4 authored by Darrell Shi's avatar Darrell Shi
Browse files

Blur the hub when shade is showing

This change makes the hub blurred when shade is open. Because the
current blur is a window blur, and the hub lives in the same window as
the shade, it needs to be manually blurred. This is similar to the
manual blurring when bouncer is opened.

It also updates the alpha of scrim_behind when hub is showing to match
keyguard.

Test: atest CommunalViewModelTest
Fix: 410071710
Flag: com.android.systemui.notification_shade_blur
Change-Id: Iafadd592141e1fe072c57e8bf09ea08253af3e25
parent fe76d80f
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.Flags.FLAG_COMMUNAL_RESPONSIVE_GRID
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_DIRECT_EDIT_MODE
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.Flags.FLAG_NOTIFICATION_SHADE_BLUR
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
import com.android.systemui.classifier.domain.interactor.falsingInteractor
@@ -948,6 +949,40 @@ class CommunalViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
            assertThat(isUiBlurred).isFalse()
        }

    @Test
    @EnableFlags(FLAG_NOTIFICATION_SHADE_BLUR)
    fun uiIsBlurred_whenShadeIsExpanded() =
        kosmos.runTest {
            val viewModel = createViewModel()
            val isUiBlurred by collectLastValue(viewModel.isUiBlurred)

            shadeTestUtil.setShadeExpansion(1.0f)
            assertThat(isUiBlurred).isTrue()

            shadeTestUtil.setShadeExpansion(0.5f)
            assertThat(isUiBlurred).isTrue()

            shadeTestUtil.setShadeExpansion(0.0f)
            assertThat(isUiBlurred).isFalse()
        }

    @Test
    @EnableFlags(FLAG_NOTIFICATION_SHADE_BLUR)
    fun uiIsBlurred_whenQsIsExpanded() =
        kosmos.runTest {
            val viewModel = createViewModel()
            val isUiBlurred by collectLastValue(viewModel.isUiBlurred)

            shadeTestUtil.setQsExpansion(1.0f)
            assertThat(isUiBlurred).isTrue()

            shadeTestUtil.setQsExpansion(0.5f)
            assertThat(isUiBlurred).isTrue()

            shadeTestUtil.setQsExpansion(0.0f)
            assertThat(isUiBlurred).isFalse()
        }

    @Test
    @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
    fun swipeToCommunal() =
+15 −2
Original line number Diff line number Diff line
@@ -229,13 +229,26 @@ constructor(
    val isEnableWorkProfileDialogShowing: Flow<Boolean> =
        _isEnableWorkProfileDialogShowing.asStateFlow()

    val isUiBlurred: StateFlow<Boolean> =
    private val isUiBlurredByBouncer =
        if (Flags.bouncerUiRevamp()) {
            keyguardInteractor.primaryBouncerShowing
        } else {
            MutableStateFlow(false)
            flowOf(false)
        }

    private val isUiBlurredByShade =
        if (Flags.notificationShadeBlur()) {
            shadeInteractor.anyExpansion.map { it > 0 }
        } else {
            flowOf(false)
        }

    // Signal for whether the hub should be manually blurred. This turns true when the shade or
    // bouncer is showing.
    val isUiBlurred: StateFlow<Boolean> =
        combine(isUiBlurredByBouncer, isUiBlurredByShade) { values -> values.any { it } }
            .stateIn(scope, SharingStarted.WhileSubscribed(), initialValue = false)

    val blurRadiusPx: Float = blurConfig.maxBlurRadiusPx

    init {