Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat: Add Appearance settings page and theme picker

Durganshu Mishra6c4fd176248c
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.kt
index d3bad59..2a7aa5f 100644
--- a/app/src/main/java/com/gotcha/MainActivity.kt
+++ b/app/src/main/java/com/gotcha/MainActivity.kt
@@ -50,6 +50,8 @@ import com.gotcha.ui.ConnectorsScreen
import com.gotcha.ui.SettingsPage
import com.gotcha.ui.SettingsScreen
import com.gotcha.ui.theme.GotchaTheme
+import com.gotcha.ui.theme.SkinBackdrop
+import com.gotcha.ui.theme.Skins
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -70,8 +72,23 @@ class MainActivity : ComponentActivity() {
/** Set when brought to front by the assistive ball (Operator-origin chats). */
private var openedFromBall by mutableStateOf(false)
- /** In-app theme override, applied immediately when changed in Settings. */
- private var themeMode by mutableStateOf(ThemeMode.SYSTEM)
+ /** Appearance, applied immediately when changed in Settings ▸ Appearance. */
+ private var appearance by mutableStateOf(Appearance())
+
+ /** The four settings that decide what the app looks like, and nothing else. */
+ private data class Appearance(
+ val themeMode: ThemeMode = ThemeMode.SYSTEM,
+ val skinId: String = Skins.DEFAULT_ID,
+ val matchSystemBrightness: Boolean = true,
+ val reduceTransparency: Boolean = false
+ )
+
+ private fun Settings.appearance() = Appearance(
+ themeMode = themeMode,
+ skinId = skinId,
+ matchSystemBrightness = matchSystemBrightness,
+ reduceTransparency = reduceTransparency
+ )
/** MediaProjection consent result — stores intent for screenshot capture. */
private val mediaProjectionLauncher =
@@ -162,19 +179,27 @@ class MainActivity : ComponentActivity() {
}
}
- themeMode = settingsRepository.load().themeMode
+ appearance = settingsRepository.load().appearance()
setContent {
- val darkTheme = when (themeMode) {
+ val darkTheme = when (appearance.themeMode) {
ThemeMode.LIGHT -> false
ThemeMode.DARK -> true
ThemeMode.SYSTEM -> isSystemInDarkTheme()
}
- GotchaTheme(darkTheme = darkTheme) {
+ GotchaTheme(
+ darkTheme = darkTheme,
+ skinId = appearance.skinId,
+ matchSystemBrightness = appearance.matchSystemBrightness,
+ reduceTransparency = appearance.reduceTransparency
+ ) {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
+ // The wallpaper sits under everything; an opaque skin draws
+ // nothing here and the Surface above remains the whole story.
+ SkinBackdrop(Modifier.fillMaxSize())
GotchaApp()
}
}
@@ -448,10 +473,7 @@ class MainActivity : ComponentActivity() {
}
},
onBack = { currentRoute = Route.HOME },
- onThemeChange = { mode ->
- themeMode = mode
- settingsRepository.save(settingsRepository.load().copy(themeMode = mode))
- },
+ onAppearanceChange = { updated -> appearance = updated.appearance() },
onRefreshAudioModels = { s ->
withContext(Dispatchers.IO) {
val ttsBase = s.effectiveTtsBaseUrl
diff --git a/app/src/main/java/com/gotcha/data/SettingsRepository.kt b/app/src/main/java/com/gotcha/data/SettingsRepository.kt
index 459ed99..6fa4763 100644
--- a/app/src/main/java/com/gotcha/data/SettingsRepository.kt
+++ b/app/src/main/java/com/gotcha/data/SettingsRepository.kt
@@ -61,6 +61,23 @@ data class Settings(
val notifyChimeEnabled: Boolean = false,
val assistiveBallEnabled: Boolean = false,
val themeMode: ThemeMode = ThemeMode.SYSTEM,
+ // ---- Appearance (Settings ▸ Appearance) ----
+ /**
+ * Which skin is painted. Stored as the id string rather than an enum so a
+ * build that drops a skin degrades to the default instead of throwing on a
+ * value it no longer knows.
+ */
+ val skinId: String = "deepspace",
+ /**
+ * Swap a paired skin (Aura ⇄ Vellum) for its twin when the device flips
+ * between light and dark, rather than keeping one of them in both.
+ */
+ val matchSystemBrightness: Boolean = true,
+ /**
+ * Solid panels, no wallpaper. Android has no system-level "reduce
+ * transparency", so this is the only way for someone to ask for one.
+ */
+ val reduceTransparency: Boolean = false,
val disabledSkills: Set<String> = emptySet(),
/**
* Ids of connectors the user switched off. Credentials survive (re-enabling
@@ -255,6 +272,9 @@ class SettingsRepository(context: Context) {
themeMode = runCatching {
ThemeMode.valueOf(string(KEY_THEME_MODE, "SYSTEM"))
}.getOrDefault(ThemeMode.SYSTEM),
+ skinId = string(KEY_SKIN_ID, "deepspace"),
+ matchSystemBrightness = prefs.getBoolean(KEY_MATCH_SYSTEM_BRIGHTNESS, true),
+ reduceTransparency = prefs.getBoolean(KEY_REDUCE_TRANSPARENCY, false),
disabledSkills = stringSet(KEY_DISABLED_SKILLS),
disabledConnectors = stringSet(KEY_DISABLED_CONNECTORS),
proactiveEnabled = prefs.getBoolean(KEY_PROACTIVE_ENABLED, true),
@@ -305,6 +325,9 @@ class SettingsRepository(context: Context) {
.putBoolean(KEY_NOTIFY_CHIME, settings.notifyChimeEnabled)
.putBoolean(KEY_ASSISTIVE_BALL, settings.assistiveBallEnabled)
.putString(KEY_THEME_MODE, settings.themeMode.name)
+ .putString(KEY_SKIN_ID, settings.skinId)
+ .putBoolean(KEY_MATCH_SYSTEM_BRIGHTNESS, settings.matchSystemBrightness)
+ .putBoolean(KEY_REDUCE_TRANSPARENCY, settings.reduceTransparency)
.putStringSet(KEY_DISABLED_SKILLS, settings.disabledSkills)
.putStringSet(KEY_DISABLED_CONNECTORS, settings.disabledConnectors)
.putBoolean(KEY_PROACTIVE_ENABLED, settings.proactiveEnabled)
@@ -371,6 +394,9 @@ class SettingsRepository(context: Context) {
const val KEY_NOTIFY_CHIME = "notify_chime"
const val KEY_ASSISTIVE_BALL = "assistive_ball_enabled"
const val KEY_THEME_MODE = "theme_mode"
+ const val KEY_SKIN_ID = "skin_id"
+ const val KEY_MATCH_SYSTEM_BRIGHTNESS = "match_system_brightness"
+ const val KEY_REDUCE_TRANSPARENCY = "reduce_transparency"
const val KEY_DISABLED_SKILLS = "disabled_skills"
const val KEY_DISABLED_CONNECTORS = "disabled_connectors"
const val KEY_PROACTIVE_ENABLED = "proactive_enabled"
diff --git a/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt b/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt
new file mode 100644
index 0000000..4abba47
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt
@@ -0,0 +1,287 @@
+package com.gotcha.ui
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.border
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.RowScope
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.selection.selectable
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.SegmentedButton
+import androidx.compose.material3.SegmentedButtonDefaults
+import androidx.compose.material3.SingleChoiceSegmentedButtonRow
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import com.gotcha.data.Settings
+import com.gotcha.data.ThemeMode
+import com.gotcha.ui.theme.Brightness
+import com.gotcha.ui.theme.GlassTier
+import com.gotcha.ui.theme.LocalGlassTier
+import com.gotcha.ui.theme.Skin
+import com.gotcha.ui.theme.SkinMiniature
+import com.gotcha.ui.theme.Skins
+
+/**
+ * The Appearance page: light or dark, which skin, and how much glass.
+ *
+ * Every control here applies the moment it is touched — a theme you have to
+ * save is a theme you cannot judge. That is also why this page exists at all:
+ * Appearance used to be one segmented control on the settings home, where a
+ * page of its own would have been emptier than the row that opened it. A skin
+ * picker changes that arithmetic.
+ */
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun AppearanceScreen(
+ load: () -> Settings,
+ onSave: ((Settings) -> Settings) -> Unit,
+ onBack: () -> Unit,
+ /** Hands the applied settings straight to the activity, which repaints. */
+ onApply: (Settings) -> Unit
+) {
+ val initial = remember { load() }
+ var themeMode by remember { mutableStateOf(initial.themeMode) }
+ var skinId by remember { mutableStateOf(initial.skinId) }
+ var matchSystem by remember { mutableStateOf(initial.matchSystemBrightness) }
+ var reduceTransparency by remember { mutableStateOf(initial.reduceTransparency) }
+
+ val overlay = rememberSettingsOverlayState()
+ val tier = LocalGlassTier.current
+ val selected = Skins.byId(skinId)
+
+ // One writer for every control on the page: persist, then repaint from storage
+ // so the activity and the preferences can never disagree about what is on.
+ fun apply(mutate: (Settings) -> Settings) {
+ onSave(mutate)
+ onApply(load())
+ }
+
+ SettingsScaffold(title = SettingsPage.APPEARANCE.title, onBack = onBack, overlay = overlay) {
+ Text("Light and dark", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
+ SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
+ ThemeMode.entries.forEachIndexed { index, mode ->
+ SegmentedButton(
+ selected = themeMode == mode,
+ onClick = {
+ themeMode = mode
+ apply { it.copy(themeMode = mode) }
+ },
+ shape = SegmentedButtonDefaults.itemShape(
+ index = index,
+ count = ThemeMode.entries.size
+ )
+ ) { Text(mode.label) }
+ }
+ }
+
+ HorizontalDivider(thickness = 1.dp)
+
+ Text("Theme", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
+ Text(
+ "Every theme works on every device. Where live blur isn't available, " +
+ "the glass is made a cheaper way rather than switched off.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ SkinGrid(
+ selectedId = skinId,
+ onSelect = { picked ->
+ skinId = picked
+ apply { it.copy(skinId = picked) }
+ }
+ )
+ Text(
+ selected.tagline,
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+
+ HorizontalDivider(thickness = 1.dp)
+
+ val pairedId = selected.pairedWith
+ if (pairedId != null) {
+ val twin = Skins.byId(pairedId)
+ SettingsToggleRow(
+ label = "Match system light & dark",
+ checked = matchSystem,
+ onCheckedChange = {
+ matchSystem = it
+ apply { s -> s.copy(matchSystemBrightness = it) }
+ },
+ isLarge = true,
+ switchTestTag = "appearance_match_system"
+ )
+ Text(
+ "${selected.label} and ${twin.label} are the same theme in two " +
+ "brightnesses. With this on, the phone picks whichever one fits.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+
+ SettingsToggleRow(
+ label = "Reduce transparency",
+ checked = reduceTransparency,
+ onCheckedChange = {
+ reduceTransparency = it
+ apply { s -> s.copy(reduceTransparency = it) }
+ },
+ isLarge = true,
+ switchTestTag = "appearance_reduce_transparency"
+ )
+ Text(
+ text = tierExplanation(tier, reduceTransparency),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+}
+
+/** Says what this device is actually doing, rather than what the theme wishes it did. */
+private fun tierExplanation(tier: GlassTier, reduceTransparency: Boolean): String = when {
+ reduceTransparency -> "Panels are solid and no wallpaper is drawn. Colours are unchanged."
+ tier == GlassTier.LIVE -> "Panels blur what's behind them."
+ tier == GlassTier.SOLID -> "Battery saver is on, so panels are solid until it's off."
+ else -> "Live blur isn't available on this device, so panels use a fixed frost."
+}
+
+private const val TILES_PER_ROW = 2
+
+@Composable
+private fun SkinGrid(selectedId: String, onSelect: (String) -> Unit) {
+ Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
+ Skins.all.chunked(TILES_PER_ROW).forEach { row ->
+ Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
+ row.forEach { skin ->
+ SkinTile(
+ skin = skin,
+ selected = skin.id == selectedId,
+ onSelect = { onSelect(skin.id) }
+ )
+ }
+ // Keeps the last row's single tile at tile width instead of full width.
+ repeat(TILES_PER_ROW - row.size) { Box(Modifier.weight(1f)) }
+ }
+ }
+ }
+}
+
+@Composable
+private fun RowScope.SkinTile(skin: Skin, selected: Boolean, onSelect: () -> Unit) {
+ val border = if (selected) {
+ MaterialTheme.colorScheme.primary
+ } else {
+ MaterialTheme.colorScheme.outlineVariant
+ }
+ Column(
+ modifier = Modifier
+ .weight(1f)
+ .clip(RoundedCornerShape(16.dp))
+ .border(
+ width = if (selected) 2.dp else 1.dp,
+ color = border,
+ shape = RoundedCornerShape(16.dp)
+ )
+ .selectable(selected = selected, onClick = onSelect)
+ .testTag("appearance_skin_${skin.id}")
+ ) {
+ SkinPreview(skin)
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 10.dp, vertical = 8.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.SpaceBetween
+ ) {
+ Text(
+ skin.label,
+ style = MaterialTheme.typography.bodyMedium,
+ fontWeight = if (selected) FontWeight.Bold else FontWeight.Medium
+ )
+ Text(
+ brightnessLabel(skin),
+ style = MaterialTheme.typography.labelSmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ }
+}
+
+private fun brightnessLabel(skin: Skin): String = when (skin.brightness) {
+ Brightness.ADAPTIVE -> if (skin.id == Skins.System.id) "wallpaper" else "auto"
+ Brightness.LIGHT -> "light"
+ Brightness.DARK -> "dark"
+ Brightness.FIXED -> "fixed"
+}
+
+/**
+ * A miniature of the chat screen in the skin's own tokens: the wallpaper it
+ * paints, a panel at the translucency it uses, two lines of thread, and the
+ * accent as the send button. Enough to tell them apart at a glance, which is
+ * all a tile has to do.
+ */
+@Composable
+private fun SkinPreview(skin: Skin) {
+ val scheme = skin.scheme(dark = skin.brightness != Brightness.LIGHT)
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .height(84.dp)
+ .background(if (skin.isGlass) Color.Transparent else scheme.background)
+ ) {
+ SkinMiniature(skin, Modifier.matchParentSize())
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(8.dp),
+ verticalArrangement = Arrangement.spacedBy(5.dp)
+ ) {
+ Box(
+ Modifier
+ .fillMaxWidth()
+ .height(14.dp)
+ .clip(RoundedCornerShape(7.dp))
+ .background(scheme.surfaceVariant)
+ )
+ Box(
+ Modifier
+ .fillMaxWidth(0.62f)
+ .height(9.dp)
+ .clip(RoundedCornerShape(5.dp))
+ .background(scheme.onSurfaceVariant.copy(alpha = 0.45f))
+ )
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.End
+ ) {
+ Box(
+ Modifier
+ .size(18.dp)
+ .clip(CircleShape)
+ .background(scheme.primary)
+ )
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
index 3d06bc3..c91f877 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
@@ -54,6 +54,11 @@ import kotlinx.coroutines.delay
* title, so the two can't drift apart.
*/
enum class SettingsPage(val title: String, val summary: String, val testTag: String) {
+ APPEARANCE(
+ "Appearance",
+ "Theme, light and dark, transparency",
+ "settings_appearance_row"
+ ),
PERSONAL_INFO(
"Personal Info",
"Who you are, language, currency, reply style",
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index af7b3eb..a356d69 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -1,35 +1,26 @@
package com.gotcha.ui
import androidx.activity.compose.BackHandler
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.SegmentedButton
-import androidx.compose.material3.SegmentedButtonDefaults
-import androidx.compose.material3.SingleChoiceSegmentedButtonRow
-import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
-import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.gotcha.audio.AudioModel
import com.gotcha.data.Settings
-import com.gotcha.data.ThemeMode
import com.gotcha.i18n.Language
/**
* Settings, shaped like the system Settings app: a home list of categories, each
- * opening its own page ([SettingsPage]), Back returning to the list. Appearance
- * is the one thing left on the home list itself — a single three-way control,
- * applied the moment it is touched, so a page of its own would be emptier than
- * the row that opened it.
+ * opening its own page ([SettingsPage]), Back returning to the list.
+ *
+ * Appearance used to be the exception, kept inline as a single three-way control
+ * because a page for it would have been emptier than the row that opened it.
+ * A theme picker settles that: it is now [AppearanceScreen], first on the list.
*
* Every page saves through [onSave]'s mutator, writing only the fields it owns.
*/
@@ -48,7 +39,8 @@ fun SettingsScreen(
onClearLlmCache: () -> Unit,
onClearDebugScreenshots: () -> Unit,
onBack: () -> Unit,
- onThemeChange: (ThemeMode) -> Unit = {},
+ /** Applies appearance changes to the running activity, without a restart. */
+ onAppearanceChange: (Settings) -> Unit = {},
onRefreshAudioModels: suspend (Settings) -> Pair<List<AudioModel>, List<AudioModel>> = {
Pair(emptyList(), emptyList())
},
@@ -85,6 +77,12 @@ fun SettingsScreen(
if (page != null) BackHandler(onBack = backToHome)
when (page) {
+ SettingsPage.APPEARANCE -> AppearanceScreen(
+ load = load,
+ onSave = onSave,
+ onBack = backToHome,
+ onApply = onAppearanceChange
+ )
SettingsPage.PERSONAL_INFO -> PersonalInfoScreen(
load = load,
onSave = onSave,
@@ -130,54 +128,21 @@ fun SettingsScreen(
onBack = backToHome
)
null -> SettingsHome(
- load = load,
onBack = onBack,
- onOpenPage = { page = it },
- onThemeChange = onThemeChange
+ onOpenPage = { page = it }
)
}
}
-/** The settings home list: the Appearance control, then a row per sub-page. */
-@OptIn(ExperimentalMaterial3Api::class)
+/** The settings home list: one row per sub-page. */
@Composable
private fun SettingsHome(
- load: () -> Settings,
onBack: () -> Unit,
- onOpenPage: (SettingsPage) -> Unit,
- onThemeChange: (ThemeMode) -> Unit
+ onOpenPage: (SettingsPage) -> Unit
) {
- val initial = remember { load() }
- var themeMode by remember { mutableStateOf(initial.themeMode) }
-
val overlay = rememberSettingsOverlayState()
SettingsScaffold(title = "Settings", onBack = onBack, overlay = overlay) {
- // ---- Appearance (applies immediately) ----
- Text(
- "Appearance",
- style = MaterialTheme.typography.titleMedium,
- fontWeight = FontWeight.Bold
- )
- SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
- ThemeMode.values().forEachIndexed { index, mode ->
- SegmentedButton(
- selected = themeMode == mode,
- onClick = {
- themeMode = mode
- onThemeChange(mode)
- },
- shape = SegmentedButtonDefaults.itemShape(
- index = index,
- count = ThemeMode.values().size
- )
- ) { Text(mode.label) }
- }
- }
-
- HorizontalDivider(thickness = 1.dp)
-
- // ---- One row per sub-page ----
SettingsPage.entries.forEachIndexed { index, entry ->
if (index > 0) HorizontalDivider(thickness = 1.dp)
SettingsNavRow(
diff --git a/app/src/main/java/com/gotcha/ui/theme/Backdrop.kt b/app/src/main/java/com/gotcha/ui/theme/Backdrop.kt
new file mode 100644
index 0000000..a99c0fd
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/theme/Backdrop.kt
@@ -0,0 +1,171 @@
+package com.gotcha.ui.theme
+
+import android.graphics.Bitmap
+import androidx.compose.foundation.Canvas
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxScope
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.blur
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.graphics.ImageShader
+import androidx.compose.ui.graphics.Path
+import androidx.compose.ui.graphics.ShaderBrush
+import androidx.compose.ui.graphics.TileMode
+import androidx.compose.ui.graphics.asImageBitmap
+import androidx.compose.ui.graphics.drawscope.DrawScope
+import androidx.compose.ui.unit.dp
+import kotlin.random.Random
+
+/**
+ * Everything painted behind the app's translucent chrome.
+ *
+ * The wallpapers are ours rather than the user's, which is the whole reason the
+ * glass is affordable: a diffuse gradient needs no blur to look blurred, so a
+ * device that cannot blur live still gets the frosted look. Only [Backdrop.FACETS]
+ * — hard edges by design — actually reads differently between tiers.
+ *
+ * Nothing here animates. A drifting wallpaper redraws the full screen forever,
+ * which is a real battery cost for an effect the user stops noticing in a day.
+ */
+@Composable
+fun SkinBackdrop(modifier: Modifier = Modifier) {
+ val skin = LocalSkin.current
+ val tier = LocalGlassTier.current
+ // An opaque skin paints its own background through the colour scheme; drawing
+ // a second ground under it would only cost a full-screen fill.
+ if (!skin.isGlass || tier == GlassTier.SOLID) return
+
+ Box(modifier.background(skin.ground)) {
+ Wallpaper(skin, live = tier == GlassTier.LIVE)
+ if (skin.grain > 0f) Grain(skin.grain)
+ }
+}
+
+@Composable
+private fun BoxScope.Wallpaper(skin: Skin, live: Boolean) {
+ val canvas = Modifier
+ .matchParentSize()
+ .let { if (live && skin.frost > 0.dp) it.blur(skin.frost) else it }
+
+ when (skin.backdrop) {
+ Backdrop.FOG -> Canvas(canvas) { drawFog(skin.wallpaper) }
+ Backdrop.FACETS -> Canvas(canvas) { drawFacets(skin.wallpaper) }
+ // FLAT is the ground and the grain, nothing else — that is the point of it.
+ Backdrop.FLAT, Backdrop.NONE -> Unit
+ }
+}
+
+/**
+ * The same wallpaper at tile size, for the theme picker. It shares the painters
+ * with the real thing rather than shipping screenshots, so a preview cannot go
+ * stale the first time a colour moves.
+ */
+@Composable
+fun SkinMiniature(skin: Skin, modifier: Modifier = Modifier) {
+ Box(modifier.background(skin.ground)) {
+ Wallpaper(skin, live = false)
+ if (skin.grain > 0f) Grain(skin.grain)
+ }
+}
+
+/** Where the fog sits, in fractions of the screen, and how far each one reaches. */
+private val FogSpots = listOf(
+ Offset(0.22f, 0.14f) to 0.78f,
+ Offset(0.84f, 0.30f) to 0.66f,
+ Offset(0.36f, 0.76f) to 0.86f,
+ Offset(0.90f, 0.94f) to 0.60f
+)
+
+private fun DrawScope.drawFog(stops: List<Color>) {
+ if (stops.isEmpty()) return
+ FogSpots.forEachIndexed { index, spot ->
+ val (relative, reach) = spot
+ val center = Offset(size.width * relative.x, size.height * relative.y)
+ val radius = size.minDimension * reach
+ drawCircle(
+ brush = Brush.radialGradient(
+ colors = listOf(stops[index % stops.size], Color.Transparent),
+ center = center,
+ radius = radius
+ ),
+ radius = radius,
+ center = center
+ )
+ }
+}
+
+/**
+ * The launcher icon's low-poly geometry at wallpaper scale. Vertices are in
+ * fractions of the screen so the field re-cuts itself for any aspect ratio
+ * instead of stretching.
+ */
+private val Facets = listOf(
+ listOf(0f to 0f, 0.62f to 0f, 0.28f to 0.44f, 0f to 0.30f),
+ listOf(0.62f to 0f, 1f to 0f, 1f to 0.34f, 0.28f to 0.44f),
+ listOf(0f to 0.30f, 0.28f to 0.44f, 0.16f to 0.78f, 0f to 0.66f),
+ listOf(0.28f to 0.44f, 1f to 0.34f, 0.78f to 0.72f, 0.16f to 0.78f),
+ listOf(0f to 0.66f, 0.16f to 0.78f, 0.42f to 1f, 0f to 1f),
+ listOf(0.16f to 0.78f, 0.78f to 0.72f, 1f to 1f, 0.42f to 1f),
+ listOf(0.78f to 0.72f, 1f to 0.34f, 1f to 1f)
+)
+
+/** Held back so the shards read as colour under glass, not as a games console. */
+private val FacetAlpha = listOf(0.62f, 0.44f, 0.72f, 0.34f, 0.56f, 0.40f, 0.66f)
+
+private fun DrawScope.drawFacets(stops: List<Color>) {
+ if (stops.isEmpty()) return
+ Facets.forEachIndexed { index, vertices ->
+ val path = Path().apply {
+ vertices.forEachIndexed { corner, (x, y) ->
+ val point = Offset(size.width * x, size.height * y)
+ if (corner == 0) moveTo(point.x, point.y) else lineTo(point.x, point.y)
+ }
+ close()
+ }
+ drawPath(
+ path = path,
+ color = stops[index % stops.size],
+ alpha = FacetAlpha[index % FacetAlpha.size]
+ )
+ }
+}
+
+/**
+ * Film grain, tiled from one small bitmap and blended in Overlay so mid-grey is
+ * a no-op — only the deviation shows, which is what keeps a flat ground from
+ * looking like an empty `<div>`.
+ */
+@Composable
+private fun BoxScope.Grain(opacity: Float) {
+ val noise = remember { noiseTile() }
+ val brush = remember(noise) {
+ ShaderBrush(ImageShader(noise, TileMode.Repeated, TileMode.Repeated))
+ }
+ Canvas(Modifier.matchParentSize()) {
+ drawRect(brush = brush, alpha = opacity, blendMode = BlendMode.Overlay)
+ }
+}
+
+private const val NOISE_TILE_PX = 128
+private const val NOISE_MID = 128
+private const val NOISE_SPREAD = 42
+
+/** Fixed seed: the grain is part of the design, so it should not re-roll per launch. */
+private const val NOISE_SEED = 0x6074CA
+
+private fun noiseTile(): ImageBitmap {
+ val random = Random(NOISE_SEED)
+ val pixels = IntArray(NOISE_TILE_PX * NOISE_TILE_PX) {
+ val v = (NOISE_MID + random.nextInt(-NOISE_SPREAD, NOISE_SPREAD)).coerceIn(0, 255)
+ (0xFF shl 24) or (v shl 16) or (v shl 8) or v
+ }
+ return Bitmap.createBitmap(pixels, NOISE_TILE_PX, NOISE_TILE_PX, Bitmap.Config.ARGB_8888)
+ .asImageBitmap()
+}
diff --git a/app/src/main/java/com/gotcha/ui/theme/Color.kt b/app/src/main/java/com/gotcha/ui/theme/Color.kt
index a9a40c2..7b8dfa7 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Color.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Color.kt
@@ -31,3 +31,74 @@ val DarkSecondaryContainer = Color(0xFF7A003C)
val DarkOnSecondaryContainer = Color(0xFFFFD9E2)
val DarkOnSurfaceVariant = Color(0xFFCBD5E1)
+
+// ---------------------------------------------------------------------------
+// Brand ramp
+// ---------------------------------------------------------------------------
+// Sampled from the launcher icon (res/mipmap-*/ic_launcher_round.png): a
+// five-stop ramp over a white field. Every skin below Deep Space is built out
+// of these five and nothing else, which is what keeps the app looking like its
+// own icon no matter which theme is on.
+//
+// Deep Space is the exception and stays cyan — it is what shipped, and it is
+// left alone so an update never repaints someone's app without asking.
+
+val BrandViolet = Color(0xFF7E1F88)
+val BrandMagenta = Color(0xFFC82F92)
+val BrandRose = Color(0xFFF04B8B)
+val BrandCoral = Color(0xFFFC6A85)
+val BrandSalmon = Color(0xFFFA8F8A)
+
+/** Magenta darkened until it clears 4.5:1 on Vellum's near-white ground. */
+val BrandMagentaInk = Color(0xFFB02A83)
+
+// ---- Aura: greyscale fog, rose as the only chroma on screen ----
+val AuraGround = Color(0xFF0A0A0B)
+val AuraPanel = Color(0x12FFFFFF)
+val AuraPanelHigh = Color(0x1FFFFFFF)
+val AuraInk = Color(0xFFF6F6F7)
+val AuraInkDim = Color(0xFFA2A2A8)
+val AuraOutline = Color(0xFF3A3A3E)
+val AuraRoseContainer = Color(0xFF4A0F2C)
+val AuraOnRoseContainer = Color(0xFFFFD9E4)
+
+// ---- Vellum: the icon's own white field, turned into an interface ----
+val VellumGround = Color(0xFFF1EFF2)
+val VellumPanel = Color(0x8CFFFFFF)
+val VellumPanelHigh = Color(0xB3FFFFFF)
+val VellumInk = Color(0xFF17111A)
+val VellumInkDim = Color(0xFF6A5F70)
+val VellumOutline = Color(0xFF867A88)
+val VellumMagentaContainer = Color(0xFFFFD8EC)
+val VellumOnMagentaContainer = Color(0xFF3A0028)
+
+// ---- Orchid: one saturated violet ground, coral for every action ----
+val OrchidGround = BrandViolet
+val OrchidPanel = Color(0x29FFFFFF)
+val OrchidPanelHigh = Color(0x3DFFFFFF)
+val OrchidInk = Color(0xFFFFFFFF)
+val OrchidInkDim = Color(0xFFEBD4EF)
+val OrchidOutline = Color(0xFFB878BE)
+val OrchidOnCoral = Color(0xFF45061F)
+val OrchidCoralContainer = Color(0xFF6E1443)
+
+// ---- Nocturne: the icon's facets at wallpaper scale, behind dark glass ----
+val NocturneGround = Color(0xFF0A050E)
+val NocturnePanel = Color(0x851A1020)
+val NocturnePanelHigh = Color(0x261A1020)
+val NocturneInk = Color(0xFFF7EAF1)
+val NocturneInkDim = Color(0xFFB69EC0)
+val NocturneOutline = Color(0xFF4A3355)
+val NocturneOnSalmon = Color(0xFF3D0A16)
+val NocturneSalmonContainer = Color(0xFF5C1A2A)
+val NocturneMagentaContainer = Color(0xFF3A1140)
+val NocturneOnMagentaContainer = Color(0xFFF7D9F2)
+
+/**
+ * Error red for the pink skins. The stock M3 error would sit a few degrees from
+ * Aura's rose and Nocturne's salmon, and an error that looks like the send
+ * button is not an error — this one is pushed toward orange to stay legible as
+ * "something went wrong" next to an accent that is already warm.
+ */
+val BrandError = Color(0xFFFF6B4A)
+val BrandOnError = Color(0xFF3E0A00)
diff --git a/app/src/main/java/com/gotcha/ui/theme/GlassTier.kt b/app/src/main/java/com/gotcha/ui/theme/GlassTier.kt
new file mode 100644
index 0000000..5a11b61
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/theme/GlassTier.kt
@@ -0,0 +1,116 @@
+package com.gotcha.ui.theme
+
+import android.app.ActivityManager
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import android.content.IntentFilter
+import android.os.Build
+import android.os.PowerManager
+import android.view.WindowManager
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.runtime.staticCompositionLocalOf
+import androidx.compose.ui.platform.LocalContext
+import androidx.core.content.ContextCompat
+import java.util.function.Consumer
+
+/**
+ * How much of the glass this device can actually make.
+ *
+ * Themes are never disabled per device — a locked tile is a dead end the user
+ * cannot clear, and it turns "which theme do you have" into a support matrix.
+ * Every skin renders everywhere; what changes is the material.
+ */
+enum class GlassTier {
+ /** Live blur. The backdrop is blurred on the GPU as the user moves through it. */
+ LIVE,
+
+ /**
+ * No live blur, so the softness has to be baked in. The wallpapers are our
+ * own assets and are already diffuse, so the panels stay translucent and
+ * only a facet field loses its haze.
+ */
+ STATIC,
+
+ /** Opaque panels, no wallpaper. Same palette, same layout — just not glass. */
+ SOLID
+}
+
+/** The tier in force, for anything that needs to branch on it. */
+val LocalGlassTier = staticCompositionLocalOf { GlassTier.STATIC }
+
+/**
+ * Resolves the tier and keeps it current. Two of the inputs flip while the app
+ * is running — battery saver, and the system-wide blur toggle in developer
+ * options — so both are observed rather than sampled once at startup.
+ *
+ * [reduceTransparency] is our own setting. Android has no system-level one (that
+ * is an iOS feature), so if we do not offer it, nobody has it.
+ */
+@Composable
+fun rememberGlassTier(reduceTransparency: Boolean): GlassTier {
+ val context = LocalContext.current
+ val powerManager = remember(context) {
+ context.getSystemService(Context.POWER_SERVICE) as PowerManager
+ }
+
+ var powerSaving by remember { mutableStateOf(powerManager.isPowerSaveMode) }
+ DisposableEffect(context) {
+ val receiver = object : BroadcastReceiver() {
+ override fun onReceive(ctx: Context?, intent: Intent?) {
+ powerSaving = powerManager.isPowerSaveMode
+ }
+ }
+ ContextCompat.registerReceiver(
+ context,
+ receiver,
+ IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED),
+ ContextCompat.RECEIVER_NOT_EXPORTED
+ )
+ onDispose { runCatching { context.unregisterReceiver(receiver) } }
+ }
+
+ var blurAvailable by remember { mutableStateOf(systemBlurEnabled(context)) }
+ DisposableEffect(context) {
+ val listener = crossWindowBlurListener(context) { blurAvailable = it }
+ onDispose { listener?.invoke() }
+ }
+
+ val lowRam = remember(context) {
+ (context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).isLowRamDevice
+ }
+
+ return when {
+ reduceTransparency || powerSaving -> GlassTier.SOLID
+ blurAvailable && !lowRam -> GlassTier.LIVE
+ else -> GlassTier.STATIC
+ }
+}
+
+/** Whether the platform will render blur at all right now. API 31+ only. */
+private fun systemBlurEnabled(context: Context): Boolean {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return false
+ val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+ return wm.isCrossWindowBlurEnabled
+}
+
+/**
+ * Subscribes to the platform blur toggle, returning the un-subscribe call — or
+ * null on Android 11, where the toggle does not exist and the answer can never
+ * change.
+ */
+private fun crossWindowBlurListener(
+ context: Context,
+ onChange: (Boolean) -> Unit
+): (() -> Unit)? {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return null
+ val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+ val listener = Consumer<Boolean> { enabled -> onChange(enabled) }
+ wm.addCrossWindowBlurEnabledListener(listener)
+ return { wm.removeCrossWindowBlurEnabledListener(listener) }
+}
diff --git a/app/src/main/java/com/gotcha/ui/theme/Skin.kt b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
new file mode 100644
index 0000000..6f8ea39
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
@@ -0,0 +1,389 @@
+package com.gotcha.ui.theme
+
+import androidx.compose.material3.ColorScheme
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.lightColorScheme
+import androidx.compose.runtime.staticCompositionLocalOf
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+
+/**
+ * A skin is a whole surface treatment, not just a palette: the colours, what is
+ * painted behind the chrome, how translucent that chrome is, and how round it
+ * is. Material 3's [ColorScheme] has nowhere to put the last three, so they
+ * live here and travel beside it through [LocalSkin].
+ */
+
+/** How a skin answers the device's light/dark setting. */
+enum class Brightness {
+ /** Carries both palettes and switches between them. Deep Space only. */
+ ADAPTIVE,
+
+ /** A daylight skin. Pairs with a dark one via [Skin.pairedWith]. */
+ LIGHT,
+
+ /** A night skin. Pairs with a light one via [Skin.pairedWith]. */
+ DARK,
+
+ /**
+ * Reads the same at noon and midnight. A saturated ground has no honest
+ * darker twin — dimming it for night mode only makes it muddy.
+ */
+ FIXED
+}
+
+/** What gets painted behind the translucent chrome. */
+enum class Backdrop {
+ /** Nothing. The scheme's own background is the whole story. */
+ NONE,
+
+ /** Soft diffused blobs — glass without anything to look at underneath. */
+ FOG,
+
+ /** Hard-edged shards taken from the launcher icon's geometry. */
+ FACETS,
+
+ /** One flat saturated colour, carried by grain rather than depth. */
+ FLAT
+}
+
+/**
+ * @param ground painted first, under [wallpaper]. Also the colour the system
+ * bars sit on, which is why it is a field rather than read back off the scheme.
+ * @param wallpaper stops the backdrop painter reads. Empty for [Backdrop.NONE].
+ * @param frost blur radius applied to the backdrop when the device can do it
+ * live. `0.dp` means the skin never frosts.
+ * @param grain film-grain opacity over the ground, 0f–1f.
+ * @param darkSystemBarIcons true when the bars sit on a light ground and their
+ * icons must be dark. Derived from the skin and never from the system's
+ * dark-mode flag: Orchid is a dark violet ground that needs light icons even
+ * when the phone is in light mode, and getting this from `isSystemInDarkTheme`
+ * is how the clock disappears.
+ * @param pairedWith the skin to swap to when "Match system light & dark" is on.
+ */
+data class Skin(
+ val id: String,
+ val label: String,
+ val tagline: String,
+ val brightness: Brightness,
+ val backdrop: Backdrop,
+ val ground: Color,
+ private val schemeLight: ColorScheme,
+ private val schemeDark: ColorScheme,
+ val wallpaper: List<Color> = emptyList(),
+ val frost: Dp = 0.dp,
+ val grain: Float = 0f,
+ val corner: Dp = 20.dp,
+ val darkSystemBarIcons: Boolean = false,
+ val pairedWith: String? = null
+) {
+ /** [dark] only changes anything for [Brightness.ADAPTIVE] skins. */
+ fun scheme(dark: Boolean): ColorScheme = if (dark) schemeDark else schemeLight
+
+ /** True when this skin has something to say about light and dark at all. */
+ val followsSystem: Boolean
+ get() = brightness == Brightness.ADAPTIVE || pairedWith != null
+
+ /** True when the chrome is meant to be see-through. */
+ val isGlass: Boolean
+ get() = backdrop != Backdrop.NONE
+
+ /**
+ * The same skin with the glass taken out: panels composited down onto their
+ * own ground, no wallpaper, no grain. The palette and the layout are
+ * untouched — it simply stops being see-through. This is what a device on
+ * [GlassTier.SOLID] gets, instead of losing the theme altogether.
+ */
+ fun opaque(): Skin {
+ if (!isGlass) return this
+ return copy(
+ backdrop = Backdrop.NONE,
+ grain = 0f,
+ schemeLight = schemeLight.flattenOnto(ground),
+ schemeDark = schemeDark.flattenOnto(ground)
+ )
+ }
+}
+
+/** Alpha-composites every translucent surface role onto [ground]. */
+private fun ColorScheme.flattenOnto(ground: Color): ColorScheme = copy(
+ background = ground,
+ surface = surface.over(ground),
+ surfaceVariant = surfaceVariant.over(ground),
+ surfaceContainer = surfaceContainer.over(ground),
+ surfaceContainerHigh = surfaceContainerHigh.over(ground),
+ surfaceContainerHighest = surfaceContainerHighest.over(ground),
+ secondaryContainer = secondaryContainer.over(ground)
+)
+
+private fun Color.over(background: Color): Color {
+ if (alpha >= 1f) return this
+ return Color(
+ red = red * alpha + background.red * (1f - alpha),
+ green = green * alpha + background.green * (1f - alpha),
+ blue = blue * alpha + background.blue * (1f - alpha),
+ alpha = 1f
+ )
+}
+
+/** The package-level colour, shadowed inside [Skins] by the skin of the same name. */
+private val DeepSpaceGround = DeepSpace
+
+/** The skin in force. Read it for anything [ColorScheme] cannot express. */
+val LocalSkin = staticCompositionLocalOf { Skins.DeepSpace }
+
+// ---------------------------------------------------------------------------
+// The catalogue
+// ---------------------------------------------------------------------------
+
+private val AuraScheme = darkColorScheme(
+ primary = BrandRose,
+ onPrimary = Color.White,
+ primaryContainer = AuraRoseContainer,
+ onPrimaryContainer = AuraOnRoseContainer,
+ secondary = AuraInkDim,
+ onSecondary = AuraGround,
+ secondaryContainer = AuraPanelHigh,
+ onSecondaryContainer = AuraInk,
+ tertiary = BrandCoral,
+ background = Color.Transparent,
+ onBackground = AuraInk,
+ surface = AuraPanel,
+ onSurface = AuraInk,
+ surfaceVariant = AuraPanelHigh,
+ onSurfaceVariant = AuraInkDim,
+ surfaceContainer = AuraPanel,
+ surfaceContainerHigh = AuraPanelHigh,
+ surfaceContainerHighest = AuraPanelHigh,
+ surfaceContainerLow = AuraGround,
+ surfaceContainerLowest = AuraGround,
+ outline = AuraOutline,
+ outlineVariant = AuraOutline,
+ error = BrandError,
+ onError = BrandOnError
+)
+
+private val VellumScheme = lightColorScheme(
+ primary = BrandMagentaInk,
+ onPrimary = Color.White,
+ primaryContainer = VellumMagentaContainer,
+ onPrimaryContainer = VellumOnMagentaContainer,
+ secondary = VellumInkDim,
+ onSecondary = Color.White,
+ secondaryContainer = VellumPanelHigh,
+ onSecondaryContainer = VellumInk,
+ tertiary = BrandViolet,
+ background = Color.Transparent,
+ onBackground = VellumInk,
+ surface = VellumPanel,
+ onSurface = VellumInk,
+ surfaceVariant = VellumPanelHigh,
+ onSurfaceVariant = VellumInkDim,
+ surfaceContainer = VellumPanel,
+ surfaceContainerHigh = VellumPanelHigh,
+ surfaceContainerHighest = VellumPanelHigh,
+ surfaceContainerLow = VellumGround,
+ surfaceContainerLowest = VellumGround,
+ outline = VellumOutline,
+ outlineVariant = VellumOutline
+)
+
+private val OrchidScheme = darkColorScheme(
+ primary = BrandCoral,
+ onPrimary = OrchidOnCoral,
+ primaryContainer = OrchidCoralContainer,
+ onPrimaryContainer = Color.White,
+ secondary = OrchidInkDim,
+ onSecondary = OrchidGround,
+ secondaryContainer = OrchidPanelHigh,
+ onSecondaryContainer = OrchidInk,
+ tertiary = BrandSalmon,
+ background = Color.Transparent,
+ onBackground = OrchidInk,
+ surface = OrchidPanel,
+ onSurface = OrchidInk,
+ surfaceVariant = OrchidPanelHigh,
+ onSurfaceVariant = OrchidInkDim,
+ surfaceContainer = OrchidPanel,
+ surfaceContainerHigh = OrchidPanelHigh,
+ surfaceContainerHighest = OrchidPanelHigh,
+ surfaceContainerLow = OrchidGround,
+ surfaceContainerLowest = OrchidGround,
+ outline = OrchidOutline,
+ outlineVariant = OrchidOutline,
+ error = BrandError,
+ onError = BrandOnError
+)
+
+private val NocturneScheme = darkColorScheme(
+ primary = BrandSalmon,
+ onPrimary = NocturneOnSalmon,
+ primaryContainer = NocturneSalmonContainer,
+ onPrimaryContainer = Color.White,
+ secondary = BrandMagenta,
+ onSecondary = Color.White,
+ secondaryContainer = NocturneMagentaContainer,
+ onSecondaryContainer = NocturneOnMagentaContainer,
+ tertiary = BrandViolet,
+ background = Color.Transparent,
+ onBackground = NocturneInk,
+ surface = NocturnePanel,
+ onSurface = NocturneInk,
+ surfaceVariant = NocturnePanelHigh,
+ onSurfaceVariant = NocturneInkDim,
+ surfaceContainer = NocturnePanel,
+ surfaceContainerHigh = NocturnePanel,
+ surfaceContainerHighest = NocturnePanelHigh,
+ surfaceContainerLow = NocturneGround,
+ surfaceContainerLowest = NocturneGround,
+ outline = NocturneOutline,
+ outlineVariant = NocturneOutline,
+ error = BrandError,
+ onError = BrandOnError
+)
+
+/** Every skin the picker offers, in the order it offers them. */
+object Skins {
+
+ /**
+ * What shipped, untouched: opaque slate, cyan primary, Material 3
+ * elevation. It stays the default so an update never surprises anyone, and
+ * it is the fallback whenever glass is unavailable.
+ */
+ val DeepSpace = Skin(
+ id = "deepspace",
+ label = "Deep Space",
+ tagline = "The original. Opaque, cyan, no wallpaper.",
+ brightness = Brightness.ADAPTIVE,
+ backdrop = Backdrop.NONE,
+ ground = DeepSpaceGround,
+ schemeLight = LightColorScheme,
+ schemeDark = DarkColorScheme
+ )
+
+ /**
+ * Greyscale fog with the icon's rose as the only chroma on screen — send,
+ * active mode, recording. Everything else is grey, which is exactly what
+ * makes the pink land.
+ */
+ val Aura = Skin(
+ id = "aura",
+ label = "Aura",
+ tagline = "Frosted dark. Grey fog, one rose accent.",
+ brightness = Brightness.DARK,
+ backdrop = Backdrop.FOG,
+ ground = AuraGround,
+ schemeLight = AuraScheme,
+ schemeDark = AuraScheme,
+ wallpaper = listOf(
+ Color(0x24FFFFFF),
+ Color(0x14FFFFFF),
+ Color(0x1AFFFFFF),
+ Color(0x0FFFFFFF)
+ ),
+ frost = 26.dp,
+ grain = 0.05f,
+ corner = 22.dp,
+ pairedWith = "vellum"
+ )
+
+ /** The icon's white field as an interface. The one skin that survives sun. */
+ val Vellum = Skin(
+ id = "vellum",
+ label = "Vellum",
+ tagline = "Frosted light. Paper ground, magenta ink.",
+ brightness = Brightness.LIGHT,
+ backdrop = Backdrop.FOG,
+ ground = VellumGround,
+ schemeLight = VellumScheme,
+ schemeDark = VellumScheme,
+ wallpaper = listOf(
+ Color(0xF2FFFFFF),
+ Color(0x52DB63B8),
+ Color(0xCCFFFFFF),
+ Color(0x3D8F3AB2)
+ ),
+ frost = 22.dp,
+ grain = 0.035f,
+ corner = 22.dp,
+ darkSystemBarIcons = true,
+ pairedWith = "aura"
+ )
+
+ /**
+ * The icon's deepest violet carrying the whole screen, grain over it, and
+ * coral — the ramp's warmest stop — for every action. Two colours that
+ * already sit next to each other in the icon, at maximum volume.
+ */
+ val Orchid = Skin(
+ id = "orchid",
+ label = "Orchid",
+ tagline = "Tinted. Violet ground, coral actions, real grain.",
+ brightness = Brightness.FIXED,
+ backdrop = Backdrop.FLAT,
+ ground = OrchidGround,
+ schemeLight = OrchidScheme,
+ schemeDark = OrchidScheme,
+ frost = 8.dp,
+ grain = 0.24f,
+ corner = 22.dp
+ )
+
+ /** The launcher icon's low-poly geometry, blown up to wallpaper scale. */
+ val Nocturne = Skin(
+ id = "nocturne",
+ label = "Nocturne",
+ tagline = "Faceted dark. The icon's shards behind black glass.",
+ brightness = Brightness.DARK,
+ backdrop = Backdrop.FACETS,
+ ground = NocturneGround,
+ schemeLight = NocturneScheme,
+ schemeDark = NocturneScheme,
+ wallpaper = listOf(BrandViolet, BrandMagenta, BrandRose, BrandCoral, BrandSalmon),
+ frost = 34.dp,
+ grain = 0.05f,
+ corner = 20.dp
+ )
+
+ /**
+ * Material You. Present as a real choice rather than as the silent default
+ * it used to be: [GotchaTheme] defaulted to `dynamicColor = true`, so the
+ * user's wallpaper has been overriding every palette here since API 31 —
+ * which is every device, given minSdk 30. Picking any other skin now turns
+ * it off, and picking this one turns it back on.
+ *
+ * The schemes below are only reached on Android 11, where there is no
+ * dynamic colour to read.
+ */
+ val System = Skin(
+ id = "system",
+ label = "System",
+ tagline = "Material You. Colours follow your wallpaper.",
+ brightness = Brightness.ADAPTIVE,
+ backdrop = Backdrop.NONE,
+ ground = DeepSpaceGround,
+ schemeLight = LightColorScheme,
+ schemeDark = DarkColorScheme
+ )
+
+ val all = listOf(DeepSpace, Aura, Vellum, Orchid, Nocturne, System)
+
+ const val DEFAULT_ID = "deepspace"
+
+ fun byId(id: String): Skin = all.firstOrNull { it.id == id } ?: DeepSpace
+
+ /**
+ * The skin actually painted, once "Match system light & dark" has had its
+ * say. A paired skin hands over to its twin rather than inventing a washed
+ * out light version of itself.
+ */
+ fun resolve(id: String, matchSystem: Boolean, dark: Boolean): Skin {
+ val chosen = byId(id)
+ if (!matchSystem) return chosen
+ val twin = chosen.pairedWith?.let(::byId) ?: return chosen
+ val wrongWayRound = (chosen.brightness == Brightness.DARK && !dark) ||
+ (chosen.brightness == Brightness.LIGHT && dark)
+ return if (wrongWayRound) twin else chosen
+ }
+}
diff --git a/app/src/main/java/com/gotcha/ui/theme/Theme.kt b/app/src/main/java/com/gotcha/ui/theme/Theme.kt
index 02f5ab5..5c3d482 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Theme.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Theme.kt
@@ -1,16 +1,22 @@
package com.gotcha.ui.theme
+import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
+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.runtime.SideEffect
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalView
+import androidx.core.view.WindowCompat
-private val DarkColorScheme = darkColorScheme(
+internal val DarkColorScheme = darkColorScheme(
primary = DarkPrimary,
onPrimary = DarkOnPrimary,
primaryContainer = DarkPrimaryContainer,
@@ -24,7 +30,7 @@ private val DarkColorScheme = darkColorScheme(
onSurfaceVariant = DarkOnSurfaceVariant
)
-private val LightColorScheme = lightColorScheme(
+internal val LightColorScheme = lightColorScheme(
primary = LightPrimary,
onPrimary = LightOnPrimary,
primaryContainer = LightPrimaryContainer,
@@ -38,24 +44,75 @@ private val LightColorScheme = lightColorScheme(
onSurfaceVariant = LightOnSurfaceVariant
)
+/**
+ * @param skinId which entry of [Skins] the user picked.
+ * @param matchSystemBrightness swap a paired skin for its twin when the device
+ * flips between light and dark, instead of keeping one skin in both.
+ * @param reduceTransparency our own accessibility switch — Android has no
+ * system-level equivalent, so this is the only way to ask for solid panels.
+ */
@Composable
fun GotchaTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
- dynamicColor: Boolean = true,
+ skinId: String = Skins.DEFAULT_ID,
+ matchSystemBrightness: Boolean = true,
+ reduceTransparency: Boolean = false,
content: @Composable () -> Unit
) {
- val colorScheme = when {
- dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
- val context = LocalContext.current
- if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
- }
- darkTheme -> DarkColorScheme
- else -> LightColorScheme
+ val tier = rememberGlassTier(reduceTransparency)
+ val picked = Skins.resolve(skinId, matchSystemBrightness, darkTheme)
+ // The tier decides what the skin is made of, not whether the user gets it.
+ val skin = if (tier == GlassTier.SOLID) picked.opaque() else picked
+
+ val colorScheme = resolveScheme(skin, darkTheme)
+ SystemBars(skin, darkTheme)
+
+ CompositionLocalProvider(
+ LocalSkin provides skin,
+ LocalGlassTier provides tier
+ ) {
+ MaterialTheme(
+ colorScheme = colorScheme,
+ typography = Typography,
+ content = content
+ )
}
+}
- MaterialTheme(
- colorScheme = colorScheme,
- typography = Typography,
- content = content
- )
+/**
+ * Material You is now a skin the user picks rather than the silent default it
+ * used to be. It has to be, once there is a picker at all: dynamic colour
+ * overrides every palette here, so leaving it on would have made choosing a
+ * skin do nothing visible.
+ */
+@Composable
+private fun resolveScheme(skin: Skin, darkTheme: Boolean): ColorScheme {
+ val dynamic = skin.id == Skins.System.id &&
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
+ if (!dynamic) return skin.scheme(darkTheme)
+ val context = LocalContext.current
+ return if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+}
+
+/**
+ * Status- and navigation-bar icons follow the *skin's* ground, not the device's
+ * dark-mode flag. Orchid is a dark violet ground that keeps light icons even in
+ * light mode; reading `isSystemInDarkTheme` here is how the clock disappears.
+ */
+@Composable
+private fun SystemBars(skin: Skin, darkTheme: Boolean) {
+ val view = LocalView.current
+ if (view.isInEditMode) return
+ val lightBars = if (skin.brightness == Brightness.ADAPTIVE) {
+ !darkTheme
+ } else {
+ skin.darkSystemBarIcons
+ }
+ SideEffect {
+ val window = (view.context as? Activity)?.window ?: return@SideEffect
+ WindowCompat.getInsetsController(window, view).apply {
+ isAppearanceLightStatusBars = lightBars
+ isAppearanceLightNavigationBars = lightBars
+ }
+ }
}