From d62b8cf81ffcffc7eea172295195372e3a684ee7 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 9 Feb 2021 10:59:36 -0500 Subject: [PATCH] Controls in Lockscreen Dialog After an action is taken by the user while the device is locked, we need to start the bouncer and continue the action after successful unlock. This action now supports either launching the GlobalActionsDialog again or continuing in the newer dialog. Bug: 179782498 Test: manual Change-Id: I3829bed7e999fcfc2924d19e0f2ab0cac0afcb77 --- .../controls/ui/ControlActionCoordinator.kt | 3 +++ .../ui/ControlActionCoordinatorImpl.kt | 20 ++++++++++++++----- .../systemui/controls/ui/ControlsDialog.kt | 2 +- .../controls/ui/ControlsUiController.kt | 2 +- .../controls/ui/ControlsUiControllerImpl.kt | 16 ++++++++++----- .../globalactions/GlobalActionsDialog.java | 9 ++++++--- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt index 429f67fdc706a..d06568a7caf9a 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinator.kt @@ -24,6 +24,9 @@ import android.service.controls.Control */ interface ControlActionCoordinator { + // Handle actions launched from GlobalActionsDialog or ControlDialog + var startedFromGlobalActions: Boolean + /** * Close any dialogs which may have been open */ diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt index 7cd7e18965c27..247f25e1ccea3 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlActionCoordinatorImpl.kt @@ -30,6 +30,7 @@ import android.service.controls.actions.CommandAction import android.service.controls.actions.FloatAction import android.util.Log import android.view.HapticFeedbackConstants +import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.globalactions.GlobalActionsComponent @@ -37,6 +38,7 @@ import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.concurrency.DelayableExecutor import com.android.wm.shell.TaskViewFactory +import dagger.Lazy import java.util.Optional import javax.inject.Inject @@ -48,13 +50,17 @@ class ControlActionCoordinatorImpl @Inject constructor( private val activityStarter: ActivityStarter, private val keyguardStateController: KeyguardStateController, private val globalActionsComponent: GlobalActionsComponent, - private val taskViewFactory: Optional + private val taskViewFactory: Optional, + private val broadcastDispatcher: BroadcastDispatcher, + private val lazyUiController: Lazy ) : ControlActionCoordinator { private var dialog: Dialog? = null private val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator private var pendingAction: Action? = null private var actionsInProgress = mutableSetOf() + override var startedFromGlobalActions: Boolean = true + companion object { private const val RESPONSE_TIMEOUT_IN_MILLIS = 3000L } @@ -131,8 +137,8 @@ class ControlActionCoordinatorImpl @Inject constructor( private fun bouncerOrRun(action: Action) { if (keyguardStateController.isShowing()) { - var closeGlobalActions = !keyguardStateController.isUnlocked() - if (closeGlobalActions) { + var closeDialog = !keyguardStateController.isUnlocked() + if (closeDialog) { context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) // pending actions will only run after the control state has been refreshed @@ -141,8 +147,12 @@ class ControlActionCoordinatorImpl @Inject constructor( activityStarter.dismissKeyguardThenExecute({ Log.d(ControlsUiController.TAG, "Device unlocked, invoking controls action") - if (closeGlobalActions) { - globalActionsComponent.handleShowGlobalActionsMenu() + if (closeDialog) { + if (startedFromGlobalActions) { + globalActionsComponent.handleShowGlobalActionsMenu() + } else { + ControlsDialog(context, broadcastDispatcher).show(lazyUiController.get()) + } } else { action.invoke() } diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt index 8e878cf76ad98..f533cfb470768 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsDialog.kt @@ -66,7 +66,7 @@ class ControlsDialog( val vg = requireViewById(com.android.systemui.R.id.global_actions_controls) vg.alpha = 0f - controller.show(vg, { /* do nothing */ }) + controller.show(vg, { /* do nothing */ }, false /* startedFromGlobalActions */) vg.animate() .alpha(1f) diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt index 4e4c82cabaa09..9448877417214 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiController.kt @@ -29,7 +29,7 @@ interface ControlsUiController { public const val EXTRA_ANIMATE = "extra_animate" } - fun show(parent: ViewGroup, dismissGlobalActions: Runnable) + fun show(parent: ViewGroup, onDismiss: Runnable, startedFromGlobalActions: Boolean) fun hide() /** diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt index 2b529f9a6cdeb..762362cde0952 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt @@ -102,7 +102,7 @@ class ControlsUiControllerImpl @Inject constructor ( private lateinit var lastItems: List private var popup: ListPopupWindow? = null private var hidden = true - private lateinit var dismissGlobalActions: Runnable + private lateinit var onDismiss: Runnable private val popupThemedContext = ContextThemeWrapper(context, R.style.Control_ListPopupWindow) private var retainCache = false @@ -145,13 +145,19 @@ class ControlsUiControllerImpl @Inject constructor ( } } - override fun show(parent: ViewGroup, dismissGlobalActions: Runnable) { + override fun show( + parent: ViewGroup, + onDismiss: Runnable, + startedFromGlobalActions: Boolean + ) { Log.d(ControlsUiController.TAG, "show()") this.parent = parent - this.dismissGlobalActions = dismissGlobalActions + this.onDismiss = onDismiss hidden = false retainCache = false + controlActionCoordinator.startedFromGlobalActions = startedFromGlobalActions + allStructures = controlsController.get().getFavorites() selectedStructure = loadPreference(allStructures) @@ -187,7 +193,7 @@ class ControlsUiControllerImpl @Inject constructor ( controlViewsById.clear() controlsById.clear() - show(parent, dismissGlobalActions) + show(parent, onDismiss, controlActionCoordinator.startedFromGlobalActions) val showAnim = ObjectAnimator.ofFloat(parent, "alpha", 0.0f, 1.0f) showAnim.setInterpolator(DecelerateInterpolator(1.0f)) showAnim.setDuration(FADE_IN_MILLIS) @@ -260,7 +266,7 @@ class ControlsUiControllerImpl @Inject constructor ( private fun startActivity(context: Context, intent: Intent) { // Force animations when transitioning from a dialog to an activity intent.putExtra(ControlsUiController.EXTRA_ANIMATE, true) - dismissGlobalActions.run() + onDismiss.run() activityStarter.dismissKeyguardThenExecute({ shadeController.collapsePanel(false) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index ad4c447679956..8af45a5c0ef10 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -2229,7 +2229,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private void showControls(ControlsUiController controller) { mControlsUiController = controller; - mControlsUiController.show(mControlsView, this::dismissForControlsActivity); + mControlsUiController.show(mControlsView, this::dismissForControlsActivity, + true /* startedFromGlobalActions */); } private boolean isWalletViewAvailable() { @@ -2457,7 +2458,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return WindowInsets.CONSUMED; }); if (mControlsUiController != null) { - mControlsUiController.show(mControlsView, this::dismissForControlsActivity); + mControlsUiController.show(mControlsView, this::dismissForControlsActivity, + true /* startedFromGlobalActions */); } mBackgroundDrawable.setAlpha(0); @@ -2632,7 +2634,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, initializeLayout(); mGlobalActionsLayout.updateList(); if (mControlsUiController != null) { - mControlsUiController.show(mControlsView, this::dismissForControlsActivity); + mControlsUiController.show(mControlsView, this::dismissForControlsActivity, + true /* startedFromGlobalActions */); } }