Skip to content
Snippets Groups Projects
Commit c4626463 authored by Matt Pietal's avatar Matt Pietal
Browse files

Controls - Handle launching/back from activities

Properly enter the control activities, allowing for bouncer, as well
handle all paths leaving the activities to go back to either
GlobalActions or the ControlsDialog.

Test: manual
Bug: 179782498
Change-Id: I2e00d76f6fe0d301588ff1a329d526a3da130d25
parent 01640845
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,8 @@ import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.controls.CustomIconCache
import com.android.systemui.controls.controller.ControlsControllerImpl
import com.android.systemui.controls.controller.StructureInfo
import com.android.systemui.controls.ui.ControlsDialog
import com.android.systemui.controls.ui.ControlsUiController
import com.android.systemui.globalactions.GlobalActionsComponent
import com.android.systemui.settings.CurrentUserTracker
import com.android.systemui.util.LifecycleActivity
......@@ -42,9 +44,10 @@ import javax.inject.Inject
*/
class ControlsEditingActivity @Inject constructor(
private val controller: ControlsControllerImpl,
broadcastDispatcher: BroadcastDispatcher,
private val broadcastDispatcher: BroadcastDispatcher,
private val globalActionsComponent: GlobalActionsComponent,
private val customIconCache: CustomIconCache
private val customIconCache: CustomIconCache,
private val uiController: ControlsUiController
) : LifecycleActivity() {
companion object {
......@@ -59,6 +62,7 @@ class ControlsEditingActivity @Inject constructor(
private lateinit var model: FavoritesModel
private lateinit var subtitle: TextView
private lateinit var saveButton: View
private var backToGlobalActions = true
private val currentUserTracker = object : CurrentUserTracker(broadcastDispatcher) {
private val startingUser = controller.currentUserId
......@@ -82,6 +86,11 @@ class ControlsEditingActivity @Inject constructor(
structure = it
} ?: run(this::finish)
backToGlobalActions = intent.getBooleanExtra(
ControlsUiController.BACK_TO_GLOBAL_ACTIONS,
true
)
bindViews()
bindButtons()
......@@ -100,7 +109,11 @@ class ControlsEditingActivity @Inject constructor(
}
override fun onBackPressed() {
globalActionsComponent.handleShowGlobalActionsMenu()
if (backToGlobalActions) {
globalActionsComponent.handleShowGlobalActionsMenu()
} else {
ControlsDialog(applicationContext, broadcastDispatcher).show(uiController)
}
animateExitAndFinish()
}
......
......@@ -40,6 +40,8 @@ import com.android.systemui.controls.ControlsServiceInfo
import com.android.systemui.controls.TooltipManager
import com.android.systemui.controls.controller.ControlsControllerImpl
import com.android.systemui.controls.controller.StructureInfo
import com.android.systemui.controls.ui.ControlsDialog
import com.android.systemui.controls.ui.ControlsUiController
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.globalactions.GlobalActionsComponent
import com.android.systemui.settings.CurrentUserTracker
......@@ -53,8 +55,9 @@ class ControlsFavoritingActivity @Inject constructor(
@Main private val executor: Executor,
private val controller: ControlsControllerImpl,
private val listingController: ControlsListingController,
broadcastDispatcher: BroadcastDispatcher,
private val globalActionsComponent: GlobalActionsComponent
private val broadcastDispatcher: BroadcastDispatcher,
private val globalActionsComponent: GlobalActionsComponent,
private val uiController: ControlsUiController
) : LifecycleActivity() {
companion object {
......@@ -89,6 +92,7 @@ class ControlsFavoritingActivity @Inject constructor(
private lateinit var comparator: Comparator<StructureContainer>
private var cancelLoadRunnable: Runnable? = null
private var isPagerLoaded = false
private var backToGlobalActions = true
private val currentUserTracker = object : CurrentUserTracker(broadcastDispatcher) {
private val startingUser = controller.currentUserId
......@@ -114,7 +118,7 @@ class ControlsFavoritingActivity @Inject constructor(
override fun onBackPressed() {
if (!fromProviderSelector) {
globalActionsComponent.handleShowGlobalActionsMenu()
openControlsOrigin()
}
animateExitAndFinish()
}
......@@ -129,6 +133,11 @@ class ControlsFavoritingActivity @Inject constructor(
component = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME)
fromProviderSelector = intent.getBooleanExtra(EXTRA_FROM_PROVIDER_SELECTOR, false)
backToGlobalActions = intent.getBooleanExtra(
ControlsUiController.BACK_TO_GLOBAL_ACTIONS,
true
)
bindViews()
}
......@@ -330,11 +339,19 @@ class ControlsFavoritingActivity @Inject constructor(
)
}
animateExitAndFinish()
globalActionsComponent.handleShowGlobalActionsMenu()
openControlsOrigin()
}
}
}
private fun openControlsOrigin() {
if (backToGlobalActions) {
globalActionsComponent.handleShowGlobalActionsMenu()
} else {
ControlsDialog(applicationContext, broadcastDispatcher).show(uiController)
}
}
override fun onPause() {
super.onPause()
mTooltipManager?.hide(false)
......
......@@ -67,7 +67,7 @@ class ControlsDialog @Inject constructor(
val vg = requireViewById<ViewGroup>(com.android.systemui.R.id.global_actions_controls)
vg.alpha = 0f
controller.show(vg, { /* do nothing */ }, false /* startedFromGlobalActions */)
controller.show(vg, { dismiss() }, false /* startedFromGlobalActions */)
vg.animate()
.alpha(1f)
......
......@@ -27,6 +27,7 @@ interface ControlsUiController {
companion object {
public const val TAG = "ControlsUiController"
public const val EXTRA_ANIMATE = "extra_animate"
public const val BACK_TO_GLOBAL_ACTIONS = "back_to_global_actions"
}
fun show(parent: ViewGroup, onDismiss: Runnable, startedFromGlobalActions: Boolean)
......
......@@ -266,6 +266,10 @@ 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)
intent.putExtra(
ControlsUiController.BACK_TO_GLOBAL_ACTIONS,
controlActionCoordinator.startedFromGlobalActions
)
onDismiss.run()
activityStarter.dismissKeyguardThenExecute({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment