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

Commit 816b7224 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Remove zoom when changing brightness" into main

parents f78771bc d6c6af96
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -478,7 +478,11 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_BOUNCER_UI_REVAMP, Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND)
    @DisableFlags(
        Flags.FLAG_BOUNCER_UI_REVAMP,
        Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK
    )
    fun brightnessMirror_hidesShadeBlur() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -495,8 +499,28 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false))
    }

    @Test
    @DisableFlags(Flags.FLAG_BOUNCER_UI_REVAMP, Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND)
    @EnableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    fun brightnessMirror_hidesShadeBlur_withAppPushback() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
        // And shade is blurred
        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())

        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false))
    }

    @Test
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP)
    @DisableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlag() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -512,6 +536,23 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(windowRootViewBlurInteractor).requestBlurForShade(0)
    }

    @Test
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP, Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlagAndAppPushback() {
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
        // And shade is blurred
        notificationShadeDepthController.onPanelExpansionChanged(
            ShadeExpansionChangeEvent(fraction = 1f, expanded = true, tracking = false)
        )
        `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())

        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(0)
    }

    @Test
    fun ignoreShadeBlurUntilHidden_whennNull_ignoresIfShadeHasNoBlur() {
        `when`(shadeAnimation.radius).thenReturn(0f)
+16 −2
Original line number Diff line number Diff line
@@ -275,7 +275,13 @@ constructor(
            shadeRadius = 0f
        }

        if (spatialModelAppPushback()) {
            // Brightness slider removes blur
            shadeRadius *= (1 - brightnessMirrorSpring.ratio)
        }

        var blur = shadeRadius.toInt()

        // If the blur comes from waking up, we don't want to zoom out the background
        val zoomOut =
            when {
@@ -297,8 +303,12 @@ constructor(
            blur = 0
        }

        // Brightness slider removes blur, but doesn't affect zooms
        if (!spatialModelAppPushback()) {
            // Brightness slider removes blur, but doesn't affect zooms. This is the legacy behavior
            // that zoom out is only applied to the wallpaper (no homescreen, app or all apps
            // zoom out). The new behavior is under the same flag when it's on a few lines above.
            blur = (blur * (1f - brightnessMirrorSpring.ratio)).toInt()
        }

        return Pair(blur, zoomOut)
    }
@@ -455,6 +465,10 @@ constructor(
        }
        shadeAnimation.setStiffness(SpringForce.STIFFNESS_LOW)
        shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        if (spatialModelAppPushback()) {
            brightnessMirrorSpring.setStiffness(SpringForce.STIFFNESS_LOW)
            brightnessMirrorSpring.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        }
        applicationScope.launch {
            wallpaperInteractor.wallpaperSupportsAmbientMode.collect { supported ->
                wallpaperSupportsAmbientMode = supported