From 68eb53e630d3669b5b3f6bbbe633ba1d213857b6 Mon Sep 17 00:00:00 2001 From: Santiago Etchebehere Date: Tue, 25 Feb 2020 14:25:34 -0800 Subject: [PATCH] Hook up zoom to GlobalActionsDialog Blur and zoom out wallpaper when GlobalActionsDialog comes up Bug: 149792636 Bug: 146387434 Test: atest NotificationShadeWindowViewTest Test: manual Change-Id: I003e83c6102163473c1dfd3cda1fa740c36253ad --- .../globalactions/GlobalActionsDialog.java | 25 ++++++++++--------- .../NotificationShadeDepthController.kt | 23 ++++++++++++++--- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index 27c81ce5321db..59b28b4372b41 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -99,7 +99,7 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; import com.android.systemui.plugins.GlobalActionsPanelPlugin; -import com.android.systemui.statusbar.BlurUtils; +import com.android.systemui.statusbar.NotificationShadeDepthController; import com.android.systemui.statusbar.phone.NotificationShadeWindowController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -162,7 +162,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final IActivityManager mIActivityManager; private final TelecomManager mTelecomManager; private final MetricsLogger mMetricsLogger; - private final BlurUtils mBlurUtils; + private final NotificationShadeDepthController mDepthController; private ArrayList mItems; private ActionsDialog mDialog; @@ -207,7 +207,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, KeyguardStateController keyguardStateController, UserManager userManager, TrustManager trustManager, IActivityManager iActivityManager, @Nullable TelecomManager telecomManager, MetricsLogger metricsLogger, - BlurUtils blurUtils, SysuiColorExtractor colorExtractor, + NotificationShadeDepthController depthController, SysuiColorExtractor colorExtractor, IStatusBarService statusBarService, NotificationShadeWindowController notificationShadeWindowController, ControlsUiController controlsUiController, IWindowManager iWindowManager, @@ -229,7 +229,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mIActivityManager = iActivityManager; mTelecomManager = telecomManager; mMetricsLogger = metricsLogger; - mBlurUtils = blurUtils; + mDepthController = depthController; mSysuiColorExtractor = colorExtractor; mStatusBarService = statusBarService; mNotificationShadeWindowController = notificationShadeWindowController; @@ -437,7 +437,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, : null; ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, panelViewController, - mBlurUtils, mSysuiColorExtractor, mStatusBarService, + mDepthController, mSysuiColorExtractor, mStatusBarService, mNotificationShadeWindowController, shouldShowControls() ? mControlsUiController : null); dialog.setCanceledOnTouchOutside(false); // Handled by the custom class. @@ -1570,20 +1570,21 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private ResetOrientationData mResetOrientationData; private boolean mHadTopUi; private final NotificationShadeWindowController mNotificationShadeWindowController; - private final BlurUtils mBlurUtils; + private final NotificationShadeDepthController mDepthController; private ControlsUiController mControlsUiController; private ViewGroup mControlsView; ActionsDialog(Context context, MyAdapter adapter, - GlobalActionsPanelPlugin.PanelViewController plugin, BlurUtils blurUtils, + GlobalActionsPanelPlugin.PanelViewController plugin, + NotificationShadeDepthController depthController, SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, NotificationShadeWindowController notificationShadeWindowController, ControlsUiController controlsUiController) { super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions); mContext = context; mAdapter = adapter; - mBlurUtils = blurUtils; + mDepthController = depthController; mColorExtractor = sysuiColorExtractor; mStatusBarService = statusBarService; mNotificationShadeWindowController = notificationShadeWindowController; @@ -1792,8 +1793,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, float animatedValue = animation.getAnimatedFraction(); int alpha = (int) (animatedValue * mScrimAlpha * 255); mBackgroundDrawable.setAlpha(alpha); - mBlurUtils.applyBlur(mGlobalActionsLayout.getViewRootImpl(), - mBlurUtils.blurRadiusOfRatio(animatedValue)); + mDepthController.updateGlobalDialogVisibility(animatedValue, + mGlobalActionsLayout); }) .start(); if (mControlsUiController != null) { @@ -1822,8 +1823,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, float animatedValue = 1f - animation.getAnimatedFraction(); int alpha = (int) (animatedValue * mScrimAlpha * 255); mBackgroundDrawable.setAlpha(alpha); - mBlurUtils.applyBlur(mGlobalActionsLayout.getViewRootImpl(), - mBlurUtils.blurRadiusOfRatio(animatedValue)); + mDepthController.updateGlobalDialogVisibility(animatedValue, + mGlobalActionsLayout); }) .start(); dismissPanel(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt index 901ed3f947606..eb8526d0ef91a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt @@ -58,6 +58,7 @@ class NotificationShadeDepthController @Inject constructor( } lateinit var root: View + private var blurRoot: View? = null private var keyguardAnimator: Animator? = null private var notificationAnimator: Animator? = null private var updateScheduled: Boolean = false @@ -72,6 +73,7 @@ class NotificationShadeDepthController @Inject constructor( return shadeBlurRadius.toFloat() } }) + private val zoomInterpolator = Interpolators.ACCELERATE_DECELERATE private var shadeBlurRadius = 0 set(value) { if (field == value) return @@ -84,6 +86,7 @@ class NotificationShadeDepthController @Inject constructor( field = value scheduleUpdate() } + private var globalDialogVisibility = 0f /** * Callback that updates the window blur value and is called only once per frame. @@ -91,9 +94,12 @@ class NotificationShadeDepthController @Inject constructor( private val updateBlurCallback = Choreographer.FrameCallback { updateScheduled = false - val blur = max(shadeBlurRadius, wakeAndUnlockBlurRadius) - blurUtils.applyBlur(root.viewRootImpl, blur) - wallpaperManager.setWallpaperZoomOut(root.windowToken, blurUtils.ratioOfBlurRadius(blur)) + val blur = max(shadeBlurRadius, + max(wakeAndUnlockBlurRadius, blurUtils.blurRadiusOfRatio(globalDialogVisibility))) + blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur) + val rawZoom = max(blurUtils.ratioOfBlurRadius(blur), globalDialogVisibility) + wallpaperManager.setWallpaperZoomOut(root.windowToken, + zoomInterpolator.getInterpolation(rawZoom)) } /** @@ -162,14 +168,23 @@ class NotificationShadeDepthController @Inject constructor( shadeSpring.animateToFinalPosition(newBlur.toFloat()) } - private fun scheduleUpdate() { + private fun scheduleUpdate(viewToBlur: View? = null) { if (updateScheduled) { return } updateScheduled = true + blurRoot = viewToBlur choreographer.postFrameCallback(updateBlurCallback) } + fun updateGlobalDialogVisibility(visibility: Float, dialogView: View) { + if (visibility == globalDialogVisibility) { + return + } + globalDialogVisibility = visibility + scheduleUpdate(dialogView) + } + override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array) { IndentingPrintWriter(pw, " ").let { it.println("StatusBarWindowBlurController:")