Migrate to new color tokens
This includes: * Quick Setting tiles * QS Customizer * Security footer and dialog * Fgs footer * Footer actions * Brightness slider Test: manual, open QS Test: atest SystemUITests Fixes: 276932747 Change-Id: I8d9b77c94aa7bc5d010bda6fbfde879467767bf3
This commit is contained in:
@@ -121,8 +121,8 @@ fun FooterActions(
|
||||
}
|
||||
}
|
||||
|
||||
val backgroundColor = colorAttr(R.attr.underSurfaceColor)
|
||||
val contentColor = LocalAndroidColorScheme.current.deprecated.textColorPrimary
|
||||
val backgroundColor = colorAttr(R.attr.underSurface)
|
||||
val contentColor = LocalAndroidColorScheme.current.onSurface
|
||||
val backgroundTopRadius = dimensionResource(R.dimen.qs_corner_radius)
|
||||
val backgroundModifier =
|
||||
remember(
|
||||
@@ -268,7 +268,7 @@ private fun NumberButton(
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
|
||||
Expandable(
|
||||
color = colorAttr(R.attr.offStateColor),
|
||||
color = colorAttr(R.attr.shadeInactive),
|
||||
shape = CircleShape,
|
||||
onClick = onClick,
|
||||
interactionSource = interactionSource,
|
||||
@@ -287,7 +287,7 @@ private fun NumberButton(
|
||||
number.toString(),
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = LocalAndroidColorScheme.current.deprecated.textColorPrimary,
|
||||
color = colorAttr(R.attr.onShadeInactiveVariant),
|
||||
// TODO(b/242040009): This should only use a standard text style instead and
|
||||
// should not override the text size.
|
||||
fontSize = 18.sp,
|
||||
@@ -305,7 +305,7 @@ private fun NumberButton(
|
||||
@Composable
|
||||
private fun NewChangesDot(modifier: Modifier = Modifier) {
|
||||
val contentDescription = stringResource(R.string.fgs_dot_content_description)
|
||||
val color = LocalAndroidColorScheme.current.deprecated.colorAccentTertiary
|
||||
val color = LocalAndroidColorScheme.current.tertiary
|
||||
|
||||
Canvas(modifier.size(12.dp).semantics { this.contentDescription = contentDescription }) {
|
||||
drawCircle(color)
|
||||
@@ -323,10 +323,9 @@ private fun TextButton(
|
||||
) {
|
||||
Expandable(
|
||||
shape = CircleShape,
|
||||
color = colorAttr(R.attr.underSurfaceColor),
|
||||
contentColor = LocalAndroidColorScheme.current.deprecated.textColorSecondary,
|
||||
borderStroke =
|
||||
BorderStroke(1.dp, LocalAndroidColorScheme.current.deprecated.colorBackground),
|
||||
color = colorAttr(R.attr.underSurface),
|
||||
contentColor = LocalAndroidColorScheme.current.onSurfaceVariant,
|
||||
borderStroke = BorderStroke(1.dp, colorAttr(R.attr.onShadeActive)),
|
||||
modifier = modifier.padding(horizontal = 4.dp),
|
||||
onClick = onClick,
|
||||
) {
|
||||
|
||||
19
packages/SystemUI/res-keyguard/color/shade_disabled.xml
Normal file
19
packages/SystemUI/res-keyguard/color/shade_disabled.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2023 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@android:color/system_neutral1_500" android:lStar="4" />
|
||||
</selector>
|
||||
@@ -26,7 +26,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.QS.SecurityFooter"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColor="?attr/onShadeInactiveVariant"
|
||||
android:textSize="18sp"/>
|
||||
<ImageView
|
||||
android:id="@+id/new_dot"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
android:layout_marginEnd="12dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_info_outline"
|
||||
android:tint="?android:attr/textColorSecondary" />
|
||||
android:tint="?attr/onSurfaceVariant" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
@@ -43,7 +43,7 @@
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="@style/TextAppearance.QS.SecurityFooter"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
android:textColor="?attr/onSurfaceVariant"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/new_dot"
|
||||
@@ -62,5 +62,5 @@
|
||||
android:contentDescription="@null"
|
||||
android:src="@*android:drawable/ic_chevron_end"
|
||||
android:autoMirrored="true"
|
||||
android:tint="?android:attr/textColorSecondary" />
|
||||
android:tint="?attr/onSurfaceVariant" />
|
||||
</com.android.systemui.animation.view.LaunchableLinearLayout>
|
||||
@@ -15,6 +15,6 @@
|
||||
~ limitations under the License
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="?attr/underSurfaceColor" />
|
||||
<solid android:color="?attr/underSurface" />
|
||||
<corners android:radius="@dimen/rounded_slider_background_rounded_corner" />
|
||||
</shape>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<shape>
|
||||
<size android:height="@dimen/rounded_slider_track_width" />
|
||||
<corners android:radius="@dimen/rounded_slider_track_corner_radius" />
|
||||
<solid android:color="?attr/offStateColor" />
|
||||
<solid android:color="?attr/shadeInactive" />
|
||||
</shape>
|
||||
</inset>
|
||||
</item>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:height="@dimen/rounded_slider_height">
|
||||
<shape>
|
||||
<size android:height="@dimen/rounded_slider_height" />
|
||||
<solid android:color="?priv-android:attr/colorAccentPrimary" />
|
||||
<solid android:color="?attr/shadeActive" />
|
||||
<corners android:radius="@dimen/rounded_slider_corner_radius"/>
|
||||
</shape>
|
||||
</item>
|
||||
@@ -34,7 +34,7 @@
|
||||
android:right="@dimen/rounded_slider_icon_inset">
|
||||
<com.android.systemui.util.AlphaTintDrawableWrapper
|
||||
android:drawable="@drawable/ic_brightness"
|
||||
android:tint="?android:attr/textColorPrimaryInverse"
|
||||
android:tint="?attr/onShadeActive"
|
||||
/>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -19,5 +19,5 @@
|
||||
android:shape="oval"
|
||||
android:width="12dp"
|
||||
android:height="12dp">
|
||||
<solid android:color="?androidprv:attr/colorAccentTertiary" />
|
||||
<solid android:color="?attr/tertiary" />
|
||||
</shape>
|
||||
@@ -15,7 +15,7 @@
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shape>
|
||||
<solid android:color="?attr/underSurfaceColor"/>
|
||||
<solid android:color="?attr/underSurface"/>
|
||||
<corners android:radius="?android:attr/dialogCornerRadius" />
|
||||
</shape>
|
||||
</inset>
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shape>
|
||||
<solid android:color="?attr/underSurfaceColor"/>
|
||||
<solid android:color="?attr/underSurface"/>
|
||||
</shape>
|
||||
</inset>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?attr/offStateColor"/>
|
||||
<solid android:color="?attr/shadeInactive"/>
|
||||
<corners android:radius="@dimen/qs_footer_action_corner_radius"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="?android:attr/colorAccent"/>
|
||||
<solid android:color="?attr/shadeActive"/>
|
||||
<corners android:radius="@dimen/qs_footer_action_corner_radius"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shape>
|
||||
<solid android:color="?attr/underSurfaceColor"/>
|
||||
<solid android:color="?attr/underSurface"/>
|
||||
<corners android:topLeftRadius="@dimen/qs_corner_radius"
|
||||
android:topRightRadius="@dimen/qs_corner_radius"/>
|
||||
</shape>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<stroke android:width="1dp"
|
||||
android:color="?android:attr/colorBackground"/>
|
||||
android:color="?attr/shadeInactive"/>
|
||||
<corners android:radius="@dimen/qs_security_footer_corner_radius"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:tint="?attr/shadeActive"
|
||||
android:visibility="gone" />
|
||||
|
||||
<FrameLayout
|
||||
@@ -70,7 +71,7 @@
|
||||
android:focusable="true"
|
||||
android:padding="@dimen/qs_footer_icon_padding"
|
||||
android:src="@*android:drawable/ic_mode_edit"
|
||||
android:tint="?android:attr/textColorPrimary" />
|
||||
android:tint="?attr/onSurfaceVariant" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -54,6 +54,6 @@
|
||||
android:focusable="false"
|
||||
android:importantForAccessibility="no"
|
||||
android:textAppearance="@style/TextAppearance.QS.TileLabel.Secondary"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
android:textColor="?attr/onShadeInactive"/>
|
||||
|
||||
</com.android.systemui.qs.tileimpl.IgnorableChildLinearLayout>
|
||||
|
||||
@@ -118,8 +118,25 @@
|
||||
<attr name="wallpaperTextColorSecondary" format="reference|color" />
|
||||
<attr name="wallpaperTextColorAccent" format="reference|color" />
|
||||
<attr name="backgroundProtectedStyle" format="reference" />
|
||||
<attr name="offStateColor" format="reference|color" />
|
||||
<attr name="underSurfaceColor" format="reference|color" />
|
||||
|
||||
<!-- color attribute tokens for QS -->
|
||||
<attr name="isQsTheme" format="boolean" />
|
||||
<attr name="underSurface" format="reference|color"/>
|
||||
<attr name="shadeActive" format="reference|color" />
|
||||
<attr name="onShadeActive" format="reference|color" />
|
||||
<attr name="onShadeActiveVariant" format="reference|color" />
|
||||
<attr name="shadeInactive" format="reference|color" />
|
||||
<attr name="onShadeInactive" format="reference|color" />
|
||||
<attr name="onShadeInactiveVariant" format="reference|color" />
|
||||
<attr name="shadeDisabled" format="reference|color" />
|
||||
<attr name="surfaceBright" format="reference|color" />
|
||||
<attr name="scHigh" format="reference|color" />
|
||||
<attr name="tertiary" format="reference|color" />
|
||||
<attr name="onSurface" format="reference|color" />
|
||||
<attr name="onSurfaceVariant" format="reference|color" />
|
||||
<attr name="outline" format="reference|color" />
|
||||
<attr name="primary" format="reference|color" />
|
||||
|
||||
|
||||
<declare-styleable name="SmartReplyView">
|
||||
<attr name="spacing" format="dimension" />
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
<style name="TextAppearance.QS">
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:textColor">?attr/onShadeInactive</item>
|
||||
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
|
||||
</style>
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
|
||||
<style name="TextAppearance.QS.DetailItemSecondary">
|
||||
<item name="android:textSize">@dimen/qs_tile_text_size</item>
|
||||
<item name="android:textColor">?android:attr/colorAccent</item>
|
||||
<item name="android:textColor">?attr/shadeActive</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.Introduction">
|
||||
@@ -117,11 +117,11 @@
|
||||
|
||||
<style name="TextAppearance.QS.DataUsage.Usage">
|
||||
<item name="android:textSize">@dimen/qs_data_usage_usage_text_size</item>
|
||||
<item name="android:textColor">?android:attr/colorAccent</item>
|
||||
<item name="android:textColor">?attr/shadeActive</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.DataUsage.Secondary">
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textColor">?attr/onShadeInactiveVariant</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.TileLabel">
|
||||
@@ -137,31 +137,31 @@
|
||||
|
||||
<style name="TextAppearance.QS.UserSwitcher">
|
||||
<item name="android:textSize">@dimen/qs_tile_text_size</item>
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textColor">?androidprv:attr/materialColorOnSurfaceVariant</item>
|
||||
</style>
|
||||
|
||||
<!-- This is hard coded to be sans-serif-condensed to match the icons -->
|
||||
|
||||
<style name="TextAppearance.QS.Status">
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:textColor">?attr/onSurface</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:letterSpacing">0.01</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.SecurityFooter" parent="@style/TextAppearance.QS.Status">
|
||||
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textColor">?attr/onSurface</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.Status.Carriers" />
|
||||
|
||||
<style name="TextAppearance.QS.Status.Carriers.NoCarrierText">
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textColor">?attr/onSurfaceVariant</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.QS.Status.Build">
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textColor">?attr/onSurfaceVariant</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.DeviceManagementDialog.Title" parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle"/>
|
||||
@@ -278,10 +278,10 @@
|
||||
|
||||
<style name="DeviceManagementDialogTitle">
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:textAppearance">@style/TextAppearance.DeviceManagementDialog.Title</item>
|
||||
<item name="android:textAppearance">@style/TextAppearance.Dialog.Title</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.DeviceManagementDialog.Content" parent="@*android:style/TextAppearance.DeviceDefault.Subhead"/>
|
||||
<style name="TextAppearance.DeviceManagementDialog.Content" parent="@style/TextAppearance.Dialog.Body.Message"/>
|
||||
|
||||
<style name="BaseBrightnessDialogContainer" parent="@style/Theme.SystemUI">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
@@ -371,14 +371,30 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.SystemUI.QuickSettings" parent="@*android:style/Theme.DeviceDefault">
|
||||
<item name="isQsTheme">true</item>
|
||||
<item name="lightIconTheme">@style/QSIconTheme</item>
|
||||
<item name="darkIconTheme">@style/QSIconTheme</item>
|
||||
<item name="android:colorError">@*android:color/error_color_material_dark</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
|
||||
<item name="offStateColor">@color/material_dynamic_neutral20</item>
|
||||
<item name="underSurfaceColor">@color/material_dynamic_neutral0</item>
|
||||
<item name="android:colorBackground">@color/material_dynamic_neutral10</item>
|
||||
|
||||
<item name="surfaceBright">?androidprv:attr/materialColorSurfaceBright</item>
|
||||
<item name="android:colorBackground">?attr/surfaceBright</item>
|
||||
<item name="scHigh">?androidprv:attr/materialColorSurfaceContainerHigh</item>
|
||||
<item name="primary">?androidprv:attr/materialColorPrimary</item>
|
||||
<item name="tertiary">?androidprv:attr/materialColorTertiary</item>
|
||||
<item name="onSurface">?androidprv:attr/materialColorOnSurface</item>
|
||||
<item name="onSurfaceVariant">?androidprv:attr/materialColorOnSurfaceVariant</item>
|
||||
<item name="outline">?androidprv:attr/materialColorOutline</item>
|
||||
|
||||
<item name="shadeActive">@color/material_dynamic_primary90</item>
|
||||
<item name="onShadeActive">@color/material_dynamic_primary10</item>
|
||||
<item name="onShadeActiveVariant">@color/material_dynamic_primary30</item>
|
||||
<item name="shadeInactive">@color/material_dynamic_neutral20</item>
|
||||
<item name="onShadeInactive">@color/material_dynamic_neutral90</item>
|
||||
<item name="onShadeInactiveVariant">@color/material_dynamic_neutral_variant80</item>
|
||||
<item name="shadeDisabled">@color/shade_disabled</item>
|
||||
<item name="underSurface">@color/material_dynamic_neutral0</item>
|
||||
<item name="android:itemTextAppearance">@style/Control.MenuItem</item>
|
||||
</style>
|
||||
|
||||
@@ -390,8 +406,15 @@
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.SystemUI.QuickSettings.Dialog" parent="@android:style/Theme.DeviceDefault.Dialog">
|
||||
<style name="Theme.SystemUI.QuickSettings.Dialog" parent="@style/Theme.SystemUI.Dialog.QuickSettings">
|
||||
</style>
|
||||
|
||||
<!-- Parent style overrides style in the dot inheritance -->
|
||||
<style name="Theme.SystemUI.Dialog.QuickSettings" parent="@style/Theme.SystemUI.QuickSettings">
|
||||
<item name="android:dialogCornerRadius">@dimen/notification_corner_radius</item>
|
||||
<item name="android:buttonBarPositiveButtonStyle">@style/Widget.Dialog.Button.QuickSettings</item>
|
||||
<item name="android:buttonBarNegativeButtonStyle">@style/Widget.Dialog.Button.QuickSettings</item>
|
||||
<item name="android:buttonBarNeutralButtonStyle">@style/Widget.Dialog.Button.QuickSettings</item>
|
||||
</style>
|
||||
|
||||
<!-- Overridden by values-television/styles.xml with tv-specific settings -->
|
||||
@@ -605,11 +628,11 @@
|
||||
<item name="android:letterSpacing">0.01</item>
|
||||
<item name="android:lineHeight">20sp</item>
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:textColor">?attr/onSurfaceVariant</item>
|
||||
</style>
|
||||
|
||||
<style name="QSCustomizeToolbar" parent="@*android:style/Widget.DeviceDefault.Toolbar">
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:textColor">?attr/onSurface</item>
|
||||
<item name="android:elevation">10dp</item>
|
||||
</style>
|
||||
|
||||
@@ -1111,6 +1134,11 @@
|
||||
<item name="android:textColor">?androidprv:attr/materialColorOnPrimaryFixed</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Dialog.Button.QuickSettings">
|
||||
<item name="android:textColor">?attr/primary</item>
|
||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||
</style>
|
||||
|
||||
<style name="MainSwitch.Settingslib" parent="@android:style/Theme.DeviceDefault">
|
||||
<item name="android:switchMinWidth">@dimen/settingslib_min_switch_width</item>
|
||||
</style>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user