Merge "Controls UI - Fix colors" into rvc-dev
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_enabled="false"
|
|
||||||
android:color="@color/control_default_background" />
|
|
||||||
<item android:color="@color/GM2_blue_200"
|
|
||||||
android:alpha="0.2" />
|
|
||||||
</selector>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_enabled="false"
|
|
||||||
android:color="@color/control_default_background" />
|
|
||||||
<item android:color="@color/GM2_yellow_200"
|
|
||||||
android:alpha="0.2" />
|
|
||||||
</selector>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_enabled="false"
|
|
||||||
android:color="@color/control_default_background" />
|
|
||||||
<item android:color="@color/GM2_blue_200"
|
|
||||||
android:alpha="0.2" />
|
|
||||||
</selector>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_enabled="false"
|
|
||||||
android:color="@color/control_default_background" />
|
|
||||||
<item android:color="@color/GM2_red_200"
|
|
||||||
android:alpha="0.2" />
|
|
||||||
</selector>
|
|
||||||
@@ -225,4 +225,8 @@
|
|||||||
<color name="control_default_background">@color/GM2_grey_900</color>
|
<color name="control_default_background">@color/GM2_grey_900</color>
|
||||||
<color name="control_list_popup_background">@*android:color/background_floating_material_dark</color>
|
<color name="control_list_popup_background">@*android:color/background_floating_material_dark</color>
|
||||||
<color name="control_spinner_dropdown">@*android:color/foreground_material_dark</color>
|
<color name="control_spinner_dropdown">@*android:color/foreground_material_dark</color>
|
||||||
|
<color name="control_enabled_light_background">@color/GM2_yellow_200</color>
|
||||||
|
<color name="control_enabled_thermo_heat_background">@color/GM2_red_200</color>
|
||||||
|
<color name="control_enabled_thermo_cool_background">@color/GM2_blue_200</color>
|
||||||
|
<color name="control_enabled_default_background">@color/GM2_blue_200</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
package com.android.systemui.controls.ui
|
package com.android.systemui.controls.ui
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.BlendMode
|
|
||||||
import android.graphics.drawable.ClipDrawable
|
import android.graphics.drawable.ClipDrawable
|
||||||
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.service.controls.Control
|
import android.service.controls.Control
|
||||||
import android.service.controls.actions.ControlAction
|
import android.service.controls.actions.ControlAction
|
||||||
@@ -39,6 +39,8 @@ import com.android.systemui.R
|
|||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
private const val UPDATE_DELAY_IN_MILLIS = 3000L
|
private const val UPDATE_DELAY_IN_MILLIS = 3000L
|
||||||
|
private const val ALPHA_ENABLED = (255.0 * 0.2).toInt()
|
||||||
|
private const val ALPHA_DISABLED = 255
|
||||||
|
|
||||||
class ControlViewHolder(
|
class ControlViewHolder(
|
||||||
val layout: ViewGroup,
|
val layout: ViewGroup,
|
||||||
@@ -144,16 +146,21 @@ class ControlViewHolder(
|
|||||||
val ri = RenderInfo.lookup(context, cws.componentName, deviceType, enabled, offset)
|
val ri = RenderInfo.lookup(context, cws.componentName, deviceType, enabled, offset)
|
||||||
|
|
||||||
val fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
|
val fg = context.getResources().getColorStateList(ri.foreground, context.getTheme())
|
||||||
val bg = context.getResources().getColorStateList(ri.background, context.getTheme())
|
val (bg, alpha) = if (enabled) {
|
||||||
|
Pair(ri.enabledBackground, ALPHA_ENABLED)
|
||||||
|
} else {
|
||||||
|
Pair(R.color.control_default_background, ALPHA_DISABLED)
|
||||||
|
}
|
||||||
|
|
||||||
status.setTextColor(fg)
|
status.setTextColor(fg)
|
||||||
statusExtra.setTextColor(fg)
|
statusExtra.setTextColor(fg)
|
||||||
|
|
||||||
icon.setImageDrawable(ri.icon)
|
icon.setImageDrawable(ri.icon)
|
||||||
icon.setImageTintList(fg)
|
icon.setImageTintList(fg)
|
||||||
|
|
||||||
clipLayer.getDrawable().apply {
|
(clipLayer.getDrawable() as GradientDrawable).apply {
|
||||||
setTintBlendMode(BlendMode.HUE)
|
setColor(context.getResources().getColor(bg, context.getTheme()))
|
||||||
setTintList(bg)
|
setAlpha(alpha)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.controls.ui
|
package com.android.systemui.controls.ui
|
||||||
|
|
||||||
|
import android.annotation.ColorRes
|
||||||
import android.annotation.MainThread
|
import android.annotation.MainThread
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -37,8 +38,11 @@ data class IconState(val disabledResourceId: Int, val enabledResourceId: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class RenderInfo(val icon: Drawable, val foreground: Int, val background: Int) {
|
data class RenderInfo(
|
||||||
|
val icon: Drawable,
|
||||||
|
val foreground: Int,
|
||||||
|
@ColorRes val enabledBackground: Int
|
||||||
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
const val APP_ICON_ID = -1
|
const val APP_ICON_ID = -1
|
||||||
private val iconMap = SparseArray<Drawable>()
|
private val iconMap = SparseArray<Drawable>()
|
||||||
@@ -72,6 +76,7 @@ data class RenderInfo(val icon: Drawable, val foreground: Int, val background: I
|
|||||||
icon = iconMap.get(resourceId)
|
icon = iconMap.get(resourceId)
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
icon = context.resources.getDrawable(resourceId, null)
|
icon = context.resources.getDrawable(resourceId, null)
|
||||||
|
icon.mutate()
|
||||||
iconMap.put(resourceId, icon)
|
iconMap.put(resourceId, icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,12 +99,13 @@ private const val THERMOSTAT_RANGE = DeviceTypes.TYPE_THERMOSTAT * BUCKET_SIZE
|
|||||||
|
|
||||||
private val deviceColorMap = mapOf<Int, Pair<Int, Int>>(
|
private val deviceColorMap = mapOf<Int, Pair<Int, Int>>(
|
||||||
(THERMOSTAT_RANGE + TemperatureControlTemplate.MODE_HEAT) to
|
(THERMOSTAT_RANGE + TemperatureControlTemplate.MODE_HEAT) to
|
||||||
Pair(R.color.thermo_heat_foreground, R.color.thermo_heat_background),
|
Pair(R.color.thermo_heat_foreground, R.color.control_enabled_thermo_heat_background),
|
||||||
(THERMOSTAT_RANGE + TemperatureControlTemplate.MODE_COOL) to
|
(THERMOSTAT_RANGE + TemperatureControlTemplate.MODE_COOL) to
|
||||||
Pair(R.color.thermo_cool_foreground, R.color.thermo_cool_background),
|
Pair(R.color.thermo_cool_foreground, R.color.control_enabled_thermo_cool_background),
|
||||||
DeviceTypes.TYPE_LIGHT to Pair(R.color.light_foreground, R.color.light_background)
|
DeviceTypes.TYPE_LIGHT
|
||||||
|
to Pair(R.color.light_foreground, R.color.control_enabled_light_background)
|
||||||
).withDefault {
|
).withDefault {
|
||||||
Pair(R.color.control_foreground, R.color.control_background)
|
Pair(R.color.control_foreground, R.color.control_enabled_default_background)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val deviceIconMap = mapOf<Int, IconState>(
|
private val deviceIconMap = mapOf<Int, IconState>(
|
||||||
|
|||||||
Reference in New Issue
Block a user