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

Commit 9766a0e7 authored by Caitlin Cassidy's avatar Caitlin Cassidy
Browse files

[Device Controls] In the device controls QS tile, have the subtitle show the...

[Device Controls] In the device controls QS tile, have the subtitle show the preferred structure name.

Fixes: 186428336
Test: Manual
Change-Id: I81953e7ae82fd1c8bf418a7f2251eef8554241ad
parent 69660aaf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -184,6 +184,9 @@ interface ControlsController : UserAwareController {
     */
    fun countFavoritesForComponent(componentName: ComponentName): Int

    /** See [ControlsUiController.getPreferredStructure]. */
    fun getPreferredStructure(): StructureInfo

    /**
     * Interface for structure to pass data to [ControlsFavoritingActivity].
     */
+4 −0
Original line number Diff line number Diff line
@@ -556,6 +556,10 @@ class ControlsControllerImpl @Inject constructor (
        )
    }

    override fun getPreferredStructure(): StructureInfo {
        return uiController.getPreferredStructure(getFavorites())
    }

    override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) {
        pw.println("ControlsController state:")
        pw.println("  Changing users: $userChanging")
+8 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context
import android.service.controls.Control
import android.service.controls.actions.ControlAction
import android.view.ViewGroup
import com.android.systemui.controls.controller.StructureInfo

interface ControlsUiController {
    companion object {
@@ -43,4 +44,11 @@ interface ControlsUiController {
        controlId: String,
        @ControlAction.ResponseResult response: Int
    )

    /**
     * Returns the structure that is currently preferred by the user.
     *
     * This structure will be the one that appears when the user first opens the controls activity.
     */
    fun getPreferredStructure(structures: List<StructureInfo>): StructureInfo
}
+2 −2
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ class ControlsUiControllerImpl @Inject constructor (
        controlActionCoordinator.activityContext = activityContext

        allStructures = controlsController.get().getFavorites()
        selectedStructure = loadPreference(allStructures)
        selectedStructure = getPreferredStructure(allStructures)

        if (controlsController.get().addSeedingFavoritesCallback(onSeedingComplete)) {
            listingCallback = createCallback(::showSeedingView)
@@ -448,7 +448,7 @@ class ControlsUiControllerImpl @Inject constructor (
        return maxColumns
    }

    private fun loadPreference(structures: List<StructureInfo>): StructureInfo {
    override fun getPreferredStructure(structures: List<StructureInfo>): StructureInfo {
        if (structures.isEmpty()) return EMPTY_STRUCTURE

        val component = sharedPreferences.getString(PREF_COMPONENT, null)?.let {
+2 −1
Original line number Diff line number Diff line
@@ -124,7 +124,8 @@ class DeviceControlsTile @Inject constructor(
        if (controlsComponent.isEnabled() && hasControlsApps.get()) {
            if (controlsComponent.getVisibility() == AVAILABLE) {
                state.state = Tile.STATE_ACTIVE
                state.secondaryLabel = ""
                state.secondaryLabel = controlsComponent
                        .getControlsController().get().getPreferredStructure().structure
            } else {
                state.state = Tile.STATE_INACTIVE
                state.secondaryLabel = mContext.getText(R.string.controls_tile_locked)
Loading