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: Refactor theme handling by removing ThemeMode and simplifying skin management
Durganshu Mishrae6f31a56db9e
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.ktindex 97a0684..5c50fc4 100644--- a/app/src/main/java/com/gotcha/MainActivity.kt+++ b/app/src/main/java/com/gotcha/MainActivity.kt@@ -3,7 +3,6 @@ package com.gotchaimport android.app.admin.DevicePolicyManagerimport android.content.Contextimport android.content.Intent-import android.content.res.Configurationimport android.graphics.drawable.ColorDrawableimport android.net.Uriimport android.net.VpnService@@ -15,7 +14,6 @@ import androidx.activity.compose.BackHandlerimport androidx.activity.compose.setContentimport androidx.activity.result.contract.ActivityResultContractsimport androidx.activity.viewModels-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.material3.DrawerValueimport androidx.compose.material3.MaterialTheme@@ -40,7 +38,6 @@ import com.gotcha.auth.SamosaAuthManagerimport com.gotcha.auth.SamosaSignInResultimport com.gotcha.data.Settingsimport com.gotcha.data.SettingsRepository-import com.gotcha.data.ThemeModeimport com.gotcha.llm.ChatMessageimport com.gotcha.llm.LLMClientimport com.gotcha.service.AssistiveBallService@@ -78,11 +75,9 @@ class MainActivity : ComponentActivity() {/** 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. */+ /** The three 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,val frostPercent: Int = 100)@@ -94,26 +89,12 @@ class MainActivity : ComponentActivity() {* chose rather than a slate blue they have never seen.*/private fun applyLaunchBackground() {- val dark = when (appearance.themeMode) {- ThemeMode.LIGHT -> false- ThemeMode.DARK -> true- ThemeMode.SYSTEM -> {- val night = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK- night == Configuration.UI_MODE_NIGHT_YES- }- }- val skin = Skins.resolve(- appearance.skinId,- appearance.matchSystemBrightness,- dark- )- window.setBackgroundDrawable(ColorDrawable(skin.launchGround(dark).toArgb()))+ val skin = Skins.byId(appearance.skinId)+ window.setBackgroundDrawable(ColorDrawable(skin.launchGround.toArgb()))}private fun Settings.appearance() = Appearance(- themeMode = themeMode,skinId = skinId,- matchSystemBrightness = matchSystemBrightness,reduceTransparency = reduceTransparency,frostPercent = frostPercent)@@ -211,15 +192,8 @@ class MainActivity : ComponentActivity() {applyLaunchBackground()setContent {- val darkTheme = when (appearance.themeMode) {- ThemeMode.LIGHT -> false- ThemeMode.DARK -> true- ThemeMode.SYSTEM -> isSystemInDarkTheme()- }GotchaTheme(- darkTheme = darkTheme,skinId = appearance.skinId,- matchSystemBrightness = appearance.matchSystemBrightness,reduceTransparency = appearance.reduceTransparency,frostPercent = appearance.frostPercent) {diff --git a/app/src/main/java/com/gotcha/data/SettingsRepository.kt b/app/src/main/java/com/gotcha/data/SettingsRepository.ktindex 4206874..bb7ff23 100644--- a/app/src/main/java/com/gotcha/data/SettingsRepository.kt+++ b/app/src/main/java/com/gotcha/data/SettingsRepository.kt@@ -6,13 +6,6 @@ import androidx.security.crypto.EncryptedSharedPreferencesimport androidx.security.crypto.MasterKeyimport com.gotcha.audio.AudioProvider-/** In-app theme override; SYSTEM follows the device dark-mode setting. */-enum class ThemeMode(val label: String) {- SYSTEM("System"),- LIGHT("Light"),- DARK("Dark")-}-data class Settings(// Which LLM backend is active. Defaults to the original OpenAI-compatible flow.val provider: LlmProvider = LlmProvider.OPENAI_COMPATIBLE,@@ -60,7 +53,6 @@ data class Settings(/** Chime when a reply arrives. Off by default — audible in a way a buzz is not. */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@@ -68,11 +60,6 @@ data class Settings(* 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.@@ -242,6 +229,21 @@ class SettingsRepository(context: Context) {private fun string(key: String, default: String = ""): String =prefs.getString(key, default) ?: default+ /**+ * The chosen skin, migrating anyone who was on the old Deep Space + "Light"+ * combination. That pairing used to be two settings; it is one skin now, and+ * silently moving them to the dark one would repaint an app they had+ * deliberately set light.+ */+ private fun resolvedSkinId(): String {+ val stored = prefs.getString(KEY_SKIN_ID, null)+ if (stored != null) return stored+ val legacy = prefs.getString(KEY_LEGACY_THEME_MODE, null)+ val id = if (legacy == "LIGHT") SKIN_DEEP_SPACE_LIGHT else SKIN_DEEP_SPACE_DARK+ prefs.edit().putString(KEY_SKIN_ID, id).apply()+ return id+ }+fun load(): Settings = Settings(provider = LlmProvider.fromName(prefs.getString(KEY_PROVIDER, null)),apiKey = string(KEY_API_KEY),@@ -275,11 +277,7 @@ class SettingsRepository(context: Context) {notifyVibrationEnabled = prefs.getBoolean(KEY_NOTIFY_VIBRATION, true),notifyChimeEnabled = prefs.getBoolean(KEY_NOTIFY_CHIME, false),assistiveBallEnabled = prefs.getBoolean(KEY_ASSISTIVE_BALL, false),- 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),+ skinId = resolvedSkinId(),reduceTransparency = prefs.getBoolean(KEY_REDUCE_TRANSPARENCY, false),frostPercent = prefs.getInt(KEY_FROST_PERCENT, 100),disabledSkills = stringSet(KEY_DISABLED_SKILLS),@@ -331,9 +329,7 @@ class SettingsRepository(context: Context) {.putBoolean(KEY_NOTIFY_VIBRATION, settings.notifyVibrationEnabled).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).putInt(KEY_FROST_PERCENT, settings.frostPercent).putStringSet(KEY_DISABLED_SKILLS, settings.disabledSkills)@@ -401,9 +397,12 @@ class SettingsRepository(context: Context) {const val KEY_NOTIFY_VIBRATION = "notify_vibration"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"++ /** Only read by [resolvedSkinId]'s migration; never written any more. */+ const val KEY_LEGACY_THEME_MODE = "theme_mode"+ const val SKIN_DEEP_SPACE_DARK = "deepspace"+ const val SKIN_DEEP_SPACE_LIGHT = "deepspace_light"const val KEY_REDUCE_TRANSPARENCY = "reduce_transparency"const val KEY_FROST_PERCENT = "frost_percent"const val KEY_DISABLED_SKILLS = "disabled_skills"diff --git a/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt b/app/src/main/java/com/gotcha/ui/AppearanceScreen.ktindex 83c4bfa..831fe3a 100644--- a/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt+++ b/app/src/main/java/com/gotcha/ui/AppearanceScreen.kt@@ -17,9 +17,6 @@ import androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.material3.ExperimentalMaterial3Apiimport androidx.compose.material3.HorizontalDividerimport androidx.compose.material3.MaterialTheme-import androidx.compose.material3.SegmentedButton-import androidx.compose.material3.SegmentedButtonDefaults-import androidx.compose.material3.SingleChoiceSegmentedButtonRowimport androidx.compose.material3.Sliderimport androidx.compose.material3.Textimport androidx.compose.runtime.Composable@@ -36,7 +33,6 @@ import androidx.compose.ui.platform.testTagimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.dpimport com.gotcha.data.Settings-import com.gotcha.data.ThemeModeimport com.gotcha.ui.theme.Brightnessimport com.gotcha.ui.theme.GlassTierimport com.gotcha.ui.theme.GotchaMono@@ -50,10 +46,11 @@ import kotlin.math.roundToInt* 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.+ * save is a theme you cannot judge.+ *+ * There is no light/dark switch. A skin *is* a brightness: Vellum is the light+ * one, Aura is the dark one, and Deep Space ships as two entries rather than one+ * that changes under you. The picker shows what you will get, not what you might.*/@OptIn(ExperimentalMaterial3Api::class)@Composable@@ -65,9 +62,7 @@ fun AppearanceScreen(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) }var frostPercent by remember { mutableIntStateOf(initial.frostPercent) }@@ -83,25 +78,6 @@ fun AppearanceScreen(}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, " +@@ -124,27 +100,6 @@ fun AppearanceScreen(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- )- }-if (selected.isGlass && !reduceTransparency) {Text("Frost",@@ -256,10 +211,8 @@ private fun RowScope.SkinTile(skin: Skin, selected: Boolean, onSelect: () -> Uni}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"}/**@@ -270,7 +223,7 @@ private fun brightnessLabel(skin: Skin): String = when (skin.brightness) {*/@Composableprivate fun SkinPreview(skin: Skin) {- val scheme = skin.scheme(dark = skin.brightness != Brightness.LIGHT)+ val scheme = skin.schemeBox(modifier = Modifier.fillMaxWidth()diff --git a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.ktindex 8a3fc76..ac5268f 100644--- a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt@@ -2,7 +2,6 @@ package com.gotcha.uiimport android.animation.ValueAnimatorimport android.content.Context-import android.content.res.Configurationimport android.graphics.Colorimport android.graphics.PixelFormatimport android.graphics.Typeface@@ -26,7 +25,6 @@ import androidx.core.content.res.ResourcesCompatimport androidx.core.graphics.ColorUtilsimport com.gotcha.Rimport com.gotcha.data.SettingsRepository-import com.gotcha.data.ThemeModeimport com.gotcha.service.EntityTypeimport com.gotcha.service.ProactiveSessionItemimport com.gotcha.service.SmartActionDetector@@ -89,17 +87,6 @@ class AssistiveBallOverlay(context: Context) {val buttonText: Int)- private fun isDarkTheme(): Boolean {- val mode = runCatching { settingsRepository.load().themeMode }.getOrDefault(ThemeMode.SYSTEM)- return when (mode) {- ThemeMode.DARK -> true- ThemeMode.LIGHT -> false- ThemeMode.SYSTEM ->- appContext.resources.configuration.uiMode and- Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES- }- }-/*** The ball is a window over other apps, so it takes its colours from the* chosen skin rather than from a pair of hardcoded Deep Space palettes.@@ -108,14 +95,12 @@ class AssistiveBallOverlay(context: Context) {* this window, only whatever app the user is looking at, and translucent* chrome over someone else's screen is unreadable.*/+ private fun skinScheme() = Skins.byId(+ runCatching { settingsRepository.load().skinId }.getOrDefault(Skins.DEFAULT_ID)+ ).opaque().scheme+private fun palette(): OverlayPalette {- val dark = isDarkTheme()- val settings = runCatching { settingsRepository.load() }.getOrNull()- val scheme = Skins.resolve(- settings?.skinId ?: Skins.DEFAULT_ID,- settings?.matchSystemBrightness ?: true,- dark- ).opaque().scheme(dark)+ val scheme = skinScheme()return OverlayPalette(surface = scheme.surface.toArgb(),onSurface = scheme.onSurface.toArgb(),@@ -126,15 +111,7 @@ class AssistiveBallOverlay(context: Context) {}/** The skin's own accent, for the ring and any other tinted overlay part. */- private fun accentColor(): Int {- val dark = isDarkTheme()- val settings = runCatching { settingsRepository.load() }.getOrNull()- return Skins.resolve(- settings?.skinId ?: Skins.DEFAULT_ID,- settings?.matchSystemBrightness ?: true,- dark- ).opaque().scheme(dark).primary.toArgb()- }+ private fun accentColor(): Int = skinScheme().primary.toArgb()fun canShow(): Boolean = Settings.canDrawOverlays(appContext)diff --git a/app/src/main/java/com/gotcha/ui/theme/Backdrop.kt b/app/src/main/java/com/gotcha/ui/theme/Backdrop.ktindex 555716e..5913bb8 100644--- a/app/src/main/java/com/gotcha/ui/theme/Backdrop.kt+++ b/app/src/main/java/com/gotcha/ui/theme/Backdrop.kt@@ -133,8 +133,8 @@ private val Facets = listOf(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)+/** Varied so adjacent shards separate; the glass over them does the softening. */+private val FacetAlpha = listOf(0.92f, 0.62f, 1f, 0.52f, 0.84f, 0.58f, 0.96f)private fun DrawScope.drawFacets(stops: List<Color>) {if (stops.isEmpty()) returndiff --git a/app/src/main/java/com/gotcha/ui/theme/Color.kt b/app/src/main/java/com/gotcha/ui/theme/Color.ktindex 4e135ff..85b05de 100644--- a/app/src/main/java/com/gotcha/ui/theme/Color.kt+++ b/app/src/main/java/com/gotcha/ui/theme/Color.kt@@ -54,18 +54,18 @@ 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 AuraPanel = Color(0x1FFFFFFF)+val AuraPanelHigh = Color(0x30FFFFFF)val AuraInk = Color(0xFFF6F6F7)val AuraInkDim = Color(0xFFA2A2A8)-val AuraOutline = Color(0xFF3A3A3E)+val AuraOutline = Color(0xFF57575E)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 VellumPanel = Color(0x9EFFFFFF)+val VellumPanelHigh = Color(0xC7FFFFFF)val VellumInk = Color(0xFF17111A)val VellumInkDim = Color(0xFF6A5F70)val VellumOutline = Color(0xFF867A88)@@ -74,8 +74,8 @@ 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 OrchidPanel = Color(0x40FFFFFF)+val OrchidPanelHigh = Color(0x59FFFFFF)val OrchidInk = Color(0xFFFFFFFF)val OrchidInkDim = Color(0xFFEBD4EF)val OrchidOutline = Color(0xFFB878BE)@@ -84,8 +84,8 @@ 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 NocturnePanel = Color(0x8F1A1020)+val NocturnePanelHigh = Color(0x40FFFFFF)val NocturneInk = Color(0xFFF7EAF1)val NocturneInkDim = Color(0xFFB69EC0)val NocturneOutline = Color(0xFF4A3355)diff --git a/app/src/main/java/com/gotcha/ui/theme/Skin.kt b/app/src/main/java/com/gotcha/ui/theme/Skin.ktindex ec40c5f..95d894d 100644--- a/app/src/main/java/com/gotcha/ui/theme/Skin.kt+++ b/app/src/main/java/com/gotcha/ui/theme/Skin.kt@@ -13,25 +13,14 @@ import androidx.compose.ui.unit.dp* 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].+ *+ * One skin is one look. There is no light/dark axis on top: a theme that has to+ * work in two brightnesses is two designs sharing a name, and the compromise+ * shows in both. Deep Space ships as two entries for exactly that reason.*/-/** 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-}+/** Which way round a skin is, for the system bars and the picker's caption. */+enum class Brightness { LIGHT, DARK }/** What gets painted behind the translucent chrome. */enum class Backdrop {@@ -53,14 +42,11 @@ enum class Backdrop {* 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.+ * live. Deliberately moderate: blur far enough and the wallpaper stops having+ * any structure to see through the glass, which is the whole effect.* @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.+ * @param scrim a veil of [ground] over the wallpaper, 0f–1f, so body text is+ * never fighting whatever the wallpaper is doing underneath it.*/data class Skin(val id: String,@@ -69,40 +55,29 @@ data class Skin(val brightness: Brightness,val backdrop: Backdrop,val ground: Color,- private val schemeLight: ColorScheme,- private val schemeDark: ColorScheme,+ val scheme: ColorScheme,val wallpaper: List<Color> = emptyList(),val frost: Dp = 0.dp,val grain: Float = 0f,- /**- * A veil of [ground] laid over the wallpaper, 0f–1f. Glass buys depth at the- * cost of contrast: body text ends up sitting on whatever the wallpaper is- * doing underneath it. The veil pulls the wallpaper's range in so the text- * always wins, and the louder the wallpaper the more of it there is.- */val scrim: Float = 0f,- val corner: Dp = 20.dp,- val darkSystemBarIcons: Boolean = false,- val pairedWith: String? = null+ val corner: Dp = 20.dp) {- /** [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: Booleanget() = backdrop != Backdrop.NONE/**- * What the window should be painted before Compose draws anything. A glass- * skin has a ground of its own; an opaque one is whatever its scheme says- * the background is, which depends on [dark].+ * True when the system bars sit on a light ground and their icons must be+ * dark. Derived from the skin and never from the device's dark-mode flag:+ * Orchid is a dark violet ground that needs light icons whatever the phone+ * thinks the time of day is.*/- fun launchGround(dark: Boolean): Color =- if (isGlass) ground else scheme(dark).background+ val darkSystemBarIcons: Boolean+ get() = brightness == Brightness.LIGHT++ /** What the window is painted before Compose draws anything. */+ val launchGround: Color+ get() = if (isGlass) ground else scheme.background/*** The same skin with its frost dialled to [percent] of what it was designed@@ -112,7 +87,7 @@ data class Skin(*/fun withFrost(percent: Int): Skin {if (percent >= 100 || !isGlass) return this- val factor = (percent.coerceIn(0, 100)) / 100f+ val factor = percent.coerceIn(0, 100) / 100freturn copy(frost = frost * factor, scrim = scrim * factor)}@@ -128,8 +103,7 @@ data class Skin(backdrop = Backdrop.NONE,grain = 0f,scrim = 0f,- schemeLight = schemeLight.flattenOnto(ground),- schemeDark = schemeDark.flattenOnto(ground)+ scheme = scheme.flattenOnto(ground))}}@@ -160,7 +134,7 @@ private fun Color.over(background: Color): Color {private val DeepSpaceGround = DeepSpace/** The skin in force. Read it for anything [ColorScheme] cannot express. */-val LocalSkin = staticCompositionLocalOf { Skins.DeepSpace }+val LocalSkin = staticCompositionLocalOf { Skins.DeepSpaceDark }// ---------------------------------------------------------------------------// The catalogue@@ -275,22 +249,6 @@ private val NocturneScheme = darkColorScheme(/** 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@@ -299,47 +257,42 @@ object Skins {val Aura = Skin(id = "aura",label = "Aura",- tagline = "Frosted dark. Grey fog, one rose accent.",+ tagline = "Frosted dark. Grey fog behind glass, one rose accent.",brightness = Brightness.DARK,backdrop = Backdrop.FOG,ground = AuraGround,- schemeLight = AuraScheme,- schemeDark = AuraScheme,+ scheme = AuraScheme,wallpaper = listOf(- Color(0x24FFFFFF),- Color(0x14FFFFFF),- Color(0x1AFFFFFF),- Color(0x0FFFFFFF)+ Color(0x59FFFFFF),+ Color(0x33FFFFFF),+ Color(0x4DFFFFFF),+ Color(0x26FFFFFF)),- frost = 26.dp,- grain = 0.05f,- scrim = 0.10f,- corner = 22.dp,- pairedWith = "vellum"+ frost = 20.dp,+ grain = 0.06f,+ scrim = 0.05f,+ corner = 22.dp)/** 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.",+ tagline = "Frosted light. Paper ground, rose haze, magenta ink.",brightness = Brightness.LIGHT,backdrop = Backdrop.FOG,ground = VellumGround,- schemeLight = VellumScheme,- schemeDark = VellumScheme,+ scheme = VellumScheme,wallpaper = listOf(- Color(0xF2FFFFFF),- Color(0x52DB63B8),+ Color(0xFFFFFFFF),+ Color(0x80DB63B8),Color(0xCCFFFFFF),- Color(0x3D8F3AB2)+ Color(0x668F3AB2)),- frost = 22.dp,- grain = 0.035f,- scrim = 0.12f,- corner = 22.dp,- darkSystemBarIcons = true,- pairedWith = "aura"+ frost = 18.dp,+ grain = 0.04f,+ scrim = 0.05f,+ corner = 22.dp)/**@@ -350,14 +303,13 @@ object Skins {val Orchid = Skin(id = "orchid",label = "Orchid",- tagline = "Tinted. Violet ground, coral actions, real grain.",- brightness = Brightness.FIXED,+ tagline = "Tinted. Violet ground, coral actions, heavy grain.",+ brightness = Brightness.DARK,backdrop = Backdrop.FLAT,ground = OrchidGround,- schemeLight = OrchidScheme,- schemeDark = OrchidScheme,+ scheme = OrchidScheme,frost = 8.dp,- grain = 0.24f,+ grain = 0.34f,corner = 22.dp)@@ -365,58 +317,48 @@ object Skins {val Nocturne = Skin(id = "nocturne",label = "Nocturne",- tagline = "Faceted dark. The icon's shards behind black glass.",+ tagline = "Faceted dark. The icon's shards read through black glass.",brightness = Brightness.DARK,backdrop = Backdrop.FACETS,ground = NocturneGround,- schemeLight = NocturneScheme,- schemeDark = NocturneScheme,+ scheme = NocturneScheme,wallpaper = listOf(BrandViolet, BrandMagenta, BrandRose, BrandCoral, BrandSalmon),- frost = 34.dp,- grain = 0.05f,- // The facets are the loudest thing any skin puts behind text.- scrim = 0.30f,+ frost = 18.dp,+ grain = 0.06f,+ scrim = 0.10f,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.+ * What shipped, untouched: opaque slate, cyan primary, Material 3+ * elevation. Two entries rather than one that follows the system, so the+ * picker shows what you will get instead of what you might get.*- * The schemes below are only reached on Android 11, where there is no- * dynamic colour to read.+ * Dark is the default, and the fallback whenever glass is unavailable.*/- val System = Skin(- id = "system",- label = "System",- tagline = "Material You. Colours follow your wallpaper.",- brightness = Brightness.ADAPTIVE,+ val DeepSpaceDark = Skin(+ id = "deepspace",+ label = "Deep Space Dark",+ tagline = "The original. Opaque slate, cyan, no wallpaper.",+ brightness = Brightness.DARK,backdrop = Backdrop.NONE,ground = DeepSpaceGround,- schemeLight = LightColorScheme,- schemeDark = DarkColorScheme+ scheme = DarkColorScheme)- val all = listOf(DeepSpace, Aura, Vellum, Orchid, Nocturne, System)+ val DeepSpaceLight = Skin(+ id = "deepspace_light",+ label = "Deep Space Light",+ tagline = "The original, in daylight. Opaque, green, no wallpaper.",+ brightness = Brightness.LIGHT,+ backdrop = Backdrop.NONE,+ ground = LightSurface,+ scheme = LightColorScheme+ )- const val DEFAULT_ID = "deepspace"+ val all = listOf(Aura, Vellum, Orchid, Nocturne, DeepSpaceDark, DeepSpaceLight)- fun byId(id: String): Skin = all.firstOrNull { it.id == id } ?: DeepSpace+ const val DEFAULT_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- }+ fun byId(id: String): Skin = all.firstOrNull { it.id == id } ?: DeepSpaceDark}diff --git a/app/src/main/java/com/gotcha/ui/theme/Theme.kt b/app/src/main/java/com/gotcha/ui/theme/Theme.ktindex 8c8fe20..c6fe6c6 100644--- a/app/src/main/java/com/gotcha/ui/theme/Theme.kt+++ b/app/src/main/java/com/gotcha/ui/theme/Theme.kt@@ -1,18 +1,12 @@package com.gotcha.ui.themeimport android.app.Activity-import android.os.Build-import androidx.compose.foundation.isSystemInDarkTheme-import androidx.compose.material3.ColorSchemeimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.darkColorScheme-import androidx.compose.material3.dynamicDarkColorScheme-import androidx.compose.material3.dynamicLightColorSchemeimport androidx.compose.material3.lightColorSchemeimport androidx.compose.runtime.Composableimport androidx.compose.runtime.CompositionLocalProviderimport androidx.compose.runtime.SideEffect-import androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.platform.LocalViewimport androidx.core.view.WindowCompat@@ -45,37 +39,33 @@ internal val LightColorScheme = lightColorScheme()/**- * @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 frostPercent scales the skin's frost and scrim, 0–100.- * @param reduceTransparency our own accessibility switch — Android has no+ * @param skinId which entry of [Skins] the user picked. A skin is the whole+ * theme: there is no light/dark switch on top of it, because a skin that has+ * to work in both is two designs sharing a name. Deep Space ships as two.+ * @param frostPercent scales the skin's frost and scrim, 0-100.+ * @param reduceTransparency our own accessibility switch - Android has no* system-level equivalent, so this is the only way to ask for solid panels.*/@Composablefun GotchaTheme(- darkTheme: Boolean = isSystemInDarkTheme(),skinId: String = Skins.DEFAULT_ID,- matchSystemBrightness: Boolean = true,- reduceTransparency: Boolean = false,frostPercent: Int = 100,+ reduceTransparency: Boolean = false,content: @Composable () -> Unit) {val tier = rememberGlassTier(reduceTransparency)- val picked = Skins.resolve(skinId, matchSystemBrightness, darkTheme)- .withFrost(frostPercent)+ val picked = Skins.byId(skinId).withFrost(frostPercent)// 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)+ SystemBars(skin)CompositionLocalProvider(LocalSkin provides skin,LocalGlassTier provides tier) {MaterialTheme(- colorScheme = colorScheme,+ colorScheme = skin.scheme,typography = Typography,content = content)@@ -83,34 +73,15 @@ fun GotchaTheme(}/**- * 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.+ * Status- and navigation-bar icons follow the skin's own ground. Reading the+ * device's dark-mode flag here is how the clock disappears on Orchid, which is+ * a dark violet ground whatever the system thinks the time of day is.*/@Composable-private fun SystemBars(skin: Skin, darkTheme: Boolean) {+private fun SystemBars(skin: Skin) {val view = LocalView.currentif (view.isInEditMode) return- val lightBars = if (skin.brightness == Brightness.ADAPTIVE) {- !darkTheme- } else {- skin.darkSystemBarIcons- }+ val lightBars = skin.darkSystemBarIconsSideEffect {val window = (view.context as? Activity)?.window ?: return@SideEffectWindowCompat.getInsetsController(window, view).apply {