Merge "Hook up zoom to GlobalActionsDialog" into rvc-dev

This commit is contained in:
Santiago Etchebehere
2020-03-13 19:15:45 +00:00
committed by Android (Google) Code Review
2 changed files with 32 additions and 16 deletions

View File

@@ -99,7 +99,7 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager; import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
import com.android.systemui.plugins.GlobalActionsPanelPlugin; 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.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -162,7 +162,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
private final IActivityManager mIActivityManager; private final IActivityManager mIActivityManager;
private final TelecomManager mTelecomManager; private final TelecomManager mTelecomManager;
private final MetricsLogger mMetricsLogger; private final MetricsLogger mMetricsLogger;
private final BlurUtils mBlurUtils; private final NotificationShadeDepthController mDepthController;
private ArrayList<Action> mItems; private ArrayList<Action> mItems;
private ActionsDialog mDialog; private ActionsDialog mDialog;
@@ -207,7 +207,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
KeyguardStateController keyguardStateController, UserManager userManager, KeyguardStateController keyguardStateController, UserManager userManager,
TrustManager trustManager, IActivityManager iActivityManager, TrustManager trustManager, IActivityManager iActivityManager,
@Nullable TelecomManager telecomManager, MetricsLogger metricsLogger, @Nullable TelecomManager telecomManager, MetricsLogger metricsLogger,
BlurUtils blurUtils, SysuiColorExtractor colorExtractor, NotificationShadeDepthController depthController, SysuiColorExtractor colorExtractor,
IStatusBarService statusBarService, IStatusBarService statusBarService,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
ControlsUiController controlsUiController, IWindowManager iWindowManager, ControlsUiController controlsUiController, IWindowManager iWindowManager,
@@ -229,7 +229,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mIActivityManager = iActivityManager; mIActivityManager = iActivityManager;
mTelecomManager = telecomManager; mTelecomManager = telecomManager;
mMetricsLogger = metricsLogger; mMetricsLogger = metricsLogger;
mBlurUtils = blurUtils; mDepthController = depthController;
mSysuiColorExtractor = colorExtractor; mSysuiColorExtractor = colorExtractor;
mStatusBarService = statusBarService; mStatusBarService = statusBarService;
mNotificationShadeWindowController = notificationShadeWindowController; mNotificationShadeWindowController = notificationShadeWindowController;
@@ -437,7 +437,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
: null; : null;
ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, panelViewController, ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, panelViewController,
mBlurUtils, mSysuiColorExtractor, mStatusBarService, mDepthController, mSysuiColorExtractor, mStatusBarService,
mNotificationShadeWindowController, mNotificationShadeWindowController,
shouldShowControls() ? mControlsUiController : null); shouldShowControls() ? mControlsUiController : null);
dialog.setCanceledOnTouchOutside(false); // Handled by the custom class. dialog.setCanceledOnTouchOutside(false); // Handled by the custom class.
@@ -1570,20 +1570,21 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
private ResetOrientationData mResetOrientationData; private ResetOrientationData mResetOrientationData;
private boolean mHadTopUi; private boolean mHadTopUi;
private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationShadeWindowController mNotificationShadeWindowController;
private final BlurUtils mBlurUtils; private final NotificationShadeDepthController mDepthController;
private ControlsUiController mControlsUiController; private ControlsUiController mControlsUiController;
private ViewGroup mControlsView; private ViewGroup mControlsView;
ActionsDialog(Context context, MyAdapter adapter, ActionsDialog(Context context, MyAdapter adapter,
GlobalActionsPanelPlugin.PanelViewController plugin, BlurUtils blurUtils, GlobalActionsPanelPlugin.PanelViewController plugin,
NotificationShadeDepthController depthController,
SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
ControlsUiController controlsUiController) { ControlsUiController controlsUiController) {
super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions); super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions);
mContext = context; mContext = context;
mAdapter = adapter; mAdapter = adapter;
mBlurUtils = blurUtils; mDepthController = depthController;
mColorExtractor = sysuiColorExtractor; mColorExtractor = sysuiColorExtractor;
mStatusBarService = statusBarService; mStatusBarService = statusBarService;
mNotificationShadeWindowController = notificationShadeWindowController; mNotificationShadeWindowController = notificationShadeWindowController;
@@ -1792,8 +1793,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
float animatedValue = animation.getAnimatedFraction(); float animatedValue = animation.getAnimatedFraction();
int alpha = (int) (animatedValue * mScrimAlpha * 255); int alpha = (int) (animatedValue * mScrimAlpha * 255);
mBackgroundDrawable.setAlpha(alpha); mBackgroundDrawable.setAlpha(alpha);
mBlurUtils.applyBlur(mGlobalActionsLayout.getViewRootImpl(), mDepthController.updateGlobalDialogVisibility(animatedValue,
mBlurUtils.blurRadiusOfRatio(animatedValue)); mGlobalActionsLayout);
}) })
.start(); .start();
if (mControlsUiController != null) { if (mControlsUiController != null) {
@@ -1822,8 +1823,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
float animatedValue = 1f - animation.getAnimatedFraction(); float animatedValue = 1f - animation.getAnimatedFraction();
int alpha = (int) (animatedValue * mScrimAlpha * 255); int alpha = (int) (animatedValue * mScrimAlpha * 255);
mBackgroundDrawable.setAlpha(alpha); mBackgroundDrawable.setAlpha(alpha);
mBlurUtils.applyBlur(mGlobalActionsLayout.getViewRootImpl(), mDepthController.updateGlobalDialogVisibility(animatedValue,
mBlurUtils.blurRadiusOfRatio(animatedValue)); mGlobalActionsLayout);
}) })
.start(); .start();
dismissPanel(); dismissPanel();

View File

@@ -58,6 +58,7 @@ class NotificationShadeDepthController @Inject constructor(
} }
lateinit var root: View lateinit var root: View
private var blurRoot: View? = null
private var keyguardAnimator: Animator? = null private var keyguardAnimator: Animator? = null
private var notificationAnimator: Animator? = null private var notificationAnimator: Animator? = null
private var updateScheduled: Boolean = false private var updateScheduled: Boolean = false
@@ -72,6 +73,7 @@ class NotificationShadeDepthController @Inject constructor(
return shadeBlurRadius.toFloat() return shadeBlurRadius.toFloat()
} }
}) })
private val zoomInterpolator = Interpolators.ACCELERATE_DECELERATE
private var shadeBlurRadius = 0 private var shadeBlurRadius = 0
set(value) { set(value) {
if (field == value) return if (field == value) return
@@ -84,6 +86,7 @@ class NotificationShadeDepthController @Inject constructor(
field = value field = value
scheduleUpdate() scheduleUpdate()
} }
private var globalDialogVisibility = 0f
/** /**
* Callback that updates the window blur value and is called only once per frame. * 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 { private val updateBlurCallback = Choreographer.FrameCallback {
updateScheduled = false updateScheduled = false
val blur = max(shadeBlurRadius, wakeAndUnlockBlurRadius) val blur = max(shadeBlurRadius,
blurUtils.applyBlur(root.viewRootImpl, blur) max(wakeAndUnlockBlurRadius, blurUtils.blurRadiusOfRatio(globalDialogVisibility)))
wallpaperManager.setWallpaperZoomOut(root.windowToken, blurUtils.ratioOfBlurRadius(blur)) 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()) shadeSpring.animateToFinalPosition(newBlur.toFloat())
} }
private fun scheduleUpdate() { private fun scheduleUpdate(viewToBlur: View? = null) {
if (updateScheduled) { if (updateScheduled) {
return return
} }
updateScheduled = true updateScheduled = true
blurRoot = viewToBlur
choreographer.postFrameCallback(updateBlurCallback) 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<out String>) { override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) {
IndentingPrintWriter(pw, " ").let { IndentingPrintWriter(pw, " ").let {
it.println("StatusBarWindowBlurController:") it.println("StatusBarWindowBlurController:")