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

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

Merge "Update some NotificationShadeDepthController and...

Merge "Update some NotificationShadeDepthController and NotificationShadeDepthControllerTest logic around the spatial_model_pushback_in_shader flag" into main
parents ee1f5abf d8036eea
Loading
Loading
Loading
Loading
+31 −8
Original line number Original line Diff line number Diff line
@@ -484,7 +484,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @DisableFlags(
    @DisableFlags(
        Flags.FLAG_BOUNCER_UI_REVAMP,
        Flags.FLAG_BOUNCER_UI_REVAMP,
        Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND,
        Flags.FLAG_GLANCEABLE_HUB_BLURRED_BACKGROUND,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER
    )
    )
    fun brightnessMirror_hidesShadeBlur() {
    fun brightnessMirror_hidesShadeBlur() {
        // Brightness mirror is fully visible
        // Brightness mirror is fully visible
@@ -499,12 +500,16 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false), anyFloat())
        verify(blurUtils).applyBlur(
            eq(viewRootImpl),
            eq(0),
            eq(false),
            eq(notificationShadeDepthController.zoomOutAsScale(0f)))
    }
    }


    @Test
    @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)
    @EnableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    @EnableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK, Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER)
    fun brightnessMirror_hidesShadeBlur_withAppPushback() {
    fun brightnessMirror_hidesShadeBlur_withAppPushback() {
        // Brightness mirror is fully visible
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -518,12 +523,20 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).prepareBlur(any(), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0), eq(false), anyFloat())
        verify(blurUtils).applyBlur(
            eq(viewRootImpl),
            eq(0),
            eq(false),
            eq(notificationShadeDepthController.zoomOutAsScale(0f))
        )
    }
    }


    @Test
    @Test
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP)
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP)
    @DisableFlags(Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    @DisableFlags(
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER
    )
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlag() {
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlag() {
        // Brightness mirror is fully visible
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -536,11 +549,18 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(wallpaperController).setNotificationShadeZoom(eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(eq(0), eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(
            eq(0),
            eq(notificationShadeDepthController.zoomOutAsScale(1f))
        )
    }
    }


    @Test
    @Test
    @EnableFlags(Flags.FLAG_BOUNCER_UI_REVAMP, Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK)
    @EnableFlags(
        Flags.FLAG_BOUNCER_UI_REVAMP,
        Flags.FLAG_SPATIAL_MODEL_APP_PUSHBACK,
        Flags.FLAG_SPATIAL_MODEL_PUSHBACK_IN_SHADER
    )
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlagAndAppPushback() {
    fun brightnessMirror_hidesShadeBlur_withWindowBlurFlagAndAppPushback() {
        // Brightness mirror is fully visible
        // Brightness mirror is fully visible
        `when`(brightnessSpring.ratio).thenReturn(1f)
        `when`(brightnessSpring.ratio).thenReturn(1f)
@@ -553,7 +573,10 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(notificationShadeWindowController).setBackgroundBlurRadius(eq(0))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(wallpaperController).setNotificationShadeZoom(eq(0f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(eq(0), eq(1f))
        verify(windowRootViewBlurInteractor).requestBlurForShade(
            eq(0),
            eq(notificationShadeDepthController.zoomOutAsScale(0f))
        )
    }
    }


    @Test
    @Test
+5 −4
Original line number Original line Diff line number Diff line
@@ -284,7 +284,7 @@ constructor(
            shadeRadius = 0f
            shadeRadius = 0f
        }
        }


        if (spatialModelAppPushback()) {
        if (spatialModelAppPushback() || spatialModelPushbackInShader()) {
            // Brightness slider removes blur
            // Brightness slider removes blur
            shadeRadius *= (1 - brightnessMirrorSpring.ratio)
            shadeRadius *= (1 - brightnessMirrorSpring.ratio)
        }
        }
@@ -312,7 +312,7 @@ constructor(
            blur = 0
            blur = 0
        }
        }


        if (!spatialModelAppPushback()) {
        if (!spatialModelAppPushback() && !spatialModelPushbackInShader()) {
            // Brightness slider removes blur, but doesn't affect zooms. This is the legacy behavior
            // 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
            // 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.
            // zoom out). The new behavior is under the same flag when it's on a few lines above.
@@ -339,7 +339,8 @@ constructor(
            if (Flags.notificationShadeBlur()) false
            if (Flags.notificationShadeBlur()) false
            else scrimsVisible && !areBlursDisabledForAppLaunch
            else scrimsVisible && !areBlursDisabledForAppLaunch


    private fun zoomOutAsScale(zoomOutProgress: Float): Float =
    @VisibleForTesting
    fun zoomOutAsScale(zoomOutProgress: Float): Float =
        if (!spatialModelPushbackInShader()) 1.0f
        if (!spatialModelPushbackInShader()) 1.0f
        else 1.0f - zoomOutProgress * getPushbackScale(isHomeFocused)
        else 1.0f - zoomOutProgress * getPushbackScale(isHomeFocused)


@@ -482,7 +483,7 @@ constructor(
        }
        }
        shadeAnimation.setStiffness(SpringForce.STIFFNESS_LOW)
        shadeAnimation.setStiffness(SpringForce.STIFFNESS_LOW)
        shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        if (spatialModelAppPushback()) {
        if (spatialModelAppPushback() || spatialModelPushbackInShader()) {
            brightnessMirrorSpring.setStiffness(SpringForce.STIFFNESS_LOW)
            brightnessMirrorSpring.setStiffness(SpringForce.STIFFNESS_LOW)
            brightnessMirrorSpring.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
            brightnessMirrorSpring.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
        }
        }