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

Fixes: 186428336
Test: Manual
Change-Id: I81953e7ae82fd1c8bf418a7f2251eef8554241ad
This commit is contained in:
Caitlin Cassidy
2021-05-21 20:30:10 +00:00
parent 69660aaf86
commit 9766a0e702
6 changed files with 23 additions and 3 deletions

View File

@@ -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].
*/

View File

@@ -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")

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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)

View File

@@ -16,6 +16,7 @@
package com.android.systemui.qs.tiles
import android.content.ComponentName
import android.os.Handler
import android.content.Context
import android.content.Intent
@@ -32,6 +33,7 @@ import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.classifier.FalsingManagerFake
import com.android.systemui.controls.ControlsServiceInfo
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.controls.controller.StructureInfo
import com.android.systemui.controls.dagger.ControlsComponent
import com.android.systemui.controls.management.ControlsListingController
import com.android.systemui.controls.ui.ControlsUiController
@@ -113,6 +115,8 @@ class DeviceControlsTileTest : SysuiTestCase() {
`when`(qsHost.uiEventLogger).thenReturn(uiEventLogger)
`when`(controlsComponent.isEnabled()).thenReturn(true)
`when`(keyguardStateController.isUnlocked()).thenReturn(true)
`when`(controlsController.getPreferredStructure())
.thenReturn(StructureInfo(ComponentName("pkg", "cls"), "structure", listOf()))
secureSettings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1)
setupControlsComponent()