Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Look: a light set of tokens and palette, the theme choice and the dynamic-colour switch in the settings model

Claudee005bad05603
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/Palette.kt b/android/app/src/main/kotlin/com/coucou/android/core/Palette.kt
index 9dca1de5..3a81412c 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/Palette.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/Palette.kt
@@ -4,7 +4,7 @@ import kotlin.math.pow
/**
* The app's colours as plain 0xAARRGGBB numbers, so a test can check that text stays readable on
- * its background (Theme.kt turns them into Compose colours). The app is dark only.
+ * its background (Theme.kt turns them into Compose colours). There is a dark and a light set.
*/
data class Palette(
val background: Long, val card: Long, val line: Long,
@@ -16,6 +16,12 @@ data class Palette(
text = 0xFFF3F4F6, textDim = 0xFFA1A6B0, accent = 0xFF8AB4FF, onAccent = 0xFF0E0F12, error = 0xFFFF8A80,
)
+ /** The light set: the same roles on a pale page. */
+ val LIGHT = Palette(
+ background = 0xFFF4F5F7, card = 0xFFFFFFFF, line = 0xFFD8DBE0,
+ text = 0xFF14161A, textDim = 0xFF575D67, accent = 0xFF1A5FD0, onAccent = 0xFFFFFFFF, error = 0xFFB3261E,
+ )
+
private fun lin(c: Int): Double {
val v = c / 255.0
return if (v <= 0.03928) v / 12.92 else ((v + 0.055) / 1.055).pow(2.4)
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/ThemeChoice.kt b/android/app/src/main/kotlin/com/coucou/android/core/ThemeChoice.kt
new file mode 100644
index 00000000..5d7eece9
--- /dev/null
+++ b/android/app/src/main/kotlin/com/coucou/android/core/ThemeChoice.kt
@@ -0,0 +1,25 @@
+package com.coucou.android.core
+
+/** Settings > Theme: follow the phone (the default), or always light, or always dark. */
+enum class ThemeChoice(val key: String) {
+ SYSTEM("system"), LIGHT("light"), DARK("dark");
+
+ companion object {
+ /** An unknown or missing key follows the system. */
+ fun parse(key: String?): ThemeChoice = values().firstOrNull { it.key == key } ?: SYSTEM
+ }
+}
+
+object ThemePolicy {
+ /** Whether the dark set is in force, given the choice and whether the phone is in dark mode. */
+ fun dark(choice: ThemeChoice, systemDark: Boolean): Boolean = when (choice) {
+ ThemeChoice.LIGHT -> false
+ ThemeChoice.DARK -> true
+ ThemeChoice.SYSTEM -> systemDark
+ }
+
+ fun tokens(choice: ThemeChoice, systemDark: Boolean): Tokens = if (dark(choice, systemDark)) Tokens.DARK else Tokens.LIGHT
+
+ /** The Material You colours need Android 12 (API 31); before that the switch has nothing to follow. */
+ fun dynamicAvailable(sdk: Int): Boolean = sdk >= 31
+}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/Tokens.kt b/android/app/src/main/kotlin/com/coucou/android/core/Tokens.kt
index bdd0c04d..7a2bdb00 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/Tokens.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/Tokens.kt
@@ -1,7 +1,8 @@
package com.coucou.android.core
/**
- * The design tokens as plain numbers, so a test can check contrast and the scale without Compose. The app is dark only.
+ * The design tokens as plain numbers, so a test can check contrast and the scale without Compose. There are two sets, dark and light
+ * (Settings > Theme); the island over other apps and the camera screen are always dark.
*
* Louis Raillé's Mochi, its state colours and the pill colours are not here and are not changed.
*/
@@ -27,6 +28,20 @@ data class Tokens(
val online: Long,
/** Alpha of the coloured glow at the bottom of a panel (0..1). */
val washAlpha: Double,
+ /** True for the dark set (status bar icons, the Material colour scheme and the dim of a scrim follow it). */
+ val isDark: Boolean = true,
+ /**
+ * The hero panel on Home and the sheets (request, question, file changes): the island grown to full width. Black in the dark set,
+ * a light card in the light one; the island itself always provides the dark set, so the same code draws both.
+ */
+ val hero: Long = 0xFF0E0F12, val sheet: Long = 0xFF141518,
+ val heroText: Long = 0xFFF5F6F8, val heroTextDim: Long = 0xFF9398A1,
+ /** The main pill on a hero surface and its label; every other pill on it. */
+ val heroPrimary: Long = 0xFFF5F6F8, val heroOnPrimary: Long = 0xFF0B0C0E, val heroButton: Long = 0xFF2A2B2E,
+ /** The thin edge of a hero panel or a sheet, and the faint fill of a row or a chip on it (alpha is part of the colour). */
+ val heroLine: Long = 0x0FFFFFFF, val heroFill: Long = 0x12FFFFFF,
+ /** The colours of an added and a removed line of a file change, readable on [sheet]. */
+ val diffAdded: Long = 0xFF34D399, val diffRemoved: Long = 0xFFFF8D97,
) {
companion object {
val DARK = Tokens(
@@ -35,6 +50,20 @@ data class Tokens(
primaryButton = 0xFFF5F6F8, onPrimaryButton = 0xFF0B0C0E, secondaryButton = 0xFF292A2D,
danger = 0xFFFF8D97, online = 0xFF34D399, washAlpha = 0.5,
)
+
+ /** The light set: a pale page, white cards, near-black text; every pair is checked for WCAG AA in TokensTest. */
+ val LIGHT = Tokens(
+ bg = 0xFFF4F5F7, panel = 0xFFFFFFFF, panel2 = 0xFFECEEF1, line = 0xFFD8DBE0,
+ text = 0xFF14161A, textDim = 0xFF575D67, textFaint = 0xFF6B717B,
+ primaryButton = 0xFF14161A, onPrimaryButton = 0xFFF5F6F8, secondaryButton = 0xFFE4E6EA,
+ danger = 0xFFB3261E, online = 0xFF0B8A5E, washAlpha = 0.28,
+ isDark = false,
+ hero = 0xFFFFFFFF, sheet = 0xFFFFFFFF,
+ heroText = 0xFF14161A, heroTextDim = 0xFF575D67,
+ heroPrimary = 0xFF14161A, heroOnPrimary = 0xFFF5F6F8, heroButton = 0xFFE4E6EA,
+ heroLine = 0xFFD8DBE0, heroFill = 0x14000000,
+ diffAdded = 0xFF0B7A55, diffRemoved = 0xFFB3261E,
+ )
}
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/UserSettings.kt b/android/app/src/main/kotlin/com/coucou/android/core/UserSettings.kt
index c289491c..d8aa17c7 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/UserSettings.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/UserSettings.kt
@@ -44,6 +44,10 @@ data class UserSettings(
val vibration: VibrationChoice = VibrationChoice.STANDARD,
/** Reduce motion: follow the system (default), always, or never. */
val motion: MotionChoice = MotionChoice.SYSTEM,
+ /** Light, dark or the phone's own. */
+ val theme: ThemeChoice = ThemeChoice.SYSTEM,
+ /** Use the phone's own colours (Material You, Android 12 and later) for the surfaces and text. Off by default. */
+ val dynamicColour: Boolean = false,
) {
companion object {
private const val SOUND = "sound_on"
@@ -57,6 +61,8 @@ data class UserSettings(
private const val NO_WAKE = "no_wake_screen"
private const val VIBRATION = "vibration_choice"
private const val MOTION = "motion_choice"
+ private const val THEME = "theme_choice"
+ private const val DYNAMIC = "dynamic_colour"
fun load(store: KeyValueStore): UserSettings {
val d = UserSettings()
@@ -74,6 +80,8 @@ data class UserSettings(
keepScreenOff = store.getBoolean(NO_WAKE, d.keepScreenOff),
vibration = VibrationChoice.parse(store.getString(VIBRATION, d.vibration.key)),
motion = MotionChoice.parse(store.getString(MOTION, d.motion.key)),
+ theme = ThemeChoice.parse(store.getString(THEME, d.theme.key)),
+ dynamicColour = store.getBoolean(DYNAMIC, d.dynamicColour),
)
}
@@ -89,6 +97,8 @@ data class UserSettings(
store.put(NO_WAKE, s.keepScreenOff)
store.put(VIBRATION, s.vibration.key)
store.put(MOTION, s.motion.key)
+ store.put(THEME, s.theme.key)
+ store.put(DYNAMIC, s.dynamicColour)
}
}
}
diff --git a/android/app/src/test/kotlin/com/coucou/android/PaletteTest.kt b/android/app/src/test/kotlin/com/coucou/android/PaletteTest.kt
index ac49ad10..a98bded2 100644
--- a/android/app/src/test/kotlin/com/coucou/android/PaletteTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/PaletteTest.kt
@@ -5,9 +5,9 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
-/** No dark text on a dark background: every text colour is readable on the surfaces it sits on (the app is dark only). */
+/** No dark text on a dark background, nor light text on a light one: every text colour is readable on the surfaces it sits on. */
class PaletteTest {
- private val themes = mapOf("dark" to Palette.DARK)
+ private val themes = mapOf("dark" to Palette.DARK, "light" to Palette.LIGHT)
@Test fun contrastMath() {
assertEquals(21.0, Palette.contrast(0xFF000000, 0xFFFFFFFF), 0.01)
diff --git a/android/app/src/test/kotlin/com/coucou/android/TokensTest.kt b/android/app/src/test/kotlin/com/coucou/android/TokensTest.kt
index f3d5f823..32c71ec5 100644
--- a/android/app/src/test/kotlin/com/coucou/android/TokensTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/TokensTest.kt
@@ -12,9 +12,9 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
-/** The redesign's tokens: readable text on every surface it sits on, on the dark theme, and a scale that holds together. */
+/** The redesign's tokens: readable text on every surface it sits on, in the dark and the light theme, and a scale that holds together. */
class TokensTest {
- private val themes = mapOf("dark" to Tokens.DARK)
+ private val themes = mapOf("dark" to Tokens.DARK, "light" to Tokens.LIGHT)
private fun c(a: Long, b: Long) = Palette.contrast(a, b)
@Test fun primaryTextIsReadableOnEverySurface() {