summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author James O'Leary <jamesoleary@google.com> 2022-05-26 19:31:19 +0000
committer James O'Leary <jamesoleary@google.com> 2022-05-26 19:52:52 +0000
commitc4e3d76a03ebaf2d9b5c0a0f24547cef63c2d1e5 (patch)
tree8f7c6a60c50357e15ccc8927dc8225fd71f8ede9
parent49fa723e9ca14de06a1789577c9e4f113365133d (diff)
Update ColorScheme.toString() formatting
ThemeOverlayController's is being used by designers for verification. To make that easier, the dumpsys now includes HCT coordinates, hex codes w/o alpha channel, and the seed color, which ColorScheme now stores in an instance variable. Test: adb shell dumpsys activity service com.android.systemui/.SystemUIService ThemeOverlayController; verify format works as intended. Shared with design, got feedback and confirmation this includes all needed info. Change-Id: I058d390b109a27e2277a2a74c1519c7b15a49400
-rw-r--r--packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt31
1 files changed, 23 insertions, 8 deletions
diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt
index 9df65e3417f5..beba0ee61dfe 100644
--- a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt
+++ b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt
@@ -21,6 +21,7 @@ import android.app.WallpaperColors
import android.graphics.Color
import com.android.internal.graphics.ColorUtils
import com.android.internal.graphics.cam.Cam
+import com.android.internal.graphics.cam.CamUtils
import kotlin.math.absoluteValue
import kotlin.math.roundToInt
@@ -207,7 +208,7 @@ enum class Style(internal val coreSpec: CoreSpec) {
}
class ColorScheme(
- @ColorInt seed: Int,
+ @ColorInt val seed: Int,
val darkTheme: Boolean,
val style: Style = Style.TONAL_SPOT
) {
@@ -271,12 +272,14 @@ class ColorScheme(
override fun toString(): String {
return "ColorScheme {\n" +
- " neutral1: ${humanReadable(neutral1)}\n" +
- " neutral2: ${humanReadable(neutral2)}\n" +
- " accent1: ${humanReadable(accent1)}\n" +
- " accent2: ${humanReadable(accent2)}\n" +
- " accent3: ${humanReadable(accent3)}\n" +
+ " seed color: ${stringForColor(seed)}\n" +
" style: $style\n" +
+ " palettes: \n" +
+ " ${humanReadable("PRIMARY", accent1)}\n" +
+ " ${humanReadable("SECONDARY", accent2)}\n" +
+ " ${humanReadable("TERTIARY", accent3)}\n" +
+ " ${humanReadable("NEUTRAL", neutral1)}\n" +
+ " ${humanReadable("NEUTRAL VARIANT", neutral2)}\n" +
"}"
}
@@ -426,8 +429,20 @@ class ColorScheme(
return 180f - ((a - b).absoluteValue - 180f).absoluteValue
}
- private fun humanReadable(colors: List<Int>): String {
- return colors.joinToString { "#" + Integer.toHexString(it) }
+ private fun stringForColor(color: Int): String {
+ val width = 4
+ val hct = Cam.fromInt(color)
+ val h = "H${hct.hue.roundToInt().toString().padEnd(width)}"
+ val c = "C${hct.chroma.roundToInt().toString().padEnd(width)}"
+ val t = "T${CamUtils.lstarFromInt(color).roundToInt().toString().padEnd(width)}"
+ val hex = Integer.toHexString(color).replaceRange(0, 2, "").uppercase()
+ return "$h$c$t = #$hex"
+ }
+
+ private fun humanReadable(paletteName: String, colors: List<Int>): String {
+ return "$paletteName\n" + colors.map {
+ stringForColor(it)
+ }.joinToString(separator = "\n") { it }
}
private fun score(cam: Cam, proportion: Double): Double {