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: the theme follows the choice and the phone (status bar icons, window background, Material You)

Claude12b5f815b257
diff --git a/android/app/src/main/kotlin/com/coucou/android/MainActivity.kt b/android/app/src/main/kotlin/com/coucou/android/MainActivity.kt
index 1996f6e8..ddb948c2 100644
--- a/android/app/src/main/kotlin/com/coucou/android/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/MainActivity.kt
@@ -150,9 +150,14 @@ class MainActivity : ComponentActivity() {
}
model.resume()
setContent {
- CoucouTheme {
- // The app is dark only: the status bar icons are always light.
- SideEffect { WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = false }
+ CoucouTheme(model.settings.theme, model.settings.dynamicColour) {
+ // Dark icons on a light page; the camera screen is black in both themes, so its icons are light.
+ val lightPage = !tokens().isDark && screen != Screen.SCAN
+ SideEffect {
+ val bars = WindowCompat.getInsetsController(window, window.decorView)
+ bars.isAppearanceLightStatusBars = lightPage
+ bars.isAppearanceLightNavigationBars = lightPage
+ }
Surface(Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
Box(Modifier.fillMaxSize().windowInsetsPadding(if (screen == Screen.HOME || screen == Screen.SCAN) WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom) else WindowInsets.safeDrawing)) {
val tabs = Nav.tabs()
diff --git a/android/app/src/main/kotlin/com/coucou/android/ui/Theme.kt b/android/app/src/main/kotlin/com/coucou/android/ui/Theme.kt
index 9cb71837..1e7d73e3 100644
--- a/android/app/src/main/kotlin/com/coucou/android/ui/Theme.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/ui/Theme.kt
@@ -1,27 +1,37 @@
package com.coucou.android.ui
+import android.os.Build
+import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.material3.dynamicLightColorScheme
+import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.toArgb
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.coucou.android.core.Palette
import com.coucou.android.core.StatusPalette
+import com.coucou.android.core.ThemeChoice
+import com.coucou.android.core.ThemePolicy
import com.coucou.android.core.Tokens
/**
- * The look of the Coucou website (docs/site.css): near-black page, slightly lighter cards with a thin
- * border, soft blue accent, rounded corners and pill-shaped buttons. Mochi itself is untouched.
+ * The look of the Coucou website (docs/site.css): a near-black page (or a pale one in the light theme), slightly lighter cards with a
+ * thin border, soft blue accent, rounded corners and pill-shaped buttons. Mochi itself is untouched.
*/
private fun scheme(p: Palette, t: Tokens): ColorScheme {
// Surfaces and text come from the tokens, the accent from Palette.
- return darkColorScheme().copy(
+ val base = if (t.isDark) darkColorScheme() else lightColorScheme()
+ return base.copy(
background = Color(t.bg), surface = Color(t.bg),
surfaceVariant = Color(t.panel), surfaceContainer = Color(t.panel),
onBackground = Color(t.text), onSurface = Color(t.text), onSurfaceVariant = Color(t.textDim),
@@ -30,7 +40,19 @@ private fun scheme(p: Palette, t: Tokens): ColorScheme {
)
}
-private val Dark = scheme(Palette.DARK, Tokens.DARK)
+private fun Color.argb(): Long = toArgb().toLong() and 0xFFFFFFFFL
+
+/** The tokens of the phone's own colours (Material You): surfaces, text and buttons from [cs]; the state and link colours stay ours. */
+private fun fromDynamic(base: Tokens, cs: ColorScheme) = base.copy(
+ bg = cs.surface.argb(), panel = cs.surfaceContainer.argb(), panel2 = cs.surfaceContainerHigh.argb(), line = cs.outlineVariant.argb(),
+ text = cs.onSurface.argb(), textDim = cs.onSurfaceVariant.argb(), textFaint = cs.outline.argb(),
+ primaryButton = cs.primary.argb(), onPrimaryButton = cs.onPrimary.argb(), secondaryButton = cs.secondaryContainer.argb(),
+ danger = cs.error.argb(),
+ hero = cs.surfaceContainerHigh.argb(), sheet = cs.surfaceContainerHigh.argb(),
+ heroText = cs.onSurface.argb(), heroTextDim = cs.onSurfaceVariant.argb(),
+ heroPrimary = cs.primary.argb(), heroOnPrimary = cs.onPrimary.argb(), heroButton = cs.secondaryContainer.argb(),
+ heroLine = cs.outlineVariant.argb(),
+)
/** Link status colours (the dot next to "Connected"). */
object StatusColors {
@@ -39,10 +61,23 @@ object StatusColors {
val offline = Color(StatusPalette.OFFLINE)
}
+/**
+ * The theme: light, dark or the phone's own ([theme]), and optionally the phone's own colours ([dynamic], Android 12 and later).
+ * Mochi, his colours and the state colours are the same in both.
+ */
@Composable
-fun CoucouTheme(content: @Composable () -> Unit) {
- CompositionLocalProvider(LocalTokens provides Tokens.DARK) {
- MaterialTheme(colorScheme = Dark, content = content)
+fun CoucouTheme(theme: ThemeChoice = ThemeChoice.SYSTEM, dynamic: Boolean = false, content: @Composable () -> Unit) {
+ val dark = ThemePolicy.dark(theme, isSystemInDarkTheme())
+ val context = LocalContext.current
+ var tokens = if (dark) Tokens.DARK else Tokens.LIGHT
+ var colours = scheme(if (dark) Palette.DARK else Palette.LIGHT, tokens)
+ if (dynamic && ThemePolicy.dynamicAvailable(Build.VERSION.SDK_INT)) {
+ val cs = if (dark) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ tokens = fromDynamic(tokens, cs)
+ colours = cs
+ }
+ CompositionLocalProvider(LocalTokens provides tokens) {
+ MaterialTheme(colorScheme = colours, content = content)
}
}
diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml
index 262aec0a..bde5ba49 100644
--- a/android/app/src/main/res/values/themes.xml
+++ b/android/app/src/main/res/values/themes.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <!-- Dark only (the UI itself is Compose). -->
- <style name="Theme.Coucou" parent="android:Theme.DeviceDefault">
+ <!-- Light or dark with the phone until Compose draws (the UI itself is Compose, with its own Theme setting). -->
+ <style name="Theme.Coucou" parent="android:Theme.DeviceDefault.DayNight">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>