Load tile icons while mapping state Previously we provided code to load icon instead of actually doing the loading in the mapper. This CL reduces thread contention among tiles by moving the mapping to UiBackground thread. The QSTileState no longer needs icon suppliers. Just icons. Flag: com.android.systemui.qs_new_tiles Fixes: 376115950 Test: atest AirplaneModeMapperTest Test: atest AlarmTileMapperTest Test: atest BatterySaverTileMapperTest Test: atest FlashlightMapperTest Test: atest FontScalingTileMapperTest Test: atest InternetTileMapperTest Test: atest IssueRecordingMapperTest Test: atest LocationTileMapperTest Test: atest OneHandedModeTileMapperTest Test: atest QRCodeScannerTileMapperTest Test: atest ReduceBrightColorsTileMapperTest Test: atest RotationLockTileMapperTest Test: atest SensorPrivacyToggleTileMapperTest Test: atest WorkModeTileMapperTest Change-Id: Iff35ce6687e96aff12301667a045d8e604df2199
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt index ff40e43..a063531 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
@@ -115,7 +115,7 @@ underTest.logUserActionPipeline( TileSpec.create("test_spec"), QSTileUserAction.Click(null), - QSTileState.build({ Icon.Resource(0, ContentDescription.Resource(0)) }, "") {}, + QSTileState.build(Icon.Resource(0, ContentDescription.Resource(0)), "") {}, "test_data", ) @@ -141,7 +141,7 @@ fun testLogStateUpdate() { underTest.logStateUpdate( TileSpec.create("test_spec"), - QSTileState.build({ Icon.Resource(0, ContentDescription.Resource(0)) }, "") {}, + QSTileState.build(Icon.Resource(0, ContentDescription.Resource(0)), "") {}, "test_data", ) @@ -162,18 +162,14 @@ @Test fun testLogForceUpdate() { - underTest.logForceUpdate( - TileSpec.create("test_spec"), - ) + underTest.logForceUpdate(TileSpec.create("test_spec")) assertThat(logBuffer.getStringBuffer()).contains("tile data force update") } @Test fun testLogInitialUpdate() { - underTest.logInitialRequest( - TileSpec.create("test_spec"), - ) + underTest.logInitialRequest(TileSpec.create("test_spec")) assertThat(logBuffer.getStringBuffer()).contains("tile data initial update") }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt index c918ed8..056efb3 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt
@@ -85,8 +85,8 @@ object : QSTileDataToStateMapper<Any> { override fun map(config: QSTileConfig, data: Any): QSTileState = QSTileState.build( - { Icon.Resource(0, ContentDescription.Resource(0)) }, - data.toString() + Icon.Resource(0, ContentDescription.Resource(0)), + data.toString(), ) {} } }, @@ -116,7 +116,7 @@ .isEqualTo( "test_spec:\n" + " QSTileState(" + - "icon=() -> com.android.systemui.common.shared.model.Icon?, " + + "icon=Resource(res=0, contentDescription=Resource(res=0)), " + "iconRes=null, " + "label=test_data, " + "activationState=INACTIVE, " +
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt index 5a73fe2..00460bf 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/AirplaneModeMapperTest.kt
@@ -66,7 +66,7 @@ createAirplaneModeState( QSTileState.ActivationState.ACTIVE, context.resources.getStringArray(R.array.tile_states_airplane)[Tile.STATE_ACTIVE], - R.drawable.qs_airplane_icon_on + R.drawable.qs_airplane_icon_on, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -81,7 +81,7 @@ createAirplaneModeState( QSTileState.ActivationState.INACTIVE, context.resources.getStringArray(R.array.tile_states_airplane)[Tile.STATE_INACTIVE], - R.drawable.qs_airplane_icon_off + R.drawable.qs_airplane_icon_off, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -89,11 +89,11 @@ private fun createAirplaneModeState( activationState: QSTileState.ActivationState, secondaryLabel: String, - iconRes: Int + iconRes: Int, ): QSTileState { val label = context.getString(R.string.airplane_mode) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -103,7 +103,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt index 79e4fef..632aae0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt
@@ -51,7 +51,7 @@ .apply { addOverride(R.drawable.ic_alarm, TestStubDrawable()) } .resources, context.theme, - fakeClock + fakeClock, ) } @@ -69,7 +69,7 @@ val expectedState = createAlarmTileState( QSTileState.ActivationState.INACTIVE, - context.getString(R.string.qs_alarm_tile_no_alarm) + context.getString(R.string.qs_alarm_tile_no_alarm), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -85,7 +85,7 @@ val localDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(triggerTime), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) val expectedSecondaryLabel = AlarmTileMapper.formatter24Hour.format(localDateTime) val expectedState = @@ -104,7 +104,7 @@ val localDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(triggerTime), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) val expectedSecondaryLabel = AlarmTileMapper.formatter12Hour.format(localDateTime) val expectedState = @@ -124,7 +124,7 @@ val localDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(triggerTime), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) val expectedSecondaryLabel = AlarmTileMapper.formatterDateOnly.format(localDateTime) val expectedState = @@ -144,7 +144,7 @@ val localDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(triggerTime), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) val expectedSecondaryLabel = AlarmTileMapper.formatter12Hour.format(localDateTime) val expectedState = @@ -164,7 +164,7 @@ val localDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(triggerTime), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) val expectedSecondaryLabel = AlarmTileMapper.formatterDateOnly.format(localDateTime) val expectedState = @@ -174,11 +174,11 @@ private fun createAlarmTileState( activationState: QSTileState.ActivationState, - secondaryLabel: String + secondaryLabel: String, ): QSTileState { val label = context.getString(R.string.status_bar_alarm) return QSTileState( - { Icon.Loaded(context.getDrawable(R.drawable.ic_alarm)!!, null) }, + Icon.Loaded(context.getDrawable(R.drawable.ic_alarm)!!, null), R.drawable.ic_alarm, label, activationState, @@ -188,7 +188,7 @@ null, QSTileState.SideViewIcon.Chevron, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt index a0d26c2..5385f94 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt
@@ -253,7 +253,7 @@ ): QSTileState { val label = context.getString(R.string.battery_detail_switch_title) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -265,7 +265,7 @@ stateDescription, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt index ea7b7c5..356b98e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt
@@ -45,7 +45,7 @@ context.orCreateTestableResources .apply { addOverride(R.drawable.ic_qs_color_correction, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -73,11 +73,11 @@ private fun createColorCorrectionTileState( activationState: QSTileState.ActivationState, - secondaryLabel: String + secondaryLabel: String, ): QSTileState { val label = context.getString(R.string.quick_settings_color_correction_label) return QSTileState( - { Icon.Loaded(context.getDrawable(R.drawable.ic_qs_color_correction)!!, null) }, + Icon.Loaded(context.getDrawable(R.drawable.ic_qs_color_correction)!!, null), R.drawable.ic_qs_color_correction, label, activationState, @@ -87,7 +87,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileMapperTest.kt index f1d08c0..8236c4c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileMapperTest.kt
@@ -57,10 +57,7 @@ private val kosmos = testKosmos().apply { customTileSpec = TileSpec.Companion.create(TEST_COMPONENT) } private val underTest by lazy { - CustomTileMapper( - context = mockContext, - uriGrantsManager = uriGrantsManager, - ) + CustomTileMapper(context = mockContext, uriGrantsManager = uriGrantsManager) } @Test @@ -68,10 +65,7 @@ with(kosmos) { testScope.runTest { val actual = - underTest.map( - customTileQsTileConfig, - createModel(hasPendingBind = true), - ) + underTest.map(customTileQsTileConfig, createModel(hasPendingBind = true)) val expected = createTileState( activationState = QSTileState.ActivationState.UNAVAILABLE, @@ -91,10 +85,7 @@ customTileQsTileConfig, createModel(tileState = Tile.STATE_ACTIVE), ) - val expected = - createTileState( - activationState = QSTileState.ActivationState.ACTIVE, - ) + val expected = createTileState(activationState = QSTileState.ActivationState.ACTIVE) assertThat(actual).isEqualTo(expected) } @@ -110,9 +101,7 @@ createModel(tileState = Tile.STATE_INACTIVE), ) val expected = - createTileState( - activationState = QSTileState.ActivationState.INACTIVE, - ) + createTileState(activationState = QSTileState.ActivationState.INACTIVE) assertThat(actual).isEqualTo(expected) } @@ -142,10 +131,7 @@ with(kosmos) { testScope.runTest { val actual = - underTest.map( - customTileQsTileConfig, - createModel(isToggleable = false), - ) + underTest.map(customTileQsTileConfig, createModel(isToggleable = false)) val expected = createTileState( sideIcon = QSTileState.SideViewIcon.Chevron, @@ -184,7 +170,7 @@ customTileQsTileConfig, createModel( tileIcon = createIcon(RuntimeException(), false), - defaultTileIcon = createIcon(null, true) + defaultTileIcon = createIcon(null, true), ), ) val expected = @@ -266,7 +252,7 @@ a11yClass: String? = Switch::class.qualifiedName, ): QSTileState { return QSTileState( - { icon?.let { com.android.systemui.common.shared.model.Icon.Loaded(icon, null) } }, + icon?.let { com.android.systemui.common.shared.model.Icon.Loaded(icon, null) }, null, "test label", activationState,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt index 63fb67d..587585c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapperTest.kt
@@ -44,7 +44,7 @@ addOverride(R.drawable.qs_flashlight_icon_on, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -74,7 +74,7 @@ val expectedIcon = Icon.Loaded(context.getDrawable(R.drawable.qs_flashlight_icon_on)!!, null) - val actualIcon = tileState.icon() + val actualIcon = tileState.icon assertThat(actualIcon).isEqualTo(expectedIcon) } @@ -85,7 +85,7 @@ val expectedIcon = Icon.Loaded(context.getDrawable(R.drawable.qs_flashlight_icon_off)!!, null) - val actualIcon = tileState.icon() + val actualIcon = tileState.icon assertThat(actualIcon).isEqualTo(expectedIcon) } @@ -96,7 +96,7 @@ val expectedIcon = Icon.Loaded(context.getDrawable(R.drawable.qs_flashlight_icon_off)!!, null) - val actualIcon = tileState.icon() + val actualIcon = tileState.icon assertThat(actualIcon).isEqualTo(expectedIcon) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt index f8e01be..e81771e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt
@@ -42,7 +42,7 @@ context.orCreateTestableResources .apply { addOverride(R.drawable.ic_qs_font_scaling, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -58,14 +58,7 @@ private fun createFontScalingTileState(): QSTileState = QSTileState( - { - Icon.Loaded( - context.getDrawable( - R.drawable.ic_qs_font_scaling, - )!!, - null - ) - }, + Icon.Loaded(context.getDrawable(R.drawable.ic_qs_font_scaling)!!, null), R.drawable.ic_qs_font_scaling, context.getString(R.string.quick_settings_font_scaling_label), QSTileState.ActivationState.ACTIVE, @@ -75,6 +68,6 @@ null, QSTileState.SideViewIcon.Chevron, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt index cdf6bda..12d604f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapperTest.kt
@@ -102,7 +102,7 @@ val label = context.getString(R.string.quick_settings_hearing_devices_label) val iconRes = R.drawable.qs_hearing_devices_icon return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt index d32ba47..9dcf49e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt
@@ -187,7 +187,7 @@ ): QSTileState { val label = context.getString(R.string.quick_settings_internet_label) return QSTileState( - { icon }, + icon, iconRes, label, activationState,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt index a7bd697..30fce73 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt
@@ -49,7 +49,7 @@ addOverride(R.drawable.qs_invert_colors_icon_on, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -63,7 +63,7 @@ createColorInversionTileState( QSTileState.ActivationState.INACTIVE, subtitleArray[1], - R.drawable.qs_invert_colors_icon_off + R.drawable.qs_invert_colors_icon_off, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -78,7 +78,7 @@ createColorInversionTileState( QSTileState.ActivationState.ACTIVE, subtitleArray[2], - R.drawable.qs_invert_colors_icon_on + R.drawable.qs_invert_colors_icon_on, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -90,7 +90,7 @@ ): QSTileState { val label = context.getString(R.string.quick_settings_inversion_label) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -100,7 +100,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt index ea74a4c..37e8a60 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapperTest.kt
@@ -45,7 +45,7 @@ addOverride(R.drawable.qs_location_icon_on, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -70,7 +70,7 @@ val tileState: QSTileState = mapper.map(qsTileConfig, LocationTileModel(true)) val expectedIcon = Icon.Loaded(context.getDrawable(R.drawable.qs_location_icon_on)!!, null) - val actualIcon = tileState.icon() + val actualIcon = tileState.icon Truth.assertThat(actualIcon).isEqualTo(expectedIcon) } @@ -79,7 +79,7 @@ val tileState: QSTileState = mapper.map(qsTileConfig, LocationTileModel(false)) val expectedIcon = Icon.Loaded(context.getDrawable(R.drawable.qs_location_icon_off)!!, null) - val actualIcon = tileState.icon() + val actualIcon = tileState.icon Truth.assertThat(actualIcon).isEqualTo(expectedIcon) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt index c3d45db..4e91d16 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapperTest.kt
@@ -59,34 +59,24 @@ @Test fun inactiveState() { val icon = TestStubDrawable("res123").asIcon() - val model = - ModesTileModel( - isActivated = false, - activeModes = emptyList(), - icon = icon, - ) + val model = ModesTileModel(isActivated = false, activeModes = emptyList(), icon = icon) val state = underTest.map(config, model) assertThat(state.activationState).isEqualTo(QSTileState.ActivationState.INACTIVE) - assertThat(state.icon()).isEqualTo(icon) + assertThat(state.icon).isEqualTo(icon) assertThat(state.secondaryLabel).isEqualTo("No active modes") } @Test fun activeState_oneMode() { val icon = TestStubDrawable("res123").asIcon() - val model = - ModesTileModel( - isActivated = true, - activeModes = listOf("DND"), - icon = icon, - ) + val model = ModesTileModel(isActivated = true, activeModes = listOf("DND"), icon = icon) val state = underTest.map(config, model) assertThat(state.activationState).isEqualTo(QSTileState.ActivationState.ACTIVE) - assertThat(state.icon()).isEqualTo(icon) + assertThat(state.icon).isEqualTo(icon) assertThat(state.secondaryLabel).isEqualTo("DND is active") } @@ -103,7 +93,7 @@ val state = underTest.map(config, model) assertThat(state.activationState).isEqualTo(QSTileState.ActivationState.ACTIVE) - assertThat(state.icon()).isEqualTo(icon) + assertThat(state.icon).isEqualTo(icon) assertThat(state.secondaryLabel).isEqualTo("3 modes are active") } @@ -115,12 +105,12 @@ isActivated = false, activeModes = emptyList(), icon = icon, - iconResId = 123 + iconResId = 123, ) val state = underTest.map(config, model) - assertThat(state.icon()).isEqualTo(icon) + assertThat(state.icon).isEqualTo(icon) assertThat(state.iconRes).isEqualTo(123) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt index 75273f2..1457f53 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt
@@ -73,7 +73,7 @@ val expectedState = createNightDisplayTileState( QSTileState.ActivationState.INACTIVE, - context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_INACTIVE] + context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_INACTIVE], ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -88,7 +88,7 @@ val expectedState = createNightDisplayTileState( QSTileState.ActivationState.INACTIVE, - context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_INACTIVE] + context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_INACTIVE], ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -102,7 +102,7 @@ val expectedState = createNightDisplayTileState( QSTileState.ActivationState.ACTIVE, - context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_ACTIVE] + context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_ACTIVE], ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -116,7 +116,7 @@ val expectedState = createNightDisplayTileState( QSTileState.ActivationState.ACTIVE, - context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_ACTIVE] + context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_ACTIVE], ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -140,7 +140,7 @@ val expectedState = createNightDisplayTileState( QSTileState.ActivationState.ACTIVE, - context.getString(R.string.quick_settings_night_secondary_label_until_sunrise) + context.getString(R.string.quick_settings_night_secondary_label_until_sunrise), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -154,7 +154,7 @@ val expectedState = createNightDisplayTileState( QSTileState.ActivationState.INACTIVE, - context.getString(R.string.quick_settings_night_secondary_label_on_at_sunset) + context.getString(R.string.quick_settings_night_secondary_label_on_at_sunset), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -181,8 +181,8 @@ QSTileState.ActivationState.INACTIVE, context.getString( R.string.quick_settings_night_secondary_label_on_at, - formatter24Hour.format(testStartTime) - ) + formatter24Hour.format(testStartTime), + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -199,8 +199,8 @@ QSTileState.ActivationState.INACTIVE, context.getString( R.string.quick_settings_night_secondary_label_on_at, - formatter12Hour.format(testStartTime) - ) + formatter12Hour.format(testStartTime), + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -218,8 +218,8 @@ QSTileState.ActivationState.INACTIVE, context.getString( R.string.quick_settings_night_secondary_label_on_at, - formatter12Hour.format(testStartTime) - ) + formatter12Hour.format(testStartTime), + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -235,8 +235,8 @@ QSTileState.ActivationState.ACTIVE, context.getString( R.string.quick_settings_secondary_label_until, - formatter24Hour.format(testEndTime) - ) + formatter24Hour.format(testEndTime), + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -252,8 +252,8 @@ QSTileState.ActivationState.ACTIVE, context.getString( R.string.quick_settings_secondary_label_until, - formatter12Hour.format(testEndTime) - ) + formatter12Hour.format(testEndTime), + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -270,15 +270,15 @@ QSTileState.ActivationState.ACTIVE, context.getString( R.string.quick_settings_secondary_label_until, - formatter24Hour.format(testEndTime) - ) + formatter24Hour.format(testEndTime), + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } private fun createNightDisplayTileState( activationState: QSTileState.ActivationState, - secondaryLabel: String? + secondaryLabel: String?, ): QSTileState { val label = context.getString(R.string.quick_settings_night_display_label) val iconRes = @@ -289,7 +289,7 @@ if (TextUtils.isEmpty(secondaryLabel)) label else TextUtils.concat(label, ", ", secondaryLabel) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -299,7 +299,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt index 3189a9e..7782d2b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt
@@ -51,11 +51,11 @@ .apply { addOverride( com.android.internal.R.drawable.ic_qs_one_handed_mode, - TestStubDrawable() + TestStubDrawable(), ) } .resources, - context.theme + context.theme, ) } @@ -69,7 +69,7 @@ createOneHandedModeTileState( QSTileState.ActivationState.INACTIVE, subtitleArray[1], - com.android.internal.R.drawable.ic_qs_one_handed_mode + com.android.internal.R.drawable.ic_qs_one_handed_mode, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -84,7 +84,7 @@ createOneHandedModeTileState( QSTileState.ActivationState.ACTIVE, subtitleArray[2], - com.android.internal.R.drawable.ic_qs_one_handed_mode + com.android.internal.R.drawable.ic_qs_one_handed_mode, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -96,7 +96,7 @@ ): QSTileState { val label = context.getString(R.string.quick_settings_onehanded_label) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -106,7 +106,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt index 08e5cbe..ed33250 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt
@@ -49,11 +49,11 @@ .apply { addOverride( com.android.systemui.res.R.drawable.ic_qr_code_scanner, - TestStubDrawable() + TestStubDrawable(), ) } .resources, - context.theme + context.theme, ) } @@ -64,11 +64,7 @@ val outputState = mapper.map(config, inputModel) - val expectedState = - createQRCodeScannerTileState( - QSTileState.ActivationState.INACTIVE, - null, - ) + val expectedState = createQRCodeScannerTileState(QSTileState.ActivationState.INACTIVE, null) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -83,7 +79,7 @@ QSTileState.ActivationState.UNAVAILABLE, context.getString( com.android.systemui.res.R.string.qr_code_scanner_updating_secondary_label - ) + ), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -94,12 +90,10 @@ ): QSTileState { val label = context.getString(com.android.systemui.res.R.string.qr_code_scanner_title) return QSTileState( - { - Icon.Loaded( - context.getDrawable(com.android.systemui.res.R.drawable.ic_qr_code_scanner)!!, - null - ) - }, + Icon.Loaded( + context.getDrawable(com.android.systemui.res.R.drawable.ic_qr_code_scanner)!!, + null, + ), com.android.systemui.res.R.drawable.ic_qr_code_scanner, label, activationState, @@ -109,7 +103,7 @@ null, QSTileState.SideViewIcon.Chevron, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt index ca30e9c..85111fd 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt
@@ -51,7 +51,7 @@ addOverride(R.drawable.qs_extra_dim_icon_off, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -61,10 +61,7 @@ val outputState = mapper.map(config, inputModel) - val expectedState = - createReduceBrightColorsTileState( - QSTileState.ActivationState.INACTIVE, - ) + val expectedState = createReduceBrightColorsTileState(QSTileState.ActivationState.INACTIVE) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -79,7 +76,7 @@ } private fun createReduceBrightColorsTileState( - activationState: QSTileState.ActivationState, + activationState: QSTileState.ActivationState ): QSTileState { val label = context.getString(com.android.internal.R.string.reduce_bright_colors_feature_name) @@ -88,7 +85,7 @@ R.drawable.qs_extra_dim_icon_on else R.drawable.qs_extra_dim_icon_off return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -101,7 +98,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt index 3e40c5c..53671ba 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt
@@ -66,13 +66,13 @@ addOverride(com.android.internal.R.bool.config_allowRotationResolver, true) addOverride( com.android.internal.R.array.config_foldedDeviceStates, - intArrayOf() // empty array <=> device is not foldable + intArrayOf(), // empty array <=> device is not foldable ) } .resources, context.theme, devicePostureController, - deviceStateManager + deviceStateManager, ) } @@ -86,7 +86,7 @@ createRotationLockTileState( QSTileState.ActivationState.ACTIVE, EMPTY_SECONDARY_STRING, - R.drawable.qs_auto_rotate_icon_on + R.drawable.qs_auto_rotate_icon_on, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -101,7 +101,7 @@ createRotationLockTileState( QSTileState.ActivationState.ACTIVE, context.getString(R.string.rotation_lock_camera_rotation_on), - R.drawable.qs_auto_rotate_icon_on + R.drawable.qs_auto_rotate_icon_on, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -116,7 +116,7 @@ createRotationLockTileState( QSTileState.ActivationState.INACTIVE, EMPTY_SECONDARY_STRING, - R.drawable.qs_auto_rotate_icon_off + R.drawable.qs_auto_rotate_icon_off, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -167,7 +167,7 @@ mapper.apply { overrideResource( com.android.internal.R.array.config_foldedDeviceStates, - intArrayOf(1, 2, 3) + intArrayOf(1, 2, 3), ) } whenever(deviceStateManager.supportedDeviceStates).thenReturn(kosmos.foldedDeviceStateList) @@ -176,11 +176,11 @@ private fun createRotationLockTileState( activationState: QSTileState.ActivationState, secondaryLabel: String, - iconRes: Int + iconRes: Int, ): QSTileState { val label = context.getString(R.string.quick_settings_rotation_unlocked_label) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -190,7 +190,7 @@ secondaryLabel, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt index 9bb6141..9a45065 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt
@@ -46,7 +46,7 @@ addOverride(R.drawable.qs_data_saver_icon_on, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -59,7 +59,7 @@ val expectedState = createDataSaverTileState( QSTileState.ActivationState.ACTIVE, - R.drawable.qs_data_saver_icon_on + R.drawable.qs_data_saver_icon_on, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -73,14 +73,14 @@ val expectedState = createDataSaverTileState( QSTileState.ActivationState.INACTIVE, - R.drawable.qs_data_saver_icon_off + R.drawable.qs_data_saver_icon_off, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } private fun createDataSaverTileState( activationState: QSTileState.ActivationState, - iconRes: Int + iconRes: Int, ): QSTileState { val label = context.getString(R.string.data_saver) val secondaryLabel = @@ -91,7 +91,7 @@ else context.resources.getStringArray(R.array.tile_states_saver)[0] return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -101,7 +101,7 @@ null, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt index 336b566..cd683c4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt
@@ -52,7 +52,7 @@ addOverride(R.drawable.qs_screen_record_icon_off, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -82,7 +82,7 @@ createScreenRecordTileState( QSTileState.ActivationState.ACTIVE, R.drawable.qs_screen_record_icon_on, - String.format("%d...", timeLeft) + String.format("%d...", timeLeft), ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -110,7 +110,7 @@ val label = context.getString(R.string.quick_settings_screen_record_label) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -123,7 +123,7 @@ QSTileState.SideViewIcon.Chevron else QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt index b08f39b..c569403 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt
@@ -56,7 +56,7 @@ context.getString(R.string.quick_settings_camera_mic_available), R.drawable.qs_camera_access_icon_on, null, - CAMERA + CAMERA, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -74,7 +74,7 @@ context.getString(R.string.quick_settings_camera_mic_blocked), R.drawable.qs_camera_access_icon_off, null, - CAMERA + CAMERA, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -92,7 +92,7 @@ context.getString(R.string.quick_settings_camera_mic_available), R.drawable.qs_mic_access_on, null, - MICROPHONE + MICROPHONE, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -110,7 +110,7 @@ context.getString(R.string.quick_settings_camera_mic_blocked), R.drawable.qs_mic_access_off, null, - MICROPHONE + MICROPHONE, ) QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState) } @@ -146,7 +146,7 @@ else context.getString(R.string.quick_settings_mic_label) return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -156,7 +156,7 @@ stateDescription, QSTileState.SideViewIcon.None, QSTileState.EnabledState.ENABLED, - Switch::class.qualifiedName + Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt index c021caa..0d2ebe4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt
@@ -49,7 +49,7 @@ addOverride(R.drawable.qs_light_dark_theme_icon_on, TestStubDrawable()) } .resources, - context.theme + context.theme, ) } @@ -69,7 +69,7 @@ expandedAccessibilityClass: KClass<out View>? = Switch::class, ): QSTileState { return QSTileState( - { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes, label, activationState, @@ -79,7 +79,7 @@ stateDescription, sideViewIcon, enabledState, - expandedAccessibilityClass?.qualifiedName + expandedAccessibilityClass?.qualifiedName, ) } @@ -98,7 +98,7 @@ createUiNightModeTileState( activationState = QSTileState.ActivationState.UNAVAILABLE, secondaryLabel = expectedSecondaryLabel, - contentDescription = expectedContentDescription + contentDescription = expectedContentDescription, ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -118,7 +118,7 @@ createUiNightModeTileState( activationState = QSTileState.ActivationState.UNAVAILABLE, secondaryLabel = expectedSecondaryLabel, - contentDescription = expectedContentDescription + contentDescription = expectedContentDescription, ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -136,7 +136,7 @@ activationState = QSTileState.ActivationState.INACTIVE, label = expectedLabel, secondaryLabel = expectedSecondaryLabel, - contentDescription = expectedLabel + contentDescription = expectedLabel, ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -155,7 +155,7 @@ label = expectedLabel, secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.ACTIVE, - contentDescription = expectedLabel + contentDescription = expectedLabel, ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -174,7 +174,7 @@ label = expectedLabel, secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.ACTIVE, - contentDescription = expectedLabel + contentDescription = expectedLabel, ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -193,7 +193,7 @@ label = expectedLabel, secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.INACTIVE, - contentDescription = expectedLabel + contentDescription = expectedLabel, ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -214,7 +214,7 @@ activationState = QSTileState.ActivationState.ACTIVE, contentDescription = expectedLabel, supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -237,7 +237,7 @@ secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.UNAVAILABLE, contentDescription = expectedContentDescription, - supportedActions = setOf(QSTileState.UserAction.LONG_CLICK) + supportedActions = setOf(QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -258,7 +258,7 @@ activationState = QSTileState.ActivationState.INACTIVE, contentDescription = expectedLabel, supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -279,7 +279,7 @@ secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.UNAVAILABLE, contentDescription = TextUtils.concat(expectedLabel, ", ", expectedSecondaryLabel), - supportedActions = setOf(QSTileState.UserAction.LONG_CLICK) + supportedActions = setOf(QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -300,7 +300,7 @@ secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.UNAVAILABLE, contentDescription = TextUtils.concat(expectedLabel, ", ", expectedSecondaryLabel), - supportedActions = setOf(QSTileState.UserAction.LONG_CLICK) + supportedActions = setOf(QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -312,7 +312,7 @@ nightMode = true, powerSave = false, isLocationEnabled = true, - uiMode = UiModeManager.MODE_NIGHT_AUTO + uiMode = UiModeManager.MODE_NIGHT_AUTO, ) val actualState: QSTileState = mapper.map(qsTileConfig, inputModel) @@ -328,7 +328,7 @@ activationState = QSTileState.ActivationState.ACTIVE, contentDescription = TextUtils.concat(expectedLabel, ", ", expectedSecondaryLabel), supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -340,7 +340,7 @@ nightMode = false, powerSave = false, isLocationEnabled = true, - uiMode = UiModeManager.MODE_NIGHT_AUTO + uiMode = UiModeManager.MODE_NIGHT_AUTO, ) val actualState: QSTileState = mapper.map(qsTileConfig, inputModel) @@ -356,7 +356,7 @@ activationState = QSTileState.ActivationState.INACTIVE, contentDescription = TextUtils.concat(expectedLabel, ", ", expectedSecondaryLabel), supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -379,7 +379,7 @@ activationState = QSTileState.ActivationState.ACTIVE, contentDescription = expectedLabel, supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -401,7 +401,7 @@ activationState = QSTileState.ActivationState.INACTIVE, contentDescription = expectedLabel, supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -413,7 +413,7 @@ nightMode = false, powerSave = false, uiMode = UiModeManager.MODE_NIGHT_CUSTOM, - nighModeCustomType = UiModeManager.MODE_NIGHT_CUSTOM_TYPE_UNKNOWN + nighModeCustomType = UiModeManager.MODE_NIGHT_CUSTOM_TYPE_UNKNOWN, ) val actualState: QSTileState = mapper.map(qsTileConfig, inputModel) @@ -428,7 +428,7 @@ activationState = QSTileState.ActivationState.INACTIVE, contentDescription = expectedLabel, supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -440,7 +440,7 @@ nightMode = true, powerSave = false, uiMode = UiModeManager.MODE_NIGHT_CUSTOM, - nighModeCustomType = UiModeManager.MODE_NIGHT_CUSTOM_TYPE_UNKNOWN + nighModeCustomType = UiModeManager.MODE_NIGHT_CUSTOM_TYPE_UNKNOWN, ) val actualState: QSTileState = mapper.map(qsTileConfig, inputModel) @@ -455,7 +455,7 @@ activationState = QSTileState.ActivationState.ACTIVE, contentDescription = expectedLabel, supportedActions = - setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } @@ -467,7 +467,7 @@ nightMode = false, powerSave = true, uiMode = UiModeManager.MODE_NIGHT_CUSTOM, - nighModeCustomType = UiModeManager.MODE_NIGHT_CUSTOM_TYPE_UNKNOWN + nighModeCustomType = UiModeManager.MODE_NIGHT_CUSTOM_TYPE_UNKNOWN, ) val actualState: QSTileState = mapper.map(qsTileConfig, inputModel) @@ -484,7 +484,7 @@ secondaryLabel = expectedSecondaryLabel, activationState = QSTileState.ActivationState.UNAVAILABLE, contentDescription = expectedContentDescription, - supportedActions = setOf(QSTileState.UserAction.LONG_CLICK) + supportedActions = setOf(QSTileState.UserAction.LONG_CLICK), ) QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt index e7bde681..86321ea 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt
@@ -56,7 +56,7 @@ whenever( devicePolicyResourceManager.getString( eq(DevicePolicyResources.Strings.SystemUi.QS_WORK_PROFILE_LABEL), - any() + any(), ) ) .thenReturn(testLabel) @@ -66,12 +66,12 @@ .apply { addOverride( com.android.internal.R.drawable.stat_sys_managed_profile_status, - TestStubDrawable() + TestStubDrawable(), ) } .resources, context.theme, - devicePolicyManager + devicePolicyManager, ) } @@ -105,13 +105,11 @@ QSTileStateSubject.assertThat(actualState).isEqualTo(expectedState) } - private fun createWorkModeTileState( - activationState: QSTileState.ActivationState, - ): QSTileState { + private fun createWorkModeTileState(activationState: QSTileState.ActivationState): QSTileState { val label = testLabel val iconRes = com.android.internal.R.drawable.stat_sys_managed_profile_status return QSTileState( - icon = { Icon.Loaded(context.getDrawable(iconRes)!!, null) }, + icon = Icon.Loaded(context.getDrawable(iconRes)!!, null), iconRes = iconRes, label = label, activationState = activationState, @@ -134,7 +132,7 @@ stateDescription = null, sideViewIcon = QSTileState.SideViewIcon.None, enabledState = QSTileState.EnabledState.ENABLED, - expandedAccessibilityClassName = Switch::class.qualifiedName + expandedAccessibilityClassName = Switch::class.qualifiedName, ) } }
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelTest.kt index c33e2a4..954215ee 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelTest.kt
@@ -184,10 +184,7 @@ { object : QSTileDataToStateMapper<String> { override fun map(config: QSTileConfig, data: String): QSTileState = - QSTileState.build( - { Icon.Resource(0, ContentDescription.Resource(0)) }, - data - ) {} + QSTileState.build(Icon.Resource(0, ContentDescription.Resource(0)), data) {} } }, disabledByPolicyInteractor,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelUserInputTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelUserInputTest.kt index 7955f2f..0219a4c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelUserInputTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelUserInputTest.kt
@@ -104,7 +104,7 @@ eq(tileConfig.tileSpec), eq(userAction), any(), - eq("initial_data") + eq("initial_data"), ) verify(qsTileAnalytics).trackUserAction(eq(tileConfig), eq(userAction)) } @@ -130,7 +130,7 @@ .logUserActionRejectedByPolicy( eq(userAction), eq(tileConfig.tileSpec), - eq(DISABLED_RESTRICTION) + eq(DISABLED_RESTRICTION), ) verify(qsTileAnalytics, never()).trackUserAction(any(), any()) } @@ -159,7 +159,7 @@ .logUserActionRejectedByPolicy( eq(userAction), eq(tileConfig.tileSpec), - eq(DISABLED_RESTRICTION) + eq(DISABLED_RESTRICTION), ) verify(qsTileAnalytics, never()).trackUserAction(any(), any()) } @@ -174,7 +174,7 @@ QSTilePolicy.Restricted( listOf( DISABLED_RESTRICTION, - FakeDisabledByPolicyInteractor.DISABLED_RESTRICTION_2 + FakeDisabledByPolicyInteractor.DISABLED_RESTRICTION_2, ) ) } @@ -194,13 +194,13 @@ .logUserActionRejectedByPolicy( eq(userAction), eq(tileConfig.tileSpec), - eq(DISABLED_RESTRICTION) + eq(DISABLED_RESTRICTION), ) verify(qsTileLogger, never()) .logUserActionRejectedByPolicy( eq(userAction), eq(tileConfig.tileSpec), - eq(FakeDisabledByPolicyInteractor.DISABLED_RESTRICTION_2) + eq(FakeDisabledByPolicyInteractor.DISABLED_RESTRICTION_2), ) verify(qsTileAnalytics, never()).trackUserAction(any(), any()) } @@ -243,10 +243,7 @@ { object : QSTileDataToStateMapper<String> { override fun map(config: QSTileConfig, data: String): QSTileState = - QSTileState.build( - { Icon.Resource(0, ContentDescription.Resource(0)) }, - data - ) {} + QSTileState.build(Icon.Resource(0, ContentDescription.Resource(0)), data) {} } }, disabledByPolicyInteractor,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt index 1c9cb3d..fef5a74 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ModesTile.kt
@@ -25,6 +25,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.coroutineScope import androidx.lifecycle.repeatOnLifecycle +import com.android.app.tracing.coroutines.launchTraced as launch import com.android.internal.logging.MetricsLogger import com.android.systemui.animation.Expandable import com.android.systemui.dagger.qualifiers.Background @@ -48,7 +49,6 @@ import com.android.systemui.qs.tiles.viewmodel.QSTileState import com.android.systemui.res.R import javax.inject.Inject -import com.android.app.tracing.coroutines.launchTraced as launch import kotlinx.coroutines.runBlocking class ModesTile @@ -120,8 +120,7 @@ tileState = tileMapper.map(config, model) state?.apply { this.state = tileState.activationState.legacyState - val tileStateIcon = tileState.icon() - icon = tileStateIcon?.asQSTileIcon() ?: ResourceIcon.get(ICON_RES_ID) + icon = tileState.icon?.asQSTileIcon() ?: ResourceIcon.get(ICON_RES_ID) label = tileLabel secondaryLabel = tileState.secondaryLabel contentDescription = tileState.contentDescription
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/AirplaneModeMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/AirplaneModeMapper.kt index 9fb1d46..d67057a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/AirplaneModeMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/airplane/domain/AirplaneModeMapper.kt
@@ -30,10 +30,8 @@ /** Maps [AirplaneModeTileModel] to [QSTileState]. */ class AirplaneModeMapper @Inject -constructor( - @Main private val resources: Resources, - val theme: Theme, -) : QSTileDataToStateMapper<AirplaneModeTileModel> { +constructor(@Main private val resources: Resources, val theme: Theme) : + QSTileDataToStateMapper<AirplaneModeTileModel> { override fun map(config: QSTileConfig, data: AirplaneModeTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { @@ -43,16 +41,7 @@ } else { R.drawable.qs_airplane_icon_off } - - icon = { - Icon.Loaded( - resources.getDrawable( - iconRes!!, - theme, - ), - contentDescription = null - ) - } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) if (data.isEnabled) { activationState = QSTileState.ActivationState.ACTIVE secondaryLabel = resources.getStringArray(R.array.tile_states_airplane)[2] @@ -62,9 +51,6 @@ } contentDescription = label supportedActions = - setOf( - QSTileState.UserAction.CLICK, - QSTileState.UserAction.LONG_CLICK, - ) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) } }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapper.kt index f088943..7322b8d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapper.kt
@@ -45,6 +45,7 @@ val formatter24Hour: DateTimeFormatter = DateTimeFormatter.ofPattern("E HH:mm") val formatterDateOnly: DateTimeFormatter = DateTimeFormatter.ofPattern("E MMM d") } + override fun map(config: QSTileConfig, data: AlarmTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { when (data) { @@ -54,13 +55,13 @@ val alarmDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(data.alarmClockInfo.triggerTime), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) val nowDateTime = LocalDateTime.ofInstant( Instant.ofEpochMilli(clock.currentTimeMillis()), - TimeZone.getDefault().toZoneId() + TimeZone.getDefault().toZoneId(), ) // Edge case: If it's 8:00:30 right now and alarm is requested for next week at @@ -84,7 +85,7 @@ } } iconRes = R.drawable.ic_alarm - icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) sideViewIcon = QSTileState.SideViewIcon.Chevron contentDescription = label supportedActions = setOf(QSTileState.UserAction.CLICK)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapper.kt index bcf0935..5b30e8d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapper.kt
@@ -29,10 +29,8 @@ /** Maps [BatterySaverTileModel] to [QSTileState]. */ open class BatterySaverTileMapper @Inject -constructor( - @Main protected val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<BatterySaverTileModel> { +constructor(@Main protected val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<BatterySaverTileModel> { override fun map(config: QSTileConfig, data: BatterySaverTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { @@ -41,8 +39,7 @@ iconRes = if (data.isPowerSaving) R.drawable.qs_battery_saver_icon_on else R.drawable.qs_battery_saver_icon_off - icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) } - + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) sideViewIcon = QSTileState.SideViewIcon.None if (data.isPluggedIn) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapper.kt index cad7c65..7c90b3d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapper.kt
@@ -17,6 +17,7 @@ package com.android.systemui.qs.tiles.impl.colorcorrection.domain import android.content.res.Resources +import com.android.systemui.common.shared.model.Icon import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.qs.tiles.base.interactor.QSTileDataToStateMapper import com.android.systemui.qs.tiles.impl.colorcorrection.domain.model.ColorCorrectionTileModel @@ -28,17 +29,14 @@ /** Maps [ColorCorrectionTileModel] to [QSTileState]. */ class ColorCorrectionTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<ColorCorrectionTileModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<ColorCorrectionTileModel> { override fun map(config: QSTileConfig, data: ColorCorrectionTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { val subtitleArray = resources.getStringArray(R.array.tile_states_color_correction) - iconRes = R.drawable.ic_qs_color_correction - + icon = Icon.Loaded(resources.getDrawable(R.drawable.ic_qs_color_correction)!!, null) if (data.isEnabled) { activationState = QSTileState.ActivationState.ACTIVE secondaryLabel = subtitleArray[2]
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/CustomTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/CustomTileMapper.kt index 984228d..60aa4ea 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/CustomTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/custom/domain/CustomTileMapper.kt
@@ -35,10 +35,8 @@ @SysUISingleton class CustomTileMapper @Inject -constructor( - private val context: Context, - private val uriGrantsManager: IUriGrantsManager, -) : QSTileDataToStateMapper<CustomTileDataModel> { +constructor(private val context: Context, private val uriGrantsManager: IUriGrantsManager) : + QSTileDataToStateMapper<CustomTileDataModel> { override fun map(config: QSTileConfig, data: CustomTileDataModel): QSTileState { val userContext = @@ -50,7 +48,7 @@ val iconResult = if (userContext != null) { - getIconProvider( + getIcon( userContext = userContext, icon = data.tile.icon, callingAppUid = data.callingAppUid, @@ -58,16 +56,16 @@ defaultIcon = data.defaultTileIcon, ) } else { - IconResult({ null }, true) + IconResult(null, true) } - return QSTileState.build(iconResult.iconProvider, data.tile.label) { + return QSTileState.build(iconResult.icon, data.tile.label) { var tileState: Int = data.tile.state if (data.hasPendingBind) { tileState = Tile.STATE_UNAVAILABLE } - icon = iconResult.iconProvider + icon = iconResult.icon activationState = if (iconResult.failedToLoad) { QSTileState.ActivationState.UNAVAILABLE @@ -102,7 +100,7 @@ } @SuppressLint("MissingPermission") // android.permission.INTERACT_ACROSS_USERS_FULL - private fun getIconProvider( + private fun getIcon( userContext: Context, icon: android.graphics.drawable.Icon?, callingAppUid: Int, @@ -123,17 +121,12 @@ null } ?: defaultIcon?.loadDrawable(userContext) return IconResult( - { - drawable?.constantState?.newDrawable()?.let { - Icon.Loaded(it, contentDescription = null) - } + drawable?.constantState?.newDrawable()?.let { + Icon.Loaded(it, contentDescription = null) }, failedToLoad, ) } - class IconResult( - val iconProvider: () -> Icon?, - val failedToLoad: Boolean, - ) + class IconResult(val icon: Icon?, val failedToLoad: Boolean) }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapper.kt index d7d6124..7e557eb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapper.kt
@@ -30,10 +30,8 @@ /** Maps [FlashlightTileModel] to [QSTileState]. */ class FlashlightMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Theme, -) : QSTileDataToStateMapper<FlashlightTileModel> { +constructor(@Main private val resources: Resources, private val theme: Theme) : + QSTileDataToStateMapper<FlashlightTileModel> { override fun map(config: QSTileConfig, data: FlashlightTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { @@ -43,15 +41,8 @@ } else { R.drawable.qs_flashlight_icon_off } - val icon = - Icon.Loaded( - resources.getDrawable( - iconRes!!, - theme, - ), - contentDescription = null - ) - this.icon = { icon } + + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) contentDescription = label
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapper.kt index 6b4dda13..9d44fc6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapper.kt
@@ -29,23 +29,13 @@ /** Maps [FontScalingTileModel] to [QSTileState]. */ class FontScalingTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<FontScalingTileModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<FontScalingTileModel> { override fun map(config: QSTileConfig, data: FontScalingTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { iconRes = R.drawable.ic_qs_font_scaling - val icon = - Icon.Loaded( - resources.getDrawable( - iconRes!!, - theme, - ), - contentDescription = null - ) - this.icon = { icon } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) contentDescription = label activationState = QSTileState.ActivationState.ACTIVE sideViewIcon = QSTileState.SideViewIcon.Chevron
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapper.kt index 8dd611f..c3ac1f8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/hearingdevices/domain/HearingDevicesTileMapper.kt
@@ -36,9 +36,7 @@ QSTileState.build(resources, theme, config.uiConfig) { label = resources.getString(R.string.quick_settings_hearing_devices_label) iconRes = R.drawable.qs_hearing_devices_icon - val loadedIcon = - Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - icon = { loadedIcon } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) sideViewIcon = QSTileState.SideViewIcon.Chevron contentDescription = label if (data.isAnyActiveHearingDevice) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt index bb0b9b7..fc94585 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt
@@ -61,28 +61,26 @@ when (val dataIcon = data.icon) { is InternetTileIconModel.ResourceId -> { iconRes = dataIcon.resId - icon = { + icon = Icon.Loaded( resources.getDrawable(dataIcon.resId, theme), contentDescription = null, ) - } } is InternetTileIconModel.Cellular -> { val signalDrawable = SignalDrawable(context, handler) signalDrawable.setLevel(dataIcon.level) - icon = { Icon.Loaded(signalDrawable, contentDescription = null) } + icon = Icon.Loaded(signalDrawable, contentDescription = null) } is InternetTileIconModel.Satellite -> { iconRes = dataIcon.resourceIcon.res // level is inferred from res - icon = { + icon = Icon.Loaded( resources.getDrawable(dataIcon.resourceIcon.res, theme), contentDescription = null, ) - } } }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapper.kt index 40aee65..3692c35 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapper.kt
@@ -30,10 +30,8 @@ /** Maps [ColorInversionTileModel] to [QSTileState]. */ class ColorInversionTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Theme, -) : QSTileDataToStateMapper<ColorInversionTileModel> { +constructor(@Main private val resources: Resources, private val theme: Theme) : + QSTileDataToStateMapper<ColorInversionTileModel> { override fun map(config: QSTileConfig, data: ColorInversionTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { val subtitleArray = resources.getStringArray(R.array.tile_states_inversion) @@ -47,7 +45,7 @@ secondaryLabel = subtitleArray[1] iconRes = R.drawable.qs_invert_colors_icon_off } - icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) contentDescription = label supportedActions = setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapper.kt index ff931b3..3fe2a77 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapper.kt
@@ -28,21 +28,26 @@ class IssueRecordingMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Theme, -) : QSTileDataToStateMapper<IssueRecordingModel> { +constructor(@Main private val resources: Resources, private val theme: Theme) : + QSTileDataToStateMapper<IssueRecordingModel> { override fun map(config: QSTileConfig, data: IssueRecordingModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { - if (data.isRecording) { - activationState = QSTileState.ActivationState.ACTIVE - secondaryLabel = resources.getString(R.string.qs_record_issue_stop) - icon = { Icon.Resource(R.drawable.qs_record_issue_icon_on, null) } - } else { - icon = { Icon.Resource(R.drawable.qs_record_issue_icon_off, null) } - activationState = QSTileState.ActivationState.INACTIVE - secondaryLabel = resources.getString(R.string.qs_record_issue_start) - } + icon = + if (data.isRecording) { + activationState = QSTileState.ActivationState.ACTIVE + secondaryLabel = resources.getString(R.string.qs_record_issue_stop) + Icon.Loaded( + resources.getDrawable(R.drawable.qs_record_issue_icon_on, theme), + null, + ) + } else { + activationState = QSTileState.ActivationState.INACTIVE + secondaryLabel = resources.getString(R.string.qs_record_issue_start) + Icon.Loaded( + resources.getDrawable(R.drawable.qs_record_issue_icon_off, theme), + null, + ) + } supportedActions = setOf(QSTileState.UserAction.CLICK) contentDescription = "$label, $secondaryLabel" }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapper.kt index d58f5ab..08432f6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapper.kt
@@ -30,10 +30,8 @@ /** Maps [LocationTileModel] to [QSTileState]. */ class LocationTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Theme, -) : QSTileDataToStateMapper<LocationTileModel> { +constructor(@Main private val resources: Resources, private val theme: Theme) : + QSTileDataToStateMapper<LocationTileModel> { override fun map(config: QSTileConfig, data: LocationTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { @@ -43,17 +41,9 @@ } else { R.drawable.qs_location_icon_off } - val icon = - Icon.Loaded( - resources.getDrawable( - iconRes!!, - theme, - ), - contentDescription = null - ) - this.icon = { icon } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - this.label = resources.getString(R.string.quick_settings_location_label) + label = resources.getString(R.string.quick_settings_location_label) if (data.isEnabled) { activationState = QSTileState.ActivationState.ACTIVE
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt index 69da313..4a64313 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/modes/ui/ModesTileMapper.kt
@@ -30,14 +30,12 @@ class ModesTileMapper @Inject -constructor( - @Main private val resources: Resources, - val theme: Resources.Theme, -) : QSTileDataToStateMapper<ModesTileModel> { +constructor(@Main private val resources: Resources, val theme: Resources.Theme) : + QSTileDataToStateMapper<ModesTileModel> { override fun map(config: QSTileConfig, data: ModesTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { iconRes = data.iconResId - icon = { data.icon } + icon = data.icon activationState = if (data.isActivated) { QSTileState.ActivationState.ACTIVE @@ -47,10 +45,7 @@ secondaryLabel = getModesStatus(data, resources) contentDescription = "$label. $secondaryLabel" supportedActions = - setOf( - QSTileState.UserAction.CLICK, - QSTileState.UserAction.LONG_CLICK, - ) + setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) sideViewIcon = QSTileState.SideViewIcon.Chevron expandedAccessibilityClass = Button::class }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapper.kt index bcf7cc7..081a03c7 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapper.kt
@@ -57,9 +57,8 @@ activationState = QSTileState.ActivationState.INACTIVE iconRes = R.drawable.qs_nightlight_icon_off } - val loadedIcon = - Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - icon = { loadedIcon } + + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) secondaryLabel = getSecondaryLabel(data, resources) @@ -70,7 +69,7 @@ private fun getSecondaryLabel( data: NightDisplayTileModel, - resources: Resources + resources: Resources, ): CharSequence? { when (data) { is NightDisplayTileModel.AutoModeTwilight -> {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapper.kt index 4080996..8e5d0d4 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapper.kt
@@ -29,17 +29,15 @@ /** Maps [OneHandedModeTileModel] to [QSTileState]. */ class OneHandedModeTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<OneHandedModeTileModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<OneHandedModeTileModel> { override fun map(config: QSTileConfig, data: OneHandedModeTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { val subtitleArray = resources.getStringArray(R.array.tile_states_onehanded) label = resources.getString(R.string.quick_settings_onehanded_label) iconRes = com.android.internal.R.drawable.ic_qs_one_handed_mode - icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) if (data.isEnabled) { activationState = QSTileState.ActivationState.ACTIVE secondaryLabel = subtitleArray[2]
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapper.kt index 8231742..5c6351e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapper.kt
@@ -29,17 +29,15 @@ /** Maps [QRCodeScannerTileModel] to [QSTileState]. */ class QRCodeScannerTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<QRCodeScannerTileModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<QRCodeScannerTileModel> { override fun map(config: QSTileConfig, data: QRCodeScannerTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { label = resources.getString(R.string.qr_code_scanner_title) contentDescription = label iconRes = R.drawable.ic_qr_code_scanner - icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) sideViewIcon = QSTileState.SideViewIcon.Chevron supportedActions = setOf(QSTileState.UserAction.CLICK)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapper.kt index 85ee0220..fe77fe6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapper.kt
@@ -30,10 +30,8 @@ /** Maps [ReduceBrightColorsTileModel] to [QSTileState]. */ class ReduceBrightColorsTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<ReduceBrightColorsTileModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<ReduceBrightColorsTileModel> { override fun map(config: QSTileConfig, data: ReduceBrightColorsTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { @@ -50,12 +48,7 @@ resources .getStringArray(R.array.tile_states_reduce_brightness)[Tile.STATE_INACTIVE] } - icon = { - Icon.Loaded( - drawable = resources.getDrawable(iconRes!!, theme), - contentDescription = null - ) - } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) label = resources.getString(com.android.internal.R.string.reduce_bright_colors_feature_name) contentDescription = label
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapper.kt index 33dc6ed..9a003ff 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapper.kt
@@ -36,36 +36,33 @@ @Main private val resources: Resources, private val theme: Resources.Theme, private val devicePostureController: DevicePostureController, - private val deviceStateManager: DeviceStateManager + private val deviceStateManager: DeviceStateManager, ) : QSTileDataToStateMapper<RotationLockTileModel> { override fun map(config: QSTileConfig, data: RotationLockTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { - this.label = resources.getString(R.string.quick_settings_rotation_unlocked_label) - this.contentDescription = - resources.getString(R.string.accessibility_quick_settings_rotation) + label = resources.getString(R.string.quick_settings_rotation_unlocked_label) + contentDescription = resources.getString(R.string.accessibility_quick_settings_rotation) if (data.isRotationLocked) { activationState = QSTileState.ActivationState.INACTIVE - this.secondaryLabel = EMPTY_SECONDARY_STRING + secondaryLabel = EMPTY_SECONDARY_STRING iconRes = R.drawable.qs_auto_rotate_icon_off } else { activationState = QSTileState.ActivationState.ACTIVE - this.secondaryLabel = + secondaryLabel = if (data.isCameraRotationEnabled) { resources.getString(R.string.rotation_lock_camera_rotation_on) } else { EMPTY_SECONDARY_STRING } - this.iconRes = R.drawable.qs_auto_rotate_icon_on + iconRes = R.drawable.qs_auto_rotate_icon_on } - this.icon = { - Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) if (isDeviceFoldable(resources, deviceStateManager)) { - this.secondaryLabel = getSecondaryLabelWithPosture(this.activationState) + secondaryLabel = getSecondaryLabelWithPosture(activationState) } - this.stateDescription = this.secondaryLabel - this.sideViewIcon = QSTileState.SideViewIcon.None + stateDescription = secondaryLabel + sideViewIcon = QSTileState.SideViewIcon.None supportedActions = setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) } @@ -86,7 +83,7 @@ return resources.getString( R.string.rotation_tile_with_posture_secondary_label_template, stateName, - posture + posture, ) }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapper.kt index 888bba87..08196bb 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapper.kt
@@ -29,10 +29,8 @@ /** Maps [DataSaverTileModel] to [QSTileState]. */ class DataSaverTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<DataSaverTileModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<DataSaverTileModel> { override fun map(config: QSTileConfig, data: DataSaverTileModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { with(data) { @@ -45,9 +43,7 @@ iconRes = R.drawable.qs_data_saver_icon_off secondaryLabel = resources.getStringArray(R.array.tile_states_saver)[1] } - val loadedIcon = - Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - icon = { loadedIcon } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) contentDescription = label supportedActions = setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/ui/ScreenRecordTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/ui/ScreenRecordTileMapper.kt index e74e77f..ba06de9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/ui/ScreenRecordTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/ui/ScreenRecordTileMapper.kt
@@ -30,10 +30,8 @@ /** Maps [ScreenRecordModel] to [QSTileState]. */ class ScreenRecordTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Resources.Theme, -) : QSTileDataToStateMapper<ScreenRecordModel> { +constructor(@Main private val resources: Resources, private val theme: Resources.Theme) : + QSTileDataToStateMapper<ScreenRecordModel> { override fun map(config: QSTileConfig, data: ScreenRecordModel): QSTileState = QSTileState.build(resources, theme, config.uiConfig) { label = resources.getString(R.string.quick_settings_screen_record_label) @@ -43,24 +41,12 @@ is ScreenRecordModel.Recording -> { activationState = QSTileState.ActivationState.ACTIVE iconRes = R.drawable.qs_screen_record_icon_on - val loadedIcon = - Icon.Loaded( - resources.getDrawable(iconRes!!, theme), - contentDescription = null - ) - icon = { loadedIcon } sideViewIcon = QSTileState.SideViewIcon.None secondaryLabel = resources.getString(R.string.quick_settings_screen_record_stop) } is ScreenRecordModel.Starting -> { activationState = QSTileState.ActivationState.ACTIVE iconRes = R.drawable.qs_screen_record_icon_on - val loadedIcon = - Icon.Loaded( - resources.getDrawable(iconRes!!, theme), - contentDescription = null - ) - icon = { loadedIcon } val countDown = data.countdownSeconds sideViewIcon = QSTileState.SideViewIcon.None secondaryLabel = String.format("%d...", countDown) @@ -68,17 +54,13 @@ is ScreenRecordModel.DoingNothing -> { activationState = QSTileState.ActivationState.INACTIVE iconRes = R.drawable.qs_screen_record_icon_off - val loadedIcon = - Icon.Loaded( - resources.getDrawable(iconRes!!, theme), - contentDescription = null - ) - icon = { loadedIcon } sideViewIcon = QSTileState.SideViewIcon.Chevron // tapping will open dialog secondaryLabel = resources.getString(R.string.quick_settings_screen_record_start) } } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) + contentDescription = if (TextUtils.isEmpty(secondaryLabel)) label else TextUtils.concat(label, ", ", secondaryLabel)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapper.kt index 597cf27..b4cfec4 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapper.kt
@@ -51,8 +51,7 @@ supportedActions = setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK) iconRes = sensorPrivacyTileResources.getIconRes(data.isBlocked) - icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) } - + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) sideViewIcon = QSTileState.SideViewIcon.None if (data.isBlocked) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapper.kt index f29c745d..eda8e5c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapper.kt
@@ -34,14 +34,13 @@ /** Maps [UiModeNightTileModel] to [QSTileState]. */ class UiModeNightTileMapper @Inject -constructor( - @Main private val resources: Resources, - private val theme: Theme, -) : QSTileDataToStateMapper<UiModeNightTileModel> { +constructor(@Main private val resources: Resources, private val theme: Theme) : + QSTileDataToStateMapper<UiModeNightTileModel> { companion object { val formatter12Hour: DateTimeFormatter = DateTimeFormatter.ofPattern("hh:mm a") val formatter24Hour: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm") } + override fun map(config: QSTileConfig, data: UiModeNightTileModel): QSTileState = with(data) { QSTileState.build(resources, theme, config.uiConfig) { @@ -76,7 +75,7 @@ if (isNightMode) R.string.quick_settings_dark_mode_secondary_label_until else R.string.quick_settings_dark_mode_secondary_label_on_at, - formatter.format(time) + formatter.format(time), ) } else if ( nightModeCustomType == UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME @@ -121,9 +120,7 @@ if (activationState == QSTileState.ActivationState.ACTIVE) R.drawable.qs_light_dark_theme_icon_on else R.drawable.qs_light_dark_theme_icon_off - val loadedIcon = - Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - icon = { loadedIcon } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) supportedActions = if (activationState == QSTileState.ActivationState.UNAVAILABLE)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapper.kt index eee95b7..a1bc8a8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapper.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapper.kt
@@ -42,9 +42,7 @@ label = getTileLabel()!! contentDescription = label iconRes = com.android.internal.R.drawable.stat_sys_managed_profile_status - icon = { - Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) - } + icon = Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null) when (data) { is WorkModeTileModel.HasActiveProfile -> {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt index 549f0a7..8394be5 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt
@@ -35,7 +35,7 @@ * // TODO(b/http://b/299909989): Clean up legacy mappings after the transition */ data class QSTileState( - val icon: () -> Icon?, + val icon: Icon?, val iconRes: Int?, val label: CharSequence, val activationState: ActivationState, @@ -54,21 +54,18 @@ resources: Resources, theme: Theme, config: QSTileUIConfig, - builder: Builder.() -> Unit + builder: Builder.() -> Unit, ): QSTileState { val iconDrawable = resources.getDrawable(config.iconRes, theme) return build( - { Icon.Loaded(iconDrawable, null) }, + Icon.Loaded(iconDrawable, null), resources.getString(config.labelRes), builder, ) } - fun build( - icon: () -> Icon?, - label: CharSequence, - builder: Builder.() -> Unit - ): QSTileState = Builder(icon, label).apply { builder() }.build() + fun build(icon: Icon?, label: CharSequence, builder: Builder.() -> Unit): QSTileState = + Builder(icon, label).apply { builder() }.build() } enum class ActivationState(val legacyState: Int) { @@ -117,10 +114,7 @@ data object None : SideViewIcon } - class Builder( - var icon: () -> Icon?, - var label: CharSequence, - ) { + class Builder(var icon: Icon?, var label: CharSequence) { var iconRes: Int? = null var activationState: ActivationState = ActivationState.INACTIVE var secondaryLabel: CharSequence? = null
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt index f89745f..35b1b96 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
@@ -19,6 +19,7 @@ import android.content.Context import android.os.UserHandle import android.util.Log +import com.android.app.tracing.coroutines.launchTraced as launch import com.android.internal.logging.InstanceId import com.android.systemui.Dumpable import com.android.systemui.animation.Expandable @@ -42,7 +43,6 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.takeWhile -import com.android.app.tracing.coroutines.launchTraced as launch // TODO(b/http://b/299909989): Use QSTileViewModel directly after the rollout class QSTileViewModelAdapter @@ -223,7 +223,7 @@ fun mapState( context: Context, viewModelState: QSTileState, - config: QSTileConfig + config: QSTileConfig, ): QSTile.State = // we have to use QSTile.BooleanState to support different side icons // which are bound to instanceof QSTile.BooleanState in QSTileView. @@ -241,7 +241,7 @@ viewModelState.supportedActions.contains(QSTileState.UserAction.TOGGLE_CLICK) icon = - when (val stateIcon = viewModelState.icon()) { + when (val stateIcon = viewModelState.icon) { is Icon.Loaded -> if (viewModelState.iconRes == null) DrawableIcon(stateIcon.drawable) else DrawableIconWithRes(stateIcon.drawable, viewModelState.iconRes)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt index f66125a..6787b8e 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt
@@ -52,7 +52,7 @@ ) object : QSTileViewModel { override val state: StateFlow<QSTileState?> = - MutableStateFlow(QSTileState.build({ null }, tileSpec.spec) {}) + MutableStateFlow(QSTileState.build(null, tileSpec.spec) {}) override val config: QSTileConfig = config override val isAvailable: StateFlow<Boolean> = MutableStateFlow(true)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/impl/custom/QSTileStateSubject.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/impl/custom/QSTileStateSubject.kt index 5b6fd8c..ab1c181 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/impl/custom/QSTileStateSubject.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/impl/custom/QSTileStateSubject.kt
@@ -44,7 +44,7 @@ check("other").that(other).isNotNull() other ?: return } - check("icon").that(actual.icon()).isEqualTo(other.icon()) + check("icon").that(actual.icon).isEqualTo(other.icon) check("iconRes").that(actual.iconRes).isEqualTo(other.iconRes) check("label").that(actual.label).isEqualTo(other.label) check("activationState").that(actual.activationState).isEqualTo(other.activationState)