summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michal Brzezinski <brzezinski@google.com> 2023-04-24 17:31:47 +0100
committer Michal Brzezinski <brzezinski@google.com> 2023-04-26 14:33:19 +0100
commit8ffbcab4a8ddee91e3953d8ae7d376d0e74ba9ad (patch)
tree0bdfe22c7b56571096aa5c3d6457c260f6467958
parentf6adbe0d1fc89dbf5d0421007e06c4de71aa8a2b (diff)
Applying dynamic material colors to backlight indicator
Bug: 270374251 Test: screenshots test coming as soon as visd is finalized Change-Id: I3b28b94fe2086311606292c04de3c6616d01eb55
-rw-r--r--packages/SystemUI/res/drawable/ic_keyboard_backlight.xml12
-rw-r--r--packages/SystemUI/res/values/colors.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt24
3 files changed, 23 insertions, 18 deletions
diff --git a/packages/SystemUI/res/drawable/ic_keyboard_backlight.xml b/packages/SystemUI/res/drawable/ic_keyboard_backlight.xml
index d123caf82ed5..cff2839e6f88 100644
--- a/packages/SystemUI/res/drawable/ic_keyboard_backlight.xml
+++ b/packages/SystemUI/res/drawable/ic_keyboard_backlight.xml
@@ -2,11 +2,11 @@
android:viewportWidth="22" android:width="20.166666dp" xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<clip-path android:pathData="M0,0.5h22v11h-22z"/>
- <path android:fillColor="#231F20" android:pathData="M6.397,9.908H0V11.5H6.397V9.908Z"/>
- <path android:fillColor="#231F20" android:pathData="M14.199,9.908H7.801V11.5H14.199V9.908Z"/>
- <path android:fillColor="#231F20" android:pathData="M11.858,0.5H10.142V6.434H11.858V0.5Z"/>
- <path android:fillColor="#231F20" android:pathData="M8.348,7.129L3.885,2.975L3.823,2.932L2.668,4.003L2.621,4.046L7.084,8.2L7.146,8.243L8.301,7.172L8.348,7.129Z"/>
- <path android:fillColor="#231F20" android:pathData="M18.224,2.975L18.177,2.932L13.653,7.129L14.807,8.2L14.854,8.243L19.379,4.046L18.224,2.975Z"/>
- <path android:fillColor="#231F20" android:pathData="M22,9.908H15.603V11.5H22V9.908Z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M6.397,9.908H0V11.5H6.397V9.908Z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M14.199,9.908H7.801V11.5H14.199V9.908Z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M11.858,0.5H10.142V6.434H11.858V0.5Z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M8.348,7.129L3.885,2.975L3.823,2.932L2.668,4.003L2.621,4.046L7.084,8.2L7.146,8.243L8.301,7.172L8.348,7.129Z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M18.224,2.975L18.177,2.932L13.653,7.129L14.807,8.2L14.854,8.243L19.379,4.046L18.224,2.975Z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M22,9.908H15.603V11.5H22V9.908Z"/>
</group>
</vector>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index cb8c2a73c15d..db7eb7a049e7 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -207,11 +207,6 @@
<color name="controls_task_view_bg">#CC191C1D</color>
<color name="control_popup_dim">#8A000000</color>
- <!-- Keyboard backlight indicator-->
- <color name="backlight_indicator_step_filled">#F6E388</color>
- <color name="backlight_indicator_step_empty">#494740</color>
- <color name="backlight_indicator_background">#32302A</color>
-
<!-- Docked misalignment message -->
<color name="misalignment_text_color">#F28B82</color>
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt b/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt
index 2ef5e19bf382..65a951d2542f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt
@@ -17,6 +17,7 @@
package com.android.systemui.keyboard.backlight.ui.view
+import android.annotation.AttrRes
import android.annotation.ColorInt
import android.app.Dialog
import android.content.Context
@@ -31,6 +32,7 @@ import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.LinearLayout.LayoutParams
import android.widget.LinearLayout.LayoutParams.WRAP_CONTENT
+import com.android.settingslib.Utils
import com.android.systemui.R
import com.android.systemui.util.children
@@ -38,7 +40,7 @@ class KeyboardBacklightDialog(
context: Context,
initialCurrentLevel: Int,
initialMaxLevel: Int,
-) : Dialog(context) {
+) : Dialog(context, R.style.Theme_SystemUI_Dialog) {
private data class RootProperties(
val cornerRadius: Float,
@@ -69,9 +71,14 @@ class KeyboardBacklightDialog(
private lateinit var rootProperties: RootProperties
private lateinit var iconProperties: BacklightIconProperties
private lateinit var stepProperties: StepViewProperties
- @ColorInt var filledRectangleColor: Int = 0
- @ColorInt var emptyRectangleColor: Int = 0
- @ColorInt var backgroundColor: Int = 0
+ @ColorInt
+ var filledRectangleColor = getColorFromStyle(com.android.internal.R.attr.materialColorPrimary)
+ @ColorInt
+ var emptyRectangleColor =
+ getColorFromStyle(com.android.internal.R.attr.materialColorOutlineVariant)
+ @ColorInt
+ var backgroundColor = getColorFromStyle(com.android.internal.R.attr.materialColorSurfaceBright)
+ @ColorInt var iconColor = getColorFromStyle(com.android.internal.R.attr.materialColorOnPrimary)
init {
currentLevel = initialCurrentLevel
@@ -90,9 +97,6 @@ class KeyboardBacklightDialog(
private fun updateResources() {
context.resources.apply {
- filledRectangleColor = getColor(R.color.backlight_indicator_step_filled, context.theme)
- emptyRectangleColor = getColor(R.color.backlight_indicator_step_empty, context.theme)
- backgroundColor = getColor(R.color.backlight_indicator_background, context.theme)
rootProperties =
RootProperties(
cornerRadius =
@@ -126,6 +130,11 @@ class KeyboardBacklightDialog(
}
}
+ @ColorInt
+ fun getColorFromStyle(@AttrRes colorId: Int): Int {
+ return Utils.getColorAttrDefaultColor(context, colorId)
+ }
+
fun updateState(current: Int, max: Int, forceRefresh: Boolean = false) {
if (maxLevel != max || forceRefresh) {
maxLevel = max
@@ -214,6 +223,7 @@ class KeyboardBacklightDialog(
private fun createBacklightIconView(): ImageView {
return ImageView(context).apply {
setImageResource(R.drawable.ic_keyboard_backlight)
+ setColorFilter(iconColor)
layoutParams =
FrameLayout.LayoutParams(iconProperties.width, iconProperties.height).apply {
gravity = Gravity.CENTER