Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c076335 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Controls - Handle launching/back from activities" into sc-dev am: 5d22e6ad

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13606205

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idc2abb54d2a5478252c15a80a91153e55cd7fcbf
parents f1a14bcf 5d22e6ad
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -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() {
        if (backToGlobalActions) {
            globalActionsComponent.handleShowGlobalActionsMenu()
        } else {
            ControlsDialog(applicationContext, broadcastDispatcher).show(uiController)
        }
        animateExitAndFinish()
    }

+21 −4
Original line number Diff line number Diff line
@@ -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,9 +339,17 @@ class ControlsFavoritingActivity @Inject constructor(
                    )
                }
                animateExitAndFinish()
                globalActionsComponent.handleShowGlobalActionsMenu()
                openControlsOrigin()
            }
        }
    }

    private fun openControlsOrigin() {
        if (backToGlobalActions) {
            globalActionsComponent.handleShowGlobalActionsMenu()
        } else {
            ControlsDialog(applicationContext, broadcastDispatcher).show(uiController)
        }
    }

    override fun onPause() {
+1 −1
Original line number Diff line number Diff line
@@ -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)
+1 −0
Original line number Diff line number Diff line
@@ -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)
+4 −0
Original line number Diff line number Diff line
@@ -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({