Merge "Controls - Handle launching/back from activities" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5d22e6ad37
@@ -32,6 +32,8 @@ import com.android.systemui.broadcast.BroadcastDispatcher
|
|||||||
import com.android.systemui.controls.CustomIconCache
|
import com.android.systemui.controls.CustomIconCache
|
||||||
import com.android.systemui.controls.controller.ControlsControllerImpl
|
import com.android.systemui.controls.controller.ControlsControllerImpl
|
||||||
import com.android.systemui.controls.controller.StructureInfo
|
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.globalactions.GlobalActionsComponent
|
||||||
import com.android.systemui.settings.CurrentUserTracker
|
import com.android.systemui.settings.CurrentUserTracker
|
||||||
import com.android.systemui.util.LifecycleActivity
|
import com.android.systemui.util.LifecycleActivity
|
||||||
@@ -42,9 +44,10 @@ import javax.inject.Inject
|
|||||||
*/
|
*/
|
||||||
class ControlsEditingActivity @Inject constructor(
|
class ControlsEditingActivity @Inject constructor(
|
||||||
private val controller: ControlsControllerImpl,
|
private val controller: ControlsControllerImpl,
|
||||||
broadcastDispatcher: BroadcastDispatcher,
|
private val broadcastDispatcher: BroadcastDispatcher,
|
||||||
private val globalActionsComponent: GlobalActionsComponent,
|
private val globalActionsComponent: GlobalActionsComponent,
|
||||||
private val customIconCache: CustomIconCache
|
private val customIconCache: CustomIconCache,
|
||||||
|
private val uiController: ControlsUiController
|
||||||
) : LifecycleActivity() {
|
) : LifecycleActivity() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -59,6 +62,7 @@ class ControlsEditingActivity @Inject constructor(
|
|||||||
private lateinit var model: FavoritesModel
|
private lateinit var model: FavoritesModel
|
||||||
private lateinit var subtitle: TextView
|
private lateinit var subtitle: TextView
|
||||||
private lateinit var saveButton: View
|
private lateinit var saveButton: View
|
||||||
|
private var backToGlobalActions = true
|
||||||
|
|
||||||
private val currentUserTracker = object : CurrentUserTracker(broadcastDispatcher) {
|
private val currentUserTracker = object : CurrentUserTracker(broadcastDispatcher) {
|
||||||
private val startingUser = controller.currentUserId
|
private val startingUser = controller.currentUserId
|
||||||
@@ -82,6 +86,11 @@ class ControlsEditingActivity @Inject constructor(
|
|||||||
structure = it
|
structure = it
|
||||||
} ?: run(this::finish)
|
} ?: run(this::finish)
|
||||||
|
|
||||||
|
backToGlobalActions = intent.getBooleanExtra(
|
||||||
|
ControlsUiController.BACK_TO_GLOBAL_ACTIONS,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
bindViews()
|
bindViews()
|
||||||
|
|
||||||
bindButtons()
|
bindButtons()
|
||||||
@@ -100,7 +109,11 @@ class ControlsEditingActivity @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
globalActionsComponent.handleShowGlobalActionsMenu()
|
if (backToGlobalActions) {
|
||||||
|
globalActionsComponent.handleShowGlobalActionsMenu()
|
||||||
|
} else {
|
||||||
|
ControlsDialog(applicationContext, broadcastDispatcher).show(uiController)
|
||||||
|
}
|
||||||
animateExitAndFinish()
|
animateExitAndFinish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import com.android.systemui.controls.ControlsServiceInfo
|
|||||||
import com.android.systemui.controls.TooltipManager
|
import com.android.systemui.controls.TooltipManager
|
||||||
import com.android.systemui.controls.controller.ControlsControllerImpl
|
import com.android.systemui.controls.controller.ControlsControllerImpl
|
||||||
import com.android.systemui.controls.controller.StructureInfo
|
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.dagger.qualifiers.Main
|
||||||
import com.android.systemui.globalactions.GlobalActionsComponent
|
import com.android.systemui.globalactions.GlobalActionsComponent
|
||||||
import com.android.systemui.settings.CurrentUserTracker
|
import com.android.systemui.settings.CurrentUserTracker
|
||||||
@@ -53,8 +55,9 @@ class ControlsFavoritingActivity @Inject constructor(
|
|||||||
@Main private val executor: Executor,
|
@Main private val executor: Executor,
|
||||||
private val controller: ControlsControllerImpl,
|
private val controller: ControlsControllerImpl,
|
||||||
private val listingController: ControlsListingController,
|
private val listingController: ControlsListingController,
|
||||||
broadcastDispatcher: BroadcastDispatcher,
|
private val broadcastDispatcher: BroadcastDispatcher,
|
||||||
private val globalActionsComponent: GlobalActionsComponent
|
private val globalActionsComponent: GlobalActionsComponent,
|
||||||
|
private val uiController: ControlsUiController
|
||||||
) : LifecycleActivity() {
|
) : LifecycleActivity() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -89,6 +92,7 @@ class ControlsFavoritingActivity @Inject constructor(
|
|||||||
private lateinit var comparator: Comparator<StructureContainer>
|
private lateinit var comparator: Comparator<StructureContainer>
|
||||||
private var cancelLoadRunnable: Runnable? = null
|
private var cancelLoadRunnable: Runnable? = null
|
||||||
private var isPagerLoaded = false
|
private var isPagerLoaded = false
|
||||||
|
private var backToGlobalActions = true
|
||||||
|
|
||||||
private val currentUserTracker = object : CurrentUserTracker(broadcastDispatcher) {
|
private val currentUserTracker = object : CurrentUserTracker(broadcastDispatcher) {
|
||||||
private val startingUser = controller.currentUserId
|
private val startingUser = controller.currentUserId
|
||||||
@@ -114,7 +118,7 @@ class ControlsFavoritingActivity @Inject constructor(
|
|||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (!fromProviderSelector) {
|
if (!fromProviderSelector) {
|
||||||
globalActionsComponent.handleShowGlobalActionsMenu()
|
openControlsOrigin()
|
||||||
}
|
}
|
||||||
animateExitAndFinish()
|
animateExitAndFinish()
|
||||||
}
|
}
|
||||||
@@ -129,6 +133,11 @@ class ControlsFavoritingActivity @Inject constructor(
|
|||||||
component = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME)
|
component = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME)
|
||||||
fromProviderSelector = intent.getBooleanExtra(EXTRA_FROM_PROVIDER_SELECTOR, false)
|
fromProviderSelector = intent.getBooleanExtra(EXTRA_FROM_PROVIDER_SELECTOR, false)
|
||||||
|
|
||||||
|
backToGlobalActions = intent.getBooleanExtra(
|
||||||
|
ControlsUiController.BACK_TO_GLOBAL_ACTIONS,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
bindViews()
|
bindViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,11 +339,19 @@ class ControlsFavoritingActivity @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
animateExitAndFinish()
|
animateExitAndFinish()
|
||||||
globalActionsComponent.handleShowGlobalActionsMenu()
|
openControlsOrigin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openControlsOrigin() {
|
||||||
|
if (backToGlobalActions) {
|
||||||
|
globalActionsComponent.handleShowGlobalActionsMenu()
|
||||||
|
} else {
|
||||||
|
ControlsDialog(applicationContext, broadcastDispatcher).show(uiController)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
mTooltipManager?.hide(false)
|
mTooltipManager?.hide(false)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class ControlsDialog @Inject constructor(
|
|||||||
|
|
||||||
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 */ }, false /* startedFromGlobalActions */)
|
controller.show(vg, { dismiss() }, false /* startedFromGlobalActions */)
|
||||||
|
|
||||||
vg.animate()
|
vg.animate()
|
||||||
.alpha(1f)
|
.alpha(1f)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ interface ControlsUiController {
|
|||||||
companion object {
|
companion object {
|
||||||
public const val TAG = "ControlsUiController"
|
public const val TAG = "ControlsUiController"
|
||||||
public const val EXTRA_ANIMATE = "extra_animate"
|
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)
|
fun show(parent: ViewGroup, onDismiss: Runnable, startedFromGlobalActions: Boolean)
|
||||||
|
|||||||
@@ -266,6 +266,10 @@ 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)
|
||||||
|
intent.putExtra(
|
||||||
|
ControlsUiController.BACK_TO_GLOBAL_ACTIONS,
|
||||||
|
controlActionCoordinator.startedFromGlobalActions
|
||||||
|
)
|
||||||
onDismiss.run()
|
onDismiss.run()
|
||||||
|
|
||||||
activityStarter.dismissKeyguardThenExecute({
|
activityStarter.dismissKeyguardThenExecute({
|
||||||
|
|||||||
Reference in New Issue
Block a user