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

Commit fe235e74 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add zoom support to lock screen wallpaper" into rvc-dev am: b4734d9b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12002740

Change-Id: I1b162a927cbc49f8beb70c658be031c155610290
parents 0bfba9c3 b4734d9b
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ class NotificationShadeDepthController @Inject constructor(
    private var isClosed: Boolean = true
    private var isOpen: Boolean = false
    private var isBlurred: Boolean = false
    private var listeners = mutableListOf<DepthListener>()

    private var prevTracking: Boolean = false
    private var prevTimestamp: Long = -1
@@ -187,12 +188,15 @@ class NotificationShadeDepthController @Inject constructor(
        }

        blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur)
        val zoomOut = blurUtils.ratioOfBlurRadius(blur)
        try {
            wallpaperManager.setWallpaperZoomOut(root.windowToken,
                    blurUtils.ratioOfBlurRadius(blur))
            wallpaperManager.setWallpaperZoomOut(root.windowToken, zoomOut)
        } catch (e: IllegalArgumentException) {
            Log.w(TAG, "Can't set zoom. Window is gone: ${root.windowToken}", e)
        }
        listeners.forEach {
            it.onWallpaperZoomOutChanged(zoomOut)
        }
        notificationShadeWindowController.setBackgroundBlurRadius(blur)
    }

@@ -271,6 +275,14 @@ class NotificationShadeDepthController @Inject constructor(
        shadeAnimation.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY)
    }

    fun addListener(listener: DepthListener) {
        listeners.add(listener)
    }

    fun removeListener(listener: DepthListener) {
        listeners.remove(listener)
    }

    /**
     * Update blurs when pulling down the shade
     */
@@ -482,4 +494,14 @@ class NotificationShadeDepthController @Inject constructor(
            springAnimation.setStartVelocity(velocity)
        }
    }

    /**
     * Invoked when changes are needed in z-space
     */
    interface DepthListener {
        /**
         * Current wallpaper zoom out, where 0 is the closest, and 1 the farthest
         */
        fun onWallpaperZoomOutChanged(zoomOut: Float)
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
import android.util.MathUtils;
import android.util.Slog;
import android.view.Display;
import android.view.IWindowManager;
@@ -1156,6 +1157,15 @@ public class StatusBar extends SystemUI implements DemoMode,
        BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop);
        mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front),
                backdrop.findViewById(R.id.backdrop_back), mScrimController, mLockscreenWallpaper);
        float maxWallpaperZoom = mContext.getResources().getFloat(
                com.android.internal.R.dimen.config_wallpaperMaxScale);
        mNotificationShadeDepthControllerLazy.get().addListener(depth -> {
            float scale = MathUtils.lerp(maxWallpaperZoom, 1f, depth);
            backdrop.setPivotX(backdrop.getWidth() / 2f);
            backdrop.setPivotY(backdrop.getHeight() / 2f);
            backdrop.setScaleX(scale);
            backdrop.setScaleY(scale);
        });

        mNotificationPanelViewController.setUserSetupComplete(mUserSetup);
        if (UserManager.get(mContext).isUserSwitcherEnabled()) {
+7 −8
Original line number Diff line number Diff line
@@ -31,13 +31,13 @@ import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.NotificationShadeWindowController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.mockito.eq
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.eq
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.any
@@ -68,6 +68,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @Mock private lateinit var shadeAnimation: NotificationShadeDepthController.DepthAnimation
    @Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation
    @Mock private lateinit var brightnessSpring: NotificationShadeDepthController.DepthAnimation
    @Mock private lateinit var listener: NotificationShadeDepthController.DepthListener
    @Mock private lateinit var dozeParameters: DozeParameters
    @JvmField @Rule val mockitoRule = MockitoJUnit.rule()

@@ -103,7 +104,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {

    @Test
    fun setupListeners() {
        verify(dumpManager).registerDumpable(anyString(), safeEq(notificationShadeDepthController))
        verify(dumpManager).registerDumpable(anyString(), eq(notificationShadeDepthController))
    }

    @Test
@@ -171,7 +172,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
    @Test
    fun updateGlobalDialogVisibility_animatesBlur() {
        notificationShadeDepthController.updateGlobalDialogVisibility(0.5f, root)
        verify(globalActionsSpring).animateTo(eq(maxBlur / 2), safeEq(root))
        verify(globalActionsSpring).animateTo(eq(maxBlur / 2), eq(root))
    }

    @Test
@@ -191,8 +192,10 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {

    @Test
    fun updateBlurCallback_setsBlurAndZoom() {
        notificationShadeDepthController.addListener(listener)
        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(wallpaperManager).setWallpaperZoomOut(any(), anyFloat())
        verify(listener).onWallpaperZoomOutChanged(anyFloat())
        verify(blurUtils).applyBlur(any(), anyInt())
    }

@@ -245,7 +248,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {

        notificationShadeDepthController.updateBlurCallback.doFrame(0)
        verify(notificationShadeWindowController).setBackgroundBlurRadius(0)
        verify(blurUtils).applyBlur(safeEq(viewRootImpl), eq(0))
        verify(blurUtils).applyBlur(eq(viewRootImpl), eq(0))
    }

    @Test
@@ -267,8 +270,4 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
        verify(shadeSpring, never()).animateTo(anyInt(), any())
        verify(shadeAnimation, never()).animateTo(anyInt(), any())
    }

    private fun <T : Any> safeEq(value: T): T {
        return eq(value) ?: value
    }
}
 No newline at end of file