From fd5f585fe279ed79f0ff2cbec3a77ac169e34289 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Mon, 8 May 2023 19:36:44 +0000 Subject: [PATCH 1/2] Dialog color tokens Test: manual, open dialogs that use base theme Test: open screen record dialog Fixes: 278574288 Change-Id: I1e664cfd34b9befc01811925f6c2cf33f8d45a7e --- .../SystemUI/res/drawable/qs_dialog_btn_filled.xml | 2 +- .../res/drawable/qs_dialog_btn_filled_large.xml | 2 +- .../SystemUI/res/drawable/qs_dialog_btn_outline.xml | 2 +- .../res/layout/alert_dialog_title_systemui.xml | 2 +- packages/SystemUI/res/layout/screen_record_dialog.xml | 9 +++++---- packages/SystemUI/res/layout/screen_share_dialog.xml | 8 +++----- packages/SystemUI/res/values/styles.xml | 11 ++++++----- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/SystemUI/res/drawable/qs_dialog_btn_filled.xml b/packages/SystemUI/res/drawable/qs_dialog_btn_filled.xml index 14cb1de9fa2dc..c4e45bf2c2237 100644 --- a/packages/SystemUI/res/drawable/qs_dialog_btn_filled.xml +++ b/packages/SystemUI/res/drawable/qs_dialog_btn_filled.xml @@ -28,7 +28,7 @@ - + - + diff --git a/packages/SystemUI/res/drawable/qs_dialog_btn_outline.xml b/packages/SystemUI/res/drawable/qs_dialog_btn_outline.xml index a47299d6f854a..b0dc6523e9714 100644 --- a/packages/SystemUI/res/drawable/qs_dialog_btn_outline.xml +++ b/packages/SystemUI/res/drawable/qs_dialog_btn_outline.xml @@ -29,7 +29,7 @@ - @@ -47,7 +48,7 @@ @@ -81,6 +81,7 @@ android:minHeight="48dp" android:layout_weight="1" android:popupBackground="@drawable/screenrecord_spinner_background" + android:textColor="?androidprv:attr/materialColorOnSurface" android:dropDownWidth="274dp" android:prompt="@string/screenrecord_audio_label"/> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index cb5342a0d66ba..f16d9aaa8c71a 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -406,7 +406,7 @@ @style/Widget.Dialog.Button @style/Widget.Dialog.Button.BorderButton @style/Widget.Dialog.Button.BorderButton - ?androidprv:attr/colorSurface + ?androidprv:attr/materialColorSurfaceBright @style/ScrollableAlertDialogStyle @style/ButtonBarStyle @style/Widget.Dialog.Button.Large @@ -1055,7 +1055,7 @@ @@ -93,7 +93,7 @@ - @@ -390,8 +406,15 @@ @android:color/transparent - + + + @@ -605,11 +628,11 @@ 0.01 20sp @*android:string/config_headlineFontFamily - ?android:attr/textColorSecondary + ?attr/onSurfaceVariant @@ -1111,6 +1134,11 @@ ?androidprv:attr/materialColorOnPrimaryFixed + + diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt b/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt index 6265b3c056e70..3432628e6d67f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt @@ -18,6 +18,7 @@ package com.android.systemui.qs.external import android.content.Context import android.graphics.drawable.Icon +import android.view.ContextThemeWrapper import android.view.LayoutInflater import android.view.ViewGroup import android.widget.TextView @@ -66,7 +67,8 @@ class TileRequestDialog( } private fun createTileView(tileData: TileData): QSTileView { - val tile = QSTileViewImpl(context, QSIconViewImpl(context), true) + val themedContext = ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings) + val tile = QSTileViewImpl(themedContext, QSIconViewImpl(themedContext), true) val state = QSTile.BooleanState().apply { label = tileData.label handlesLongClick = false diff --git a/packages/SystemUI/src/com/android/systemui/qs/footer/ui/binder/FooterActionsViewBinder.kt b/packages/SystemUI/src/com/android/systemui/qs/footer/ui/binder/FooterActionsViewBinder.kt index 9c9ad33e4918f..3c53d77c6beb2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/footer/ui/binder/FooterActionsViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/footer/ui/binder/FooterActionsViewBinder.kt @@ -244,8 +244,8 @@ class FooterActionsViewBinder @Inject constructor() { val backgroundResource = when (model.backgroundColor) { - R.attr.offStateColor -> R.drawable.qs_footer_action_circle - com.android.internal.R.attr.colorAccent -> R.drawable.qs_footer_action_circle_color + R.attr.shadeInactive -> R.drawable.qs_footer_action_circle + R.attr.shadeActive -> R.drawable.qs_footer_action_circle_color else -> error("Unsupported icon background resource ${model.backgroundColor}") } buttonView.setBackgroundResource(backgroundResource) diff --git a/packages/SystemUI/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModel.kt index b3596a254b7d2..32146b5b00e4a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModel.kt @@ -145,8 +145,12 @@ class FooterActionsViewModel( R.drawable.ic_settings, ContentDescription.Resource(R.string.accessibility_quick_settings_settings) ), - iconTint = null, - backgroundColor = R.attr.offStateColor, + iconTint = + Utils.getColorAttrDefaultColor( + context, + R.attr.onShadeInactiveVariant, + ), + backgroundColor = R.attr.shadeInactive, this::onSettingsButtonClicked, ) @@ -162,9 +166,9 @@ class FooterActionsViewModel( iconTint = Utils.getColorAttrDefaultColor( context, - com.android.internal.R.attr.textColorOnAccent, + R.attr.onShadeActive, ), - backgroundColor = com.android.internal.R.attr.colorAccent, + backgroundColor = R.attr.shadeActive, this::onPowerButtonClicked, ) } else { @@ -264,7 +268,7 @@ class FooterActionsViewModel( ), ), iconTint = null, - backgroundColor = R.attr.offStateColor, + backgroundColor = R.attr.shadeInactive, onClick = this::onUserSwitcherClicked, ) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java index e54168162de6e..7e45491adc830 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java @@ -248,13 +248,11 @@ public class QSIconViewImpl extends QSIconView { */ private static int getIconColorForState(Context context, QSTile.State state) { if (state.disabledByPolicy || state.state == Tile.STATE_UNAVAILABLE) { - return Utils.getColorAttrDefaultColor( - context, com.android.internal.R.attr.textColorTertiary); + return Utils.getColorAttrDefaultColor(context, R.attr.outline); } else if (state.state == Tile.STATE_INACTIVE) { - return Utils.getColorAttrDefaultColor(context, android.R.attr.textColorPrimary); + return Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactiveVariant); } else if (state.state == Tile.STATE_ACTIVE) { - return Utils.getColorAttrDefaultColor(context, - com.android.internal.R.attr.textColorOnAccent); + return Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive); } else { Log.e("QSIconView", "Invalid state " + state); return 0; diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index b80668379e49c..d81e4c229aa7c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -29,6 +29,7 @@ import android.os.Trace import android.service.quicksettings.Tile import android.text.TextUtils import android.util.Log +import android.util.TypedValue import android.view.Gravity import android.view.LayoutInflater import android.view.View @@ -92,24 +93,21 @@ open class QSTileViewImpl @JvmOverloads constructor( updateHeight() } - private val colorActive = Utils.getColorAttrDefaultColor(context, - com.android.internal.R.attr.colorAccentPrimary) - private val colorInactive = Utils.getColorAttrDefaultColor(context, R.attr.offStateColor) - private val colorUnavailable = Utils.applyAlpha(UNAVAILABLE_ALPHA, colorInactive) + private val colorActive = Utils.getColorAttrDefaultColor(context, R.attr.shadeActive) + private val colorInactive = Utils.getColorAttrDefaultColor(context, R.attr.shadeInactive) + private val colorUnavailable = Utils.getColorAttrDefaultColor(context, R.attr.shadeDisabled) - private val colorLabelActive = - Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.textColorOnAccent) - private val colorLabelInactive = - Utils.getColorAttrDefaultColor(context, android.R.attr.textColorPrimary) + private val colorLabelActive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive) + private val colorLabelInactive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactive) private val colorLabelUnavailable = - Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.textColorTertiary) + Utils.getColorAttrDefaultColor(context, R.attr.outline) private val colorSecondaryLabelActive = - Utils.getColorAttrDefaultColor(context, android.R.attr.textColorSecondaryInverse) + Utils.getColorAttrDefaultColor(context, R.attr.onShadeActiveVariant) private val colorSecondaryLabelInactive = - Utils.getColorAttrDefaultColor(context, android.R.attr.textColorSecondary) + Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactiveVariant) private val colorSecondaryLabelUnavailable = - Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.textColorTertiary) + Utils.getColorAttrDefaultColor(context, R.attr.outline) private lateinit var label: TextView protected lateinit var secondaryLabel: TextView @@ -151,6 +149,11 @@ open class QSTileViewImpl @JvmOverloads constructor( private val locInScreen = IntArray(2) init { + val typedValue = TypedValue() + if (!getContext().theme.resolveAttribute(R.attr.isQsTheme, typedValue, true)) { + throw IllegalStateException("QSViewImpl must be inflated with a theme that contains " + + "Theme.SystemUI.QuickSettings") + } setId(generateViewId()) orientation = LinearLayout.HORIZONTAL gravity = Gravity.CENTER_VERTICAL or Gravity.START diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt index a60dad4a14fe0..fe6c9b3fe7b11 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt @@ -15,9 +15,11 @@ package com.android.systemui.qs import android.graphics.Rect import android.testing.AndroidTestingRunner +import android.testing.TestableContext import android.testing.TestableLooper import android.testing.TestableLooper.RunWithLooper import android.testing.ViewUtils +import android.view.ContextThemeWrapper import android.view.View import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.accessibility.AccessibilityNodeInfo @@ -55,19 +57,24 @@ class QSPanelTest : SysuiTestCase() { private lateinit var footer: View + private val themedContext = TestableContext( + ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings) + ) + @Before @Throws(Exception::class) fun setup() { MockitoAnnotations.initMocks(this) testableLooper = TestableLooper.get(this) + // Apply only the values of the theme that are not defined testableLooper.runWithLooper { - qsPanel = QSPanel(context, null) + qsPanel = QSPanel(themedContext, null) qsPanel.mUsingMediaPlayer = true qsPanel.initialize(qsLogger) // QSPanel inflates a footer inside of it, mocking it here - footer = LinearLayout(context).apply { id = R.id.qs_footer } + footer = LinearLayout(themedContext).apply { id = R.id.qs_footer } qsPanel.addView(footer, MATCH_PARENT, 100) qsPanel.onFinishInflate() // Provides a parent with non-zero size for QSPanel @@ -105,12 +112,12 @@ class QSPanelTest : SysuiTestCase() { qsPanel.tileLayout?.addTile( QSPanelControllerBase.TileRecord( mock(QSTile::class.java), - QSTileViewImpl(context, QSIconViewImpl(context)) + QSTileViewImpl(themedContext, QSIconViewImpl(themedContext)) ) ) - val mediaView = FrameLayout(context) - mediaView.addView(View(context), MATCH_PARENT, 800) + val mediaView = FrameLayout(themedContext) + mediaView.addView(View(themedContext), MATCH_PARENT, 800) qsPanel.setUsingHorizontalLayout(/* horizontal */ true, mediaView, /* force */ true) qsPanel.measure( @@ -135,12 +142,12 @@ class QSPanelTest : SysuiTestCase() { qsPanel.tileLayout?.addTile( QSPanelControllerBase.TileRecord( mock(QSTile::class.java), - QSTileViewImpl(context, QSIconViewImpl(context)) + QSTileViewImpl(themedContext, QSIconViewImpl(themedContext)) ) ) - val mediaView = FrameLayout(context) - mediaView.addView(View(context), MATCH_PARENT, 800) + val mediaView = FrameLayout(themedContext) + mediaView.addView(View(themedContext), MATCH_PARENT, 800) qsPanel.setUsingHorizontalLayout(/* horizontal */ true, mediaView, /* force */ true) qsPanel.measure( @@ -161,7 +168,10 @@ class QSPanelTest : SysuiTestCase() { @Test fun testBottomPadding() { val padding = 10 - context.orCreateTestableResources.addOverride(R.dimen.qs_panel_padding_bottom, padding) + themedContext.orCreateTestableResources.addOverride( + R.dimen.qs_panel_padding_bottom, + padding + ) qsPanel.updatePadding() assertThat(qsPanel.paddingBottom).isEqualTo(padding) } @@ -170,8 +180,11 @@ class QSPanelTest : SysuiTestCase() { fun testTopPadding() { val padding = 10 val paddingCombined = 100 - context.orCreateTestableResources.addOverride(R.dimen.qs_panel_padding_top, padding) - context.orCreateTestableResources.addOverride(R.dimen.qs_panel_padding_top, paddingCombined) + themedContext.orCreateTestableResources.addOverride(R.dimen.qs_panel_padding_top, padding) + themedContext.orCreateTestableResources.addOverride( + R.dimen.qs_panel_padding_top, + paddingCombined + ) qsPanel.updatePadding() assertThat(qsPanel.paddingTop).isEqualTo(paddingCombined) diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java index 87892539ccfe0..f55ef65a8fc1d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java @@ -26,12 +26,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.test.suitebuilder.annotation.SmallTest; import android.testing.TestableLooper; +import android.view.ContextThemeWrapper; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; @@ -56,14 +58,17 @@ public class TileLayoutTest extends SysuiTestCase { private Resources mResources; private int mLayoutSizeForOneTile; private TileLayout mTileLayout; // under test + private Context mSpyContext; + @Before public void setUp() throws Exception { - Context context = Mockito.spy(mContext); - mResources = Mockito.spy(context.getResources()); - Mockito.when(mContext.getResources()).thenReturn(mResources); + mSpyContext = Mockito.spy( + new ContextThemeWrapper(mContext, R.style.Theme_SystemUI_QuickSettings)); + mResources = Mockito.spy(mSpyContext.getResources()); + when(mSpyContext.getResources()).thenReturn(mResources); - mTileLayout = new TileLayout(context); + mTileLayout = new TileLayout(mSpyContext); // Layout needs to leave space for the tile margins. Three times the margin size is // sufficient for any number of columns. mLayoutSizeForOneTile = @@ -73,7 +78,7 @@ public class TileLayoutTest extends SysuiTestCase { private QSPanelControllerBase.TileRecord createTileRecord() { return new QSPanelControllerBase.TileRecord( mock(QSTile.class), - spy(new QSTileViewImpl(mContext, new QSIconViewImpl(mContext)))); + spy(new QSTileViewImpl(mSpyContext, new QSIconViewImpl(mSpyContext)))); } @Test @@ -161,7 +166,7 @@ public class TileLayoutTest extends SysuiTestCase { .layout(left2.capture(), top2.capture(), right2.capture(), bottom2.capture()); // We assume two tiles will always fit side-by-side. - assertTrue(mContext.getResources().getInteger(R.integer.quick_settings_num_columns) > 1); + assertTrue(mSpyContext.getResources().getInteger(R.integer.quick_settings_num_columns) > 1); // left <= right, top <= bottom assertTrue(left1.getValue() <= right1.getValue()); @@ -218,16 +223,16 @@ public class TileLayoutTest extends SysuiTestCase { @Test public void resourcesChanged_updateResources_returnsTrue() { - Mockito.when(mResources.getInteger(R.integer.quick_settings_num_columns)).thenReturn(1); + when(mResources.getInteger(R.integer.quick_settings_num_columns)).thenReturn(1); mTileLayout.updateResources(); // setup with 1 - Mockito.when(mResources.getInteger(R.integer.quick_settings_num_columns)).thenReturn(2); + when(mResources.getInteger(R.integer.quick_settings_num_columns)).thenReturn(2); assertEquals(true, mTileLayout.updateResources()); } @Test public void resourcesSame_updateResources_returnsFalse() { - Mockito.when(mResources.getInteger(R.integer.quick_settings_num_columns)).thenReturn(1); + when(mResources.getInteger(R.integer.quick_settings_num_columns)).thenReturn(1); mTileLayout.updateResources(); // setup with 1 assertEquals(false, mTileLayout.updateResources()); @@ -250,7 +255,7 @@ public class TileLayoutTest extends SysuiTestCase { QSPanelControllerBase.TileRecord tileRecord = createTileRecord(); mTileLayout.addTile(tileRecord); - FakeTileView tileView = new FakeTileView(mContext); + FakeTileView tileView = new FakeTileView(mSpyContext); QSTile.State state = new QSTile.State(); state.label = "TEST LABEL"; state.secondaryLabel = "TEST SECONDARY LABEL"; @@ -276,9 +281,10 @@ public class TileLayoutTest extends SysuiTestCase { } private void changeFontScaling(float scale) { - Configuration configuration = new Configuration(mContext.getResources().getConfiguration()); + Configuration configuration = + new Configuration(mSpyContext.getResources().getConfiguration()); configuration.fontScale = scale; // updateConfiguration could help update on both resource configuration and displayMetrics - mContext.getResources().updateConfiguration(configuration, null, null); + mSpyContext.getResources().updateConfiguration(configuration, null, null); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt index 2cc6709d0f37d..d647d6add512c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/footer/ui/viewmodel/FooterActionsViewModelTest.kt @@ -21,6 +21,7 @@ import android.os.UserManager import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.testing.TestableLooper.RunWithLooper +import android.view.ContextThemeWrapper import androidx.test.filters.SmallTest import com.android.settingslib.Utils import com.android.settingslib.drawable.UserIconDrawable @@ -63,6 +64,8 @@ class FooterActionsViewModelTest : SysuiTestCase() { private val testScope = TestScope() private lateinit var utils: FooterActionsTestUtils + private val themedContext = ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings) + @Before fun setUp() { utils = FooterActionsTestUtils(context, TestableLooper.get(this), testScope.testScheduler) @@ -84,8 +87,14 @@ class FooterActionsViewModelTest : SysuiTestCase() { ContentDescription.Resource(R.string.accessibility_quick_settings_settings) ) ) - assertThat(settings.backgroundColor).isEqualTo(R.attr.offStateColor) - assertThat(settings.iconTint).isNull() + assertThat(settings.backgroundColor).isEqualTo(R.attr.shadeInactive) + assertThat(settings.iconTint) + .isEqualTo( + Utils.getColorAttrDefaultColor( + themedContext, + R.attr.onShadeInactiveVariant, + ) + ) } @Test @@ -105,12 +114,12 @@ class FooterActionsViewModelTest : SysuiTestCase() { ContentDescription.Resource(R.string.accessibility_quick_settings_power_menu) ) ) - assertThat(power.backgroundColor).isEqualTo(com.android.internal.R.attr.colorAccent) + assertThat(power.backgroundColor).isEqualTo(R.attr.shadeActive) assertThat(power.iconTint) .isEqualTo( Utils.getColorAttrDefaultColor( - context, - com.android.internal.R.attr.textColorOnAccent, + themedContext, + R.attr.onShadeActive, ), ) } @@ -170,7 +179,7 @@ class FooterActionsViewModelTest : SysuiTestCase() { assertThat(userSwitcher).isNotNull() assertThat(userSwitcher!!.icon) .isEqualTo(Icon.Loaded(picture, ContentDescription.Loaded("Signed in as foo"))) - assertThat(userSwitcher.backgroundColor).isEqualTo(R.attr.offStateColor) + assertThat(userSwitcher.backgroundColor).isEqualTo(R.attr.shadeInactive) // Change the current user name. userSwitcherControllerWrapper.currentUserName = "bar" diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt index 28aeba461c50c..3c667725c78ae 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt @@ -22,6 +22,7 @@ import android.service.quicksettings.Tile import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.text.TextUtils +import android.view.ContextThemeWrapper import android.view.View import android.view.accessibility.AccessibilityNodeInfo import android.widget.TextView @@ -386,7 +387,11 @@ class QSTileViewImplTest : SysuiTestCase() { context: Context, icon: QSIconView, collapsed: Boolean - ) : QSTileViewImpl(context, icon, collapsed) { + ) : QSTileViewImpl( + ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings), + icon, + collapsed + ) { fun changeState(state: QSTile.State) { handleStateChanged(state) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt index f0e4e3adda7c7..77a4436664427 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DndTileTest.kt @@ -25,6 +25,7 @@ import android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS import android.provider.Settings.Global.ZEN_MODE_OFF import android.testing.AndroidTestingRunner import android.testing.TestableLooper +import android.view.ContextThemeWrapper import android.view.View import androidx.test.filters.SmallTest import com.android.internal.logging.MetricsLogger @@ -110,7 +111,9 @@ class DndTileTest : SysuiTestCase() { whenever(qsHost.userId).thenReturn(DEFAULT_USER) - val wrappedContext = object : ContextWrapper(context) { + val wrappedContext = object : ContextWrapper( + ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings) + ) { override fun getSharedPreferences(file: File?, mode: Int): SharedPreferences { return sharedPreferences } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierTest.java index 44613103a5b24..dae9c975b9976 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierTest.java @@ -20,8 +20,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import android.content.Context; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; @@ -48,7 +50,9 @@ public class ShadeCarrierTest extends SysuiTestCase { @Before public void setUp() throws Exception { mTestableLooper = TestableLooper.get(this); - LayoutInflater inflater = LayoutInflater.from(mContext); + Context themedContext = + new ContextThemeWrapper(mContext, R.style.Theme_SystemUI_QuickSettings); + LayoutInflater inflater = LayoutInflater.from(themedContext); mContext.ensureTestableResources(); mTestableLooper.runWithLooper(() -> mShadeCarrier = (ShadeCarrier) inflater.inflate(R.layout.shade_carrier, null));