summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/custom/domain/interactor/CustomTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapperTest.kt4
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapperTest.kt5
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapperTest.kt17
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapperTest.kt16
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/ui/ScreenRecordTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapperTest.kt1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapperTest.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/alarm/domain/AlarmTileMapper.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/battery/ui/BatterySaverTileMapper.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/colorcorrection/domain/ColorCorrectionTileMapper.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/flashlight/domain/FlashlightMapper.kt12
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/fontscaling/domain/FontScalingTileMapper.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/internet/domain/InternetTileMapper.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/inversion/domain/ColorInversionTileMapper.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapper.kt12
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/night/ui/NightDisplayTileMapper.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/onehanded/ui/OneHandedModeTileMapper.kt11
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/qr/ui/QRCodeScannerTileMapper.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/reducebrightness/ui/ReduceBrightColorsTileMapper.kt21
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/rotation/ui/mapper/RotationLockTileMapper.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/saver/domain/DataSaverTileMapper.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/ui/ScreenRecordTileMapper.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/sensorprivacy/ui/SensorPrivacyToggleTileMapper.kt11
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/uimodenight/domain/UiModeNightTileMapper.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapper.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileState.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt1
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt11
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/impl/custom/QSTileStateSubject.kt1
40 files changed, 113 insertions, 141 deletions
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 f1cd0c843256..79e4fef874b6 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
@@ -179,6 +179,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
val label = context.getString(R.string.status_bar_alarm)
return QSTileState(
{ Icon.Loaded(context.getDrawable(R.drawable.ic_alarm)!!, null) },
+ R.drawable.ic_alarm,
label,
activationState,
secondaryLabel,
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 6e9db2cbef07..a0d26c28cbfa 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
@@ -254,6 +254,7 @@ class BatterySaverTileMapperTest : SysuiTestCase() {
val label = context.getString(R.string.battery_detail_switch_title)
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 d05e98faee22..ea7b7c5f797d 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
@@ -78,6 +78,7 @@ class ColorCorrectionTileMapperTest : SysuiTestCase() {
val label = context.getString(R.string.quick_settings_color_correction_label)
return QSTileState(
{ Icon.Loaded(context.getDrawable(R.drawable.ic_qs_color_correction)!!, null) },
+ R.drawable.ic_qs_color_correction,
label,
activationState,
secondaryLabel,
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 3972938d7b1b..b4ff56566c75 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
@@ -245,6 +245,7 @@ class CustomTileMapperTest : SysuiTestCase() {
): QSTileState {
return QSTileState(
{ icon?.let { com.android.systemui.common.shared.model.Icon.Loaded(icon, null) } },
+ null,
"test label",
activationState,
"test subtitle",
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 b7b3fdbed955..f8e01be5163f 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
@@ -66,6 +66,7 @@ class FontScalingTileMapperTest : SysuiTestCase() {
null
)
},
+ R.drawable.ic_qs_font_scaling,
context.getString(R.string.quick_settings_font_scaling_label),
QSTileState.ActivationState.ACTIVE,
null,
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 39755bf8d764..c44836a70642 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
@@ -70,6 +70,7 @@ class InternetTileMapperTest : SysuiTestCase() {
QSTileState.ActivationState.ACTIVE,
context.getString(R.string.quick_settings_networks_available),
Icon.Loaded(context.getDrawable(wifiRes)!!, contentDescription = null),
+ wifiRes,
context.getString(R.string.quick_settings_internet_label)
)
QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
@@ -96,6 +97,7 @@ class InternetTileMapperTest : SysuiTestCase() {
context.getDrawable(R.drawable.ic_qs_no_internet_unavailable)!!,
contentDescription = null
),
+ R.drawable.ic_qs_no_internet_unavailable,
context.getString(R.string.quick_settings_networks_unavailable)
)
QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
@@ -105,11 +107,13 @@ class InternetTileMapperTest : SysuiTestCase() {
activationState: QSTileState.ActivationState,
secondaryLabel: String,
icon: Icon,
+ iconRes: Int,
contentDescription: String,
): QSTileState {
val label = context.getString(R.string.quick_settings_internet_label)
return QSTileState(
{ icon },
+ iconRes,
label,
activationState,
secondaryLabel,
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 ccd7ed92b884..a7bd69770a4f 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
@@ -39,9 +39,7 @@ class ColorInversionTileMapperTest : SysuiTestCase() {
private val colorInversionTileConfig = kosmos.qsColorInversionTileConfig
private val subtitleArrayId =
SubtitleArrayMapping.getSubtitleId(colorInversionTileConfig.tileSpec.spec)
- private val subtitleArray by lazy {
- context.resources.getStringArray(subtitleArrayId)
- }
+ private val subtitleArray by lazy { context.resources.getStringArray(subtitleArrayId) }
// Using lazy (versus =) to make sure we override the right context -- see b/311612168
private val mapper by lazy {
ColorInversionTileMapper(
@@ -93,6 +91,7 @@ class ColorInversionTileMapperTest : SysuiTestCase() {
val label = context.getString(R.string.quick_settings_inversion_label)
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 5d2e7013c2f4..75273f2a52e1 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
@@ -281,21 +281,16 @@ class NightDisplayTileMapperTest : SysuiTestCase() {
secondaryLabel: String?
): QSTileState {
val label = context.getString(R.string.quick_settings_night_display_label)
-
+ val iconRes =
+ if (activationState == QSTileState.ActivationState.ACTIVE)
+ R.drawable.qs_nightlight_icon_on
+ else R.drawable.qs_nightlight_icon_off
val contentDescription =
if (TextUtils.isEmpty(secondaryLabel)) label
else TextUtils.concat(label, ", ", secondaryLabel)
return QSTileState(
- {
- Icon.Loaded(
- context.getDrawable(
- if (activationState == QSTileState.ActivationState.ACTIVE)
- R.drawable.qs_nightlight_icon_on
- else R.drawable.qs_nightlight_icon_off
- )!!,
- null
- )
- },
+ { Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 7ef020da8b67..3189a9e063a1 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
@@ -97,6 +97,7 @@ class OneHandedModeTileMapperTest : SysuiTestCase() {
val label = context.getString(R.string.quick_settings_onehanded_label)
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 d26a21365f54..08e5cbef31ab 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
@@ -100,6 +100,7 @@ class QRCodeScannerTileMapperTest : SysuiTestCase() {
null
)
},
+ com.android.systemui.res.R.drawable.ic_qr_code_scanner,
label,
activationState,
secondaryLabel,
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 10e9bd695cbc..ca30e9ca3e69 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
@@ -83,17 +83,13 @@ class ReduceBrightColorsTileMapperTest : SysuiTestCase() {
): QSTileState {
val label =
context.getString(com.android.internal.R.string.reduce_bright_colors_feature_name)
+ val iconRes =
+ if (activationState == QSTileState.ActivationState.ACTIVE)
+ R.drawable.qs_extra_dim_icon_on
+ else R.drawable.qs_extra_dim_icon_off
return QSTileState(
- {
- Icon.Loaded(
- context.getDrawable(
- if (activationState == QSTileState.ActivationState.ACTIVE)
- R.drawable.qs_extra_dim_icon_on
- else R.drawable.qs_extra_dim_icon_off
- )!!,
- null
- )
- },
+ { Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
context.resources
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 60c69f427ef3..04ca38fa4343 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
@@ -172,6 +172,7 @@ class RotationLockTileMapperTest : SysuiTestCase() {
val label = context.getString(R.string.quick_settings_rotation_unlocked_label)
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 d162c778f607..9bb61415de28 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
@@ -92,6 +92,7 @@ class DataSaverTileMapperTest : SysuiTestCase() {
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 d7b7ab6b4e81..f9320a3414e9 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
@@ -111,6 +111,7 @@ class ScreenRecordTileMapperTest : SysuiTestCase() {
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 5e7aadcda6db..b08f39b0accf 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
@@ -147,6 +147,7 @@ class SensorPrivacyToggleTileMapperTest : SysuiTestCase() {
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
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 a9776068b20c..c021caa598b9 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
@@ -70,6 +70,7 @@ class UiModeNightTileMapperTest : SysuiTestCase() {
): QSTileState {
return QSTileState(
{ Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes,
label,
activationState,
secondaryLabel,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
index 56588ff75a5a..8887f5857baf 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
@@ -677,6 +677,10 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
mId = id;
}
+ public int getResourceId() {
+ return mId;
+ }
+
@Override
public boolean equals(Object o) {
return o instanceof DrawableIconWithRes && ((DrawableIconWithRes) o).mId == mId;
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 c0fc52e85866..f0889433094a 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
@@ -18,6 +18,7 @@ package com.android.systemui.qs.tiles.impl.alarm.domain
import android.content.res.Resources
import android.content.res.Resources.Theme
+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.alarm.domain.model.AlarmTileModel
@@ -82,7 +83,8 @@ constructor(
secondaryLabel = resources.getString(R.string.qs_alarm_tile_no_alarm)
}
}
-
+ iconRes = R.drawable.ic_alarm
+ 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 0c08fbacfcfc..bcf0935adf85 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
@@ -38,17 +38,10 @@ constructor(
QSTileState.build(resources, theme, config.uiConfig) {
label = resources.getString(R.string.battery_detail_switch_title)
contentDescription = label
-
- icon = {
- Icon.Loaded(
- resources.getDrawable(
- if (data.isPowerSaving) R.drawable.qs_battery_saver_icon_on
- else R.drawable.qs_battery_saver_icon_off,
- theme
- ),
- null
- )
- }
+ 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) }
sideViewIcon = QSTileState.SideViewIcon.None
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 1efbfd70fa98..cad7c65ad112 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
@@ -37,6 +37,8 @@ constructor(
QSTileState.build(resources, theme, config.uiConfig) {
val subtitleArray = resources.getStringArray(R.array.tile_states_color_correction)
+ iconRes = R.drawable.ic_qs_color_correction
+
if (data.isEnabled) {
activationState = QSTileState.ActivationState.ACTIVE
secondaryLabel = subtitleArray[2]
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 58e761370457..d7d61241fc6c 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
@@ -37,14 +37,16 @@ constructor(
override fun map(config: QSTileConfig, data: FlashlightTileModel): QSTileState =
QSTileState.build(resources, theme, config.uiConfig) {
+ iconRes =
+ if (data is FlashlightTileModel.FlashlightAvailable && data.isEnabled) {
+ R.drawable.qs_flashlight_icon_on
+ } else {
+ R.drawable.qs_flashlight_icon_off
+ }
val icon =
Icon.Loaded(
resources.getDrawable(
- if (data is FlashlightTileModel.FlashlightAvailable && data.isEnabled) {
- R.drawable.qs_flashlight_icon_on
- } else {
- R.drawable.qs_flashlight_icon_off
- },
+ iconRes!!,
theme,
),
contentDescription = null
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 26069c774364..6b4dda13a5e6 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
@@ -36,10 +36,11 @@ constructor(
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(
- R.drawable.ic_qs_font_scaling,
+ iconRes!!,
theme,
),
contentDescription = null
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 caae4d26634d..e543e4bdc930 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
@@ -53,6 +53,7 @@ constructor(
stateDescription = data.stateDescription.loadContentDescription(context)
contentDescription = data.contentDescription.loadContentDescription(context)
+ iconRes = data.iconId
if (data.icon != null) {
this.icon = { data.icon }
} else if (data.iconId != 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 4af985424a39..40aee65f41a7 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
@@ -41,22 +41,13 @@ constructor(
if (data.isEnabled) {
activationState = QSTileState.ActivationState.ACTIVE
secondaryLabel = subtitleArray[2]
- icon = {
- Icon.Loaded(
- resources.getDrawable(R.drawable.qs_invert_colors_icon_on, theme),
- null
- )
- }
+ iconRes = R.drawable.qs_invert_colors_icon_on
} else {
activationState = QSTileState.ActivationState.INACTIVE
secondaryLabel = subtitleArray[1]
- icon = {
- Icon.Loaded(
- resources.getDrawable(R.drawable.qs_invert_colors_icon_off, theme),
- null
- )
- }
+ iconRes = R.drawable.qs_invert_colors_icon_off
}
+ 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/location/domain/LocationTileMapper.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/location/domain/LocationTileMapper.kt
index fe5445d00670..d58f5abcd018 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
@@ -37,14 +37,16 @@ constructor(
override fun map(config: QSTileConfig, data: LocationTileModel): QSTileState =
QSTileState.build(resources, theme, config.uiConfig) {
+ iconRes =
+ if (data.isEnabled) {
+ R.drawable.qs_location_icon_on
+ } else {
+ R.drawable.qs_location_icon_off
+ }
val icon =
Icon.Loaded(
resources.getDrawable(
- if (data.isEnabled) {
- R.drawable.qs_location_icon_on
- } else {
- R.drawable.qs_location_icon_off
- },
+ iconRes!!,
theme,
),
contentDescription = null
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 5c2dcfcaf37c..bcf7cc763b9e 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
@@ -52,21 +52,14 @@ constructor(
if (data.isActivated) {
activationState = QSTileState.ActivationState.ACTIVE
- val loadedIcon =
- Icon.Loaded(
- resources.getDrawable(R.drawable.qs_nightlight_icon_on, theme),
- contentDescription = null
- )
- icon = { loadedIcon }
+ iconRes = R.drawable.qs_nightlight_icon_on
} else {
activationState = QSTileState.ActivationState.INACTIVE
- val loadedIcon =
- Icon.Loaded(
- resources.getDrawable(R.drawable.qs_nightlight_icon_off, theme),
- contentDescription = null
- )
- icon = { loadedIcon }
+ iconRes = R.drawable.qs_nightlight_icon_off
}
+ val loadedIcon =
+ Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null)
+ icon = { loadedIcon }
secondaryLabel = getSecondaryLabel(data, resources)
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 9166ed8faacf..40809960735f 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
@@ -38,15 +38,8 @@ constructor(
QSTileState.build(resources, theme, config.uiConfig) {
val subtitleArray = resources.getStringArray(R.array.tile_states_onehanded)
label = resources.getString(R.string.quick_settings_onehanded_label)
- icon = {
- Icon.Loaded(
- resources.getDrawable(
- com.android.internal.R.drawable.ic_qs_one_handed_mode,
- theme
- ),
- null
- )
- }
+ iconRes = com.android.internal.R.drawable.ic_qs_one_handed_mode
+ 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 45a77179fb3f..823174234b13 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
@@ -38,9 +38,8 @@ constructor(
QSTileState.build(resources, theme, config.uiConfig) {
label = resources.getString(R.string.qr_code_scanner_title)
contentDescription = label
- icon = {
- Icon.Loaded(resources.getDrawable(R.drawable.ic_qr_code_scanner, theme), null)
- }
+ iconRes = R.drawable.ic_qr_code_scanner
+ 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 fca93dfe47da..85ee02207ac6 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
@@ -39,28 +39,23 @@ constructor(
QSTileState.build(resources, theme, config.uiConfig) {
if (data.isEnabled) {
activationState = QSTileState.ActivationState.ACTIVE
- icon = {
- Icon.Loaded(
- drawable = resources.getDrawable(R.drawable.qs_extra_dim_icon_on, theme),
- contentDescription = null
- )
- }
-
+ iconRes = R.drawable.qs_extra_dim_icon_on
secondaryLabel =
resources
.getStringArray(R.array.tile_states_reduce_brightness)[Tile.STATE_ACTIVE]
} else {
activationState = QSTileState.ActivationState.INACTIVE
- icon = {
- Icon.Loaded(
- drawable = resources.getDrawable(R.drawable.qs_extra_dim_icon_off, theme),
- contentDescription = null
- )
- }
+ iconRes = R.drawable.qs_extra_dim_icon_off
secondaryLabel =
resources
.getStringArray(R.array.tile_states_reduce_brightness)[Tile.STATE_INACTIVE]
}
+ icon = {
+ Icon.Loaded(
+ drawable = resources.getDrawable(iconRes!!, theme),
+ contentDescription = 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 070cdef336e5..8e80fb0b4c3e 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
@@ -44,12 +44,7 @@ constructor(
if (data.isRotationLocked) {
activationState = QSTileState.ActivationState.INACTIVE
this.secondaryLabel = EMPTY_SECONDARY_STRING
- this.icon = {
- Icon.Loaded(
- resources.getDrawable(R.drawable.qs_auto_rotate_icon_off, theme),
- contentDescription = null
- )
- }
+ iconRes = R.drawable.qs_auto_rotate_icon_off
} else {
activationState = QSTileState.ActivationState.ACTIVE
this.secondaryLabel =
@@ -58,12 +53,10 @@ constructor(
} else {
EMPTY_SECONDARY_STRING
}
- this.icon = {
- Icon.Loaded(
- resources.getDrawable(R.drawable.qs_auto_rotate_icon_on, theme),
- contentDescription = null
- )
- }
+ this.iconRes = R.drawable.qs_auto_rotate_icon_on
+ }
+ this.icon = {
+ Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null)
}
if (isDeviceFoldable()) {
this.secondaryLabel = getSecondaryLabelWithPosture(this.activationState)
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 df25600228a5..888bba87a03a 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
@@ -36,7 +36,6 @@ constructor(
override fun map(config: QSTileConfig, data: DataSaverTileModel): QSTileState =
QSTileState.build(resources, theme, config.uiConfig) {
with(data) {
- val iconRes: Int
if (isEnabled) {
activationState = QSTileState.ActivationState.ACTIVE
iconRes = R.drawable.qs_data_saver_icon_on
@@ -47,7 +46,7 @@ constructor(
secondaryLabel = resources.getStringArray(R.array.tile_states_saver)[1]
}
val loadedIcon =
- Icon.Loaded(resources.getDrawable(iconRes, theme), contentDescription = null)
+ Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null)
icon = { loadedIcon }
contentDescription = label
supportedActions =
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 c09b0e309d7f..1cf91262a18d 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
@@ -42,9 +42,10 @@ constructor(
when (data) {
is ScreenRecordTileModel.Recording -> {
activationState = QSTileState.ActivationState.ACTIVE
+ iconRes = R.drawable.qs_screen_record_icon_on
val loadedIcon =
Icon.Loaded(
- resources.getDrawable(R.drawable.qs_screen_record_icon_on, theme),
+ resources.getDrawable(iconRes!!, theme),
contentDescription = null
)
icon = { loadedIcon }
@@ -53,9 +54,10 @@ constructor(
}
is ScreenRecordTileModel.Starting -> {
activationState = QSTileState.ActivationState.ACTIVE
+ iconRes = R.drawable.qs_screen_record_icon_on
val loadedIcon =
Icon.Loaded(
- resources.getDrawable(R.drawable.qs_screen_record_icon_on, theme),
+ resources.getDrawable(iconRes!!, theme),
contentDescription = null
)
icon = { loadedIcon }
@@ -65,9 +67,10 @@ constructor(
}
is ScreenRecordTileModel.DoingNothing -> {
activationState = QSTileState.ActivationState.INACTIVE
+ iconRes = R.drawable.qs_screen_record_icon_off
val loadedIcon =
Icon.Loaded(
- resources.getDrawable(R.drawable.qs_screen_record_icon_off, theme),
+ resources.getDrawable(iconRes!!, theme),
contentDescription = null
)
icon = { loadedIcon }
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 52622d26348d..597cf274dcff 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
@@ -50,15 +50,8 @@ constructor(
contentDescription = label
supportedActions =
setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK)
- icon = {
- Icon.Loaded(
- resources.getDrawable(
- sensorPrivacyTileResources.getIconRes(data.isBlocked),
- theme
- ),
- null
- )
- }
+ iconRes = sensorPrivacyTileResources.getIconRes(data.isBlocked)
+ icon = { Icon.Loaded(resources.getDrawable(iconRes!!, theme), null) }
sideViewIcon = QSTileState.SideViewIcon.None
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 ffef2b6ecfb5..f29c745d8119 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
@@ -117,12 +117,12 @@ constructor(
}
}
- val iconRes =
+ iconRes =
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.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null)
icon = { loadedIcon }
supportedActions =
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 55445bb922a5..eee95b7311d3 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
@@ -41,15 +41,9 @@ constructor(
QSTileState.build(resources, theme, config.uiConfig) {
label = getTileLabel()!!
contentDescription = label
-
+ iconRes = com.android.internal.R.drawable.stat_sys_managed_profile_status
icon = {
- Icon.Loaded(
- resources.getDrawable(
- com.android.internal.R.drawable.stat_sys_managed_profile_status,
- theme
- ),
- contentDescription = null
- )
+ Icon.Loaded(resources.getDrawable(iconRes!!, theme), contentDescription = null)
}
when (data) {
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 b927e41bc97e..ae6c0143f603 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
@@ -29,10 +29,14 @@ import kotlin.reflect.KClass
* [QSTileState.build] for better state creation experience and preset default values for certain
* fields.
*
+ * @param iconRes For when we want to have Loaded icon, but still keep a reference to the resource
+ * id. A use case would be for tests that have to compare animated drawables.
+ *
* // TODO(b/http://b/299909989): Clean up legacy mappings after the transition
*/
data class QSTileState(
val icon: () -> Icon?,
+ val iconRes: Int?,
val label: CharSequence,
val activationState: ActivationState,
val secondaryLabel: CharSequence?,
@@ -111,6 +115,7 @@ data class QSTileState(
var icon: () -> Icon?,
var label: CharSequence,
) {
+ var iconRes: Int? = null
var activationState: ActivationState = ActivationState.INACTIVE
var secondaryLabel: CharSequence? = null
var supportedActions: Set<UserAction> = setOf(UserAction.CLICK)
@@ -123,6 +128,7 @@ data class QSTileState(
fun build(): QSTileState =
QSTileState(
icon,
+ iconRes,
label,
activationState,
secondaryLabel,
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 5346b237111f..7be13e08f972 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
@@ -28,6 +28,7 @@ import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.qs.QSHost
import com.android.systemui.qs.tileimpl.QSTileImpl.DrawableIcon
+import com.android.systemui.qs.tileimpl.QSTileImpl.DrawableIconWithRes
import com.android.systemui.qs.tileimpl.QSTileImpl.ResourceIcon
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
@@ -241,7 +242,9 @@ constructor(
iconSupplier = Supplier {
when (val stateIcon = viewModelState.icon()) {
- is Icon.Loaded -> DrawableIcon(stateIcon.drawable)
+ is Icon.Loaded ->
+ if (viewModelState.iconRes == null) DrawableIcon(stateIcon.drawable)
+ else DrawableIconWithRes(stateIcon.drawable, viewModelState.iconRes)
is Icon.Resource -> ResourceIcon.get(stateIcon.res)
null -> null
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt
index 0ec8552e8595..42b81de92af7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/base/viewmodel/QSTileViewModelImplTest.kt
@@ -116,6 +116,7 @@ class QSTileViewModelImplTest : SysuiTestCase() {
"test_spec:\n" +
" QSTileState(" +
"icon=() -> com.android.systemui.common.shared.model.Icon?, " +
+ "iconRes=null, " +
"label=test_data, " +
"activationState=INACTIVE, " +
"secondaryLabel=null, " +
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt
index 4215b8c9a1a3..e7bde681fe6f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/impl/work/ui/WorkModeTileMapperTest.kt
@@ -109,15 +109,10 @@ class WorkModeTileMapperTest : SysuiTestCase() {
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(
- com.android.internal.R.drawable.stat_sys_managed_profile_status
- )!!,
- null
- )
- },
+ icon = { Icon.Loaded(context.getDrawable(iconRes)!!, null) },
+ iconRes = iconRes,
label = label,
activationState = activationState,
secondaryLabel =
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 4f5c9b48690d..5b6fd8c3bd62 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
@@ -45,6 +45,7 @@ private constructor(failureMetadata: FailureMetadata, subject: QSTileState?) :
other ?: return
}
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)
check("secondaryLabel").that(actual.secondaryLabel).isEqualTo(other.secondaryLabel)