diff options
| author | 2020-04-23 23:30:52 +0000 | |
|---|---|---|
| committer | 2020-04-23 23:30:52 +0000 | |
| commit | 3d85095816bf4f2389a0d2a1b8639a1622bffd03 (patch) | |
| tree | 82915ae3be53a81ea78becdba8d2a73c7fc72fab | |
| parent | 598593c1045cefd99fdad1f84a7367b28790ee42 (diff) | |
| parent | 4f5cd67ba6fbecc3121b31a021eb0cde289b95d1 (diff) | |
Merge "Controls UI - Support custom colors/icons" into rvc-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt index 61a323d0b9a8..6fd37caff3f4 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt @@ -186,22 +186,36 @@ class ControlViewHolder( val fg = context.resources.getColorStateList(ri.foreground, context.theme) val bg = context.resources.getColor(R.color.control_default_background, context.theme) val dimAlpha = if (dimmed) dimmedAlpha else 1f - var (clip, newAlpha) = if (enabled) { - listOf(ri.enabledBackground, ALPHA_ENABLED) + var (newClipColor, newAlpha) = if (enabled) { + // allow color overrides for the enabled state only + val color = cws.control?.getCustomColor()?.let { + val state = intArrayOf(android.R.attr.state_enabled) + it.getColorForState(state, it.getDefaultColor()) + } ?: context.resources.getColor(ri.enabledBackground, context.theme) + listOf(color, ALPHA_ENABLED) } else { - listOf(R.color.control_default_background, ALPHA_DISABLED) + listOf( + context.resources.getColor(R.color.control_default_background, context.theme), + ALPHA_DISABLED + ) } status.setTextColor(fg) - icon.setImageDrawable(ri.icon) - // do not color app icons - if (deviceType != DeviceTypes.TYPE_ROUTINE) { - icon.imageTintList = fg + cws.control?.getCustomIcon()?.let { + // do not tint custom icons, assume the intended icon color is correct + icon.imageTintList = null + icon.setImageIcon(it) + } ?: run { + icon.setImageDrawable(ri.icon) + + // do not color app icons + if (deviceType != DeviceTypes.TYPE_ROUTINE) { + icon.imageTintList = fg + } } (clipLayer.getDrawable() as GradientDrawable).apply { - val newClipColor = context.resources.getColor(clip, context.theme) val newBaseColor = if (behavior is ToggleRangeBehavior) { ColorUtils.blendARGB(bg, newClipColor, toggleBackgroundIntensity) } else { |