Merge "[Device Controls] In the device controls QS tile, have the subtitle show the preferred structure name." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2cca71c0bf
@@ -184,6 +184,9 @@ interface ControlsController : UserAwareController {
|
|||||||
*/
|
*/
|
||||||
fun countFavoritesForComponent(componentName: ComponentName): Int
|
fun countFavoritesForComponent(componentName: ComponentName): Int
|
||||||
|
|
||||||
|
/** See [ControlsUiController.getPreferredStructure]. */
|
||||||
|
fun getPreferredStructure(): StructureInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for structure to pass data to [ControlsFavoritingActivity].
|
* Interface for structure to pass data to [ControlsFavoritingActivity].
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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>) {
|
override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) {
|
||||||
pw.println("ControlsController state:")
|
pw.println("ControlsController state:")
|
||||||
pw.println(" Changing users: $userChanging")
|
pw.println(" Changing users: $userChanging")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.content.Context
|
|||||||
import android.service.controls.Control
|
import android.service.controls.Control
|
||||||
import android.service.controls.actions.ControlAction
|
import android.service.controls.actions.ControlAction
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.android.systemui.controls.controller.StructureInfo
|
||||||
|
|
||||||
interface ControlsUiController {
|
interface ControlsUiController {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -43,4 +44,11 @@ interface ControlsUiController {
|
|||||||
controlId: String,
|
controlId: String,
|
||||||
@ControlAction.ResponseResult response: Int
|
@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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
controlActionCoordinator.activityContext = activityContext
|
controlActionCoordinator.activityContext = activityContext
|
||||||
|
|
||||||
allStructures = controlsController.get().getFavorites()
|
allStructures = controlsController.get().getFavorites()
|
||||||
selectedStructure = loadPreference(allStructures)
|
selectedStructure = getPreferredStructure(allStructures)
|
||||||
|
|
||||||
if (controlsController.get().addSeedingFavoritesCallback(onSeedingComplete)) {
|
if (controlsController.get().addSeedingFavoritesCallback(onSeedingComplete)) {
|
||||||
listingCallback = createCallback(::showSeedingView)
|
listingCallback = createCallback(::showSeedingView)
|
||||||
@@ -448,7 +448,7 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
return maxColumns
|
return maxColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadPreference(structures: List<StructureInfo>): StructureInfo {
|
override fun getPreferredStructure(structures: List<StructureInfo>): StructureInfo {
|
||||||
if (structures.isEmpty()) return EMPTY_STRUCTURE
|
if (structures.isEmpty()) return EMPTY_STRUCTURE
|
||||||
|
|
||||||
val component = sharedPreferences.getString(PREF_COMPONENT, null)?.let {
|
val component = sharedPreferences.getString(PREF_COMPONENT, null)?.let {
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ class DeviceControlsTile @Inject constructor(
|
|||||||
if (controlsComponent.isEnabled() && hasControlsApps.get()) {
|
if (controlsComponent.isEnabled() && hasControlsApps.get()) {
|
||||||
if (controlsComponent.getVisibility() == AVAILABLE) {
|
if (controlsComponent.getVisibility() == AVAILABLE) {
|
||||||
state.state = Tile.STATE_ACTIVE
|
state.state = Tile.STATE_ACTIVE
|
||||||
state.secondaryLabel = ""
|
state.secondaryLabel = controlsComponent
|
||||||
|
.getControlsController().get().getPreferredStructure().structure
|
||||||
} else {
|
} else {
|
||||||
state.state = Tile.STATE_INACTIVE
|
state.state = Tile.STATE_INACTIVE
|
||||||
state.secondaryLabel = mContext.getText(R.string.controls_tile_locked)
|
state.secondaryLabel = mContext.getText(R.string.controls_tile_locked)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.qs.tiles
|
package com.android.systemui.qs.tiles
|
||||||
|
|
||||||
|
import android.content.ComponentName
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -32,6 +33,7 @@ import com.android.systemui.animation.ActivityLaunchAnimator
|
|||||||
import com.android.systemui.classifier.FalsingManagerFake
|
import com.android.systemui.classifier.FalsingManagerFake
|
||||||
import com.android.systemui.controls.ControlsServiceInfo
|
import com.android.systemui.controls.ControlsServiceInfo
|
||||||
import com.android.systemui.controls.controller.ControlsController
|
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.dagger.ControlsComponent
|
||||||
import com.android.systemui.controls.management.ControlsListingController
|
import com.android.systemui.controls.management.ControlsListingController
|
||||||
import com.android.systemui.controls.ui.ControlsUiController
|
import com.android.systemui.controls.ui.ControlsUiController
|
||||||
@@ -113,6 +115,8 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
|||||||
`when`(qsHost.uiEventLogger).thenReturn(uiEventLogger)
|
`when`(qsHost.uiEventLogger).thenReturn(uiEventLogger)
|
||||||
`when`(controlsComponent.isEnabled()).thenReturn(true)
|
`when`(controlsComponent.isEnabled()).thenReturn(true)
|
||||||
`when`(keyguardStateController.isUnlocked()).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)
|
secureSettings.putInt(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 1)
|
||||||
|
|
||||||
setupControlsComponent()
|
setupControlsComponent()
|
||||||
|
|||||||
Reference in New Issue
Block a user