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

Commit d2b4a576 authored by Darrell Shi's avatar Darrell Shi Committed by Android (Google) Code Review
Browse files

Merge "Blur the hub when shade is showing" into main

parents b222bc59 872df7e4
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 {