Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ffbcab4 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Applying dynamic material colors to backlight indicator

Bug: 270374251
Test: screenshots test coming as soon as visd is finalized
Change-Id: I3b28b94fe2086311606292c04de3c6616d01eb55
parent f6adbe0d
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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>
+0 −5
Original line number Diff line number Diff line
@@ -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>

+17 −7
Original line number Diff line number Diff line
@@ -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