Merge "Controls in Lockscreen Dialog" into sc-dev
This commit is contained in:
@@ -24,6 +24,9 @@ import android.service.controls.Control
|
|||||||
*/
|
*/
|
||||||
interface ControlActionCoordinator {
|
interface ControlActionCoordinator {
|
||||||
|
|
||||||
|
// Handle actions launched from GlobalActionsDialog or ControlDialog
|
||||||
|
var startedFromGlobalActions: Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close any dialogs which may have been open
|
* Close any dialogs which may have been open
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.service.controls.actions.CommandAction
|
|||||||
import android.service.controls.actions.FloatAction
|
import android.service.controls.actions.FloatAction
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
|
import com.android.systemui.broadcast.BroadcastDispatcher
|
||||||
import com.android.systemui.dagger.SysUISingleton
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
import com.android.systemui.dagger.qualifiers.Main
|
import com.android.systemui.dagger.qualifiers.Main
|
||||||
import com.android.systemui.globalactions.GlobalActionsComponent
|
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.statusbar.policy.KeyguardStateController
|
||||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||||
import com.android.wm.shell.TaskViewFactory
|
import com.android.wm.shell.TaskViewFactory
|
||||||
|
import dagger.Lazy
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -48,13 +50,17 @@ class ControlActionCoordinatorImpl @Inject constructor(
|
|||||||
private val activityStarter: ActivityStarter,
|
private val activityStarter: ActivityStarter,
|
||||||
private val keyguardStateController: KeyguardStateController,
|
private val keyguardStateController: KeyguardStateController,
|
||||||
private val globalActionsComponent: GlobalActionsComponent,
|
private val globalActionsComponent: GlobalActionsComponent,
|
||||||
private val taskViewFactory: Optional<TaskViewFactory>
|
private val taskViewFactory: Optional<TaskViewFactory>,
|
||||||
|
private val broadcastDispatcher: BroadcastDispatcher,
|
||||||
|
private val lazyUiController: Lazy<ControlsUiController>
|
||||||
) : ControlActionCoordinator {
|
) : ControlActionCoordinator {
|
||||||
private var dialog: Dialog? = null
|
private var dialog: Dialog? = null
|
||||||
private val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
private val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||||
private var pendingAction: Action? = null
|
private var pendingAction: Action? = null
|
||||||
private var actionsInProgress = mutableSetOf<String>()
|
private var actionsInProgress = mutableSetOf<String>()
|
||||||
|
|
||||||
|
override var startedFromGlobalActions: Boolean = true
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val RESPONSE_TIMEOUT_IN_MILLIS = 3000L
|
private const val RESPONSE_TIMEOUT_IN_MILLIS = 3000L
|
||||||
}
|
}
|
||||||
@@ -131,8 +137,8 @@ class ControlActionCoordinatorImpl @Inject constructor(
|
|||||||
|
|
||||||
private fun bouncerOrRun(action: Action) {
|
private fun bouncerOrRun(action: Action) {
|
||||||
if (keyguardStateController.isShowing()) {
|
if (keyguardStateController.isShowing()) {
|
||||||
var closeGlobalActions = !keyguardStateController.isUnlocked()
|
var closeDialog = !keyguardStateController.isUnlocked()
|
||||||
if (closeGlobalActions) {
|
if (closeDialog) {
|
||||||
context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
|
context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
|
||||||
|
|
||||||
// pending actions will only run after the control state has been refreshed
|
// pending actions will only run after the control state has been refreshed
|
||||||
@@ -141,8 +147,12 @@ class ControlActionCoordinatorImpl @Inject constructor(
|
|||||||
|
|
||||||
activityStarter.dismissKeyguardThenExecute({
|
activityStarter.dismissKeyguardThenExecute({
|
||||||
Log.d(ControlsUiController.TAG, "Device unlocked, invoking controls action")
|
Log.d(ControlsUiController.TAG, "Device unlocked, invoking controls action")
|
||||||
if (closeGlobalActions) {
|
if (closeDialog) {
|
||||||
globalActionsComponent.handleShowGlobalActionsMenu()
|
if (startedFromGlobalActions) {
|
||||||
|
globalActionsComponent.handleShowGlobalActionsMenu()
|
||||||
|
} else {
|
||||||
|
ControlsDialog(context, broadcastDispatcher).show(lazyUiController.get())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
action.invoke()
|
action.invoke()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class ControlsDialog(
|
|||||||
|
|
||||||
val vg = requireViewById<ViewGroup>(com.android.systemui.R.id.global_actions_controls)
|
val vg = requireViewById<ViewGroup>(com.android.systemui.R.id.global_actions_controls)
|
||||||
vg.alpha = 0f
|
vg.alpha = 0f
|
||||||
controller.show(vg, { /* do nothing */ })
|
controller.show(vg, { /* do nothing */ }, false /* startedFromGlobalActions */)
|
||||||
|
|
||||||
vg.animate()
|
vg.animate()
|
||||||
.alpha(1f)
|
.alpha(1f)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ interface ControlsUiController {
|
|||||||
public const val EXTRA_ANIMATE = "extra_animate"
|
public const val EXTRA_ANIMATE = "extra_animate"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun show(parent: ViewGroup, dismissGlobalActions: Runnable)
|
fun show(parent: ViewGroup, onDismiss: Runnable, startedFromGlobalActions: Boolean)
|
||||||
fun hide()
|
fun hide()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
private lateinit var lastItems: List<SelectionItem>
|
private lateinit var lastItems: List<SelectionItem>
|
||||||
private var popup: ListPopupWindow? = null
|
private var popup: ListPopupWindow? = null
|
||||||
private var hidden = true
|
private var hidden = true
|
||||||
private lateinit var dismissGlobalActions: Runnable
|
private lateinit var onDismiss: Runnable
|
||||||
private val popupThemedContext = ContextThemeWrapper(context, R.style.Control_ListPopupWindow)
|
private val popupThemedContext = ContextThemeWrapper(context, R.style.Control_ListPopupWindow)
|
||||||
private var retainCache = false
|
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()")
|
Log.d(ControlsUiController.TAG, "show()")
|
||||||
this.parent = parent
|
this.parent = parent
|
||||||
this.dismissGlobalActions = dismissGlobalActions
|
this.onDismiss = onDismiss
|
||||||
hidden = false
|
hidden = false
|
||||||
retainCache = false
|
retainCache = false
|
||||||
|
|
||||||
|
controlActionCoordinator.startedFromGlobalActions = startedFromGlobalActions
|
||||||
|
|
||||||
allStructures = controlsController.get().getFavorites()
|
allStructures = controlsController.get().getFavorites()
|
||||||
selectedStructure = loadPreference(allStructures)
|
selectedStructure = loadPreference(allStructures)
|
||||||
|
|
||||||
@@ -187,7 +193,7 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
controlViewsById.clear()
|
controlViewsById.clear()
|
||||||
controlsById.clear()
|
controlsById.clear()
|
||||||
|
|
||||||
show(parent, dismissGlobalActions)
|
show(parent, onDismiss, controlActionCoordinator.startedFromGlobalActions)
|
||||||
val showAnim = ObjectAnimator.ofFloat(parent, "alpha", 0.0f, 1.0f)
|
val showAnim = ObjectAnimator.ofFloat(parent, "alpha", 0.0f, 1.0f)
|
||||||
showAnim.setInterpolator(DecelerateInterpolator(1.0f))
|
showAnim.setInterpolator(DecelerateInterpolator(1.0f))
|
||||||
showAnim.setDuration(FADE_IN_MILLIS)
|
showAnim.setDuration(FADE_IN_MILLIS)
|
||||||
@@ -260,7 +266,7 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
private fun startActivity(context: Context, intent: Intent) {
|
private fun startActivity(context: Context, intent: Intent) {
|
||||||
// Force animations when transitioning from a dialog to an activity
|
// Force animations when transitioning from a dialog to an activity
|
||||||
intent.putExtra(ControlsUiController.EXTRA_ANIMATE, true)
|
intent.putExtra(ControlsUiController.EXTRA_ANIMATE, true)
|
||||||
dismissGlobalActions.run()
|
onDismiss.run()
|
||||||
|
|
||||||
activityStarter.dismissKeyguardThenExecute({
|
activityStarter.dismissKeyguardThenExecute({
|
||||||
shadeController.collapsePanel(false)
|
shadeController.collapsePanel(false)
|
||||||
|
|||||||
@@ -2229,7 +2229,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
|
|
||||||
private void showControls(ControlsUiController controller) {
|
private void showControls(ControlsUiController controller) {
|
||||||
mControlsUiController = controller;
|
mControlsUiController = controller;
|
||||||
mControlsUiController.show(mControlsView, this::dismissForControlsActivity);
|
mControlsUiController.show(mControlsView, this::dismissForControlsActivity,
|
||||||
|
true /* startedFromGlobalActions */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWalletViewAvailable() {
|
private boolean isWalletViewAvailable() {
|
||||||
@@ -2457,7 +2458,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
return WindowInsets.CONSUMED;
|
return WindowInsets.CONSUMED;
|
||||||
});
|
});
|
||||||
if (mControlsUiController != null) {
|
if (mControlsUiController != null) {
|
||||||
mControlsUiController.show(mControlsView, this::dismissForControlsActivity);
|
mControlsUiController.show(mControlsView, this::dismissForControlsActivity,
|
||||||
|
true /* startedFromGlobalActions */);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBackgroundDrawable.setAlpha(0);
|
mBackgroundDrawable.setAlpha(0);
|
||||||
@@ -2632,7 +2634,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
initializeLayout();
|
initializeLayout();
|
||||||
mGlobalActionsLayout.updateList();
|
mGlobalActionsLayout.updateList();
|
||||||
if (mControlsUiController != null) {
|
if (mControlsUiController != null) {
|
||||||
mControlsUiController.show(mControlsView, this::dismissForControlsActivity);
|
mControlsUiController.show(mControlsView, this::dismissForControlsActivity,
|
||||||
|
true /* startedFromGlobalActions */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user