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.
Address PR #42 review: safe overlay fallback, SYSTEM skin migration, pinned-host casing
Jalebi0eef3109a26c
diff --git a/app/src/main/java/com/gotcha/data/SettingsRepository.kt b/app/src/main/java/com/gotcha/data/SettingsRepository.ktindex 44e2ae6..cb6a8c4 100644--- a/app/src/main/java/com/gotcha/data/SettingsRepository.kt+++ b/app/src/main/java/com/gotcha/data/SettingsRepository.kt@@ -92,6 +92,9 @@ data class Settings(* 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.+ *+ * Keep this default in sync with [com.gotcha.ui.theme.Skins.DEFAULT_ID] — a+ * fresh install that never runs the migration reads it straight from here.*/val skinId: String = "vellum",val disabledSkills: Set<String> = emptySet(),@@ -282,15 +285,18 @@ data class Settings(* whole reason this exists. It runs once: [SettingsRepository] writes the* result, and every later load reads that instead.*- * A legacy light/dark choice keeps the matching Deep Space skin; an install- * that never chose a theme lands on the Vellum default.+ * A legacy light/dark choice keeps the matching Deep Space skin. SYSTEM was the+ * stored default, so it was the theme the app actually showed for most installs+ * — it stays on Deep Space Dark rather than silently flipping those users from+ * dark to light. Only an install that never wrote the field (a fresh install,+ * where the new skin system replaced `theme_mode` entirely) lands on Vellum.** @param legacyThemeMode the old `theme_mode` value, or null if never set.*/internal fun migrateSkinId(legacyThemeMode: String?): String =when (legacyThemeMode) {LEGACY_THEME_MODE_LIGHT -> SKIN_DEEP_SPACE_LIGHT- LEGACY_THEME_MODE_DARK -> SKIN_DEEP_SPACE_DARK+ LEGACY_THEME_MODE_DARK, LEGACY_THEME_MODE_SYSTEM -> SKIN_DEEP_SPACE_DARKelse -> SKIN_VELLUM}@@ -320,6 +326,7 @@ internal const val SKIN_DEEP_SPACE_LIGHT = "deepspace_light"internal const val SKIN_VELLUM = "vellum"private const val LEGACY_THEME_MODE_LIGHT = "LIGHT"private const val LEGACY_THEME_MODE_DARK = "DARK"+private const val LEGACY_THEME_MODE_SYSTEM = "SYSTEM"interface SettingsStore {fun load(): Settingsdiff --git a/app/src/main/java/com/gotcha/service/ScreenLensController.kt b/app/src/main/java/com/gotcha/service/ScreenLensController.ktindex 476a4fc..5e51920 100644--- a/app/src/main/java/com/gotcha/service/ScreenLensController.kt+++ b/app/src/main/java/com/gotcha/service/ScreenLensController.kt@@ -43,7 +43,7 @@ class ScreenLensController(private fun currentColors(): OverlaySkin = overlaySkin(appContext,runCatching { com.gotcha.data.SettingsRepository(appContext).load().skinId }- .getOrDefault(Skins.DEFAULT_ID)+ .getOrDefault(Skins.OVERLAY_FALLBACK_ID))private val windowManager = appContext.getSystemService(Context.WINDOW_SERVICE) as WindowManagerdiff --git a/app/src/main/java/com/gotcha/ui/AiConfigScreen.kt b/app/src/main/java/com/gotcha/ui/AiConfigScreen.ktindex d988f43..1860ac8 100644--- a/app/src/main/java/com/gotcha/ui/AiConfigScreen.kt+++ b/app/src/main/java/com/gotcha/ui/AiConfigScreen.kt@@ -150,11 +150,10 @@ fun AiConfigScreen(// ---- Provider / model guidance ----Text("Recommended setup:\n" +- "• Use the SAMOSA AI provider for the best LLM performance — it " +- "includes a built-in TTS that handles mixed-language text.\n" +- "• For high-quality single-language speech (e.g. English primarily), " +- "SAMOSA AI's TTS is the recommendation.\n" +- "• SAMOSA AI's STT is the recommended speech-to-text engine.",+ "• Use the SAMOSA AI provider for the best LLM performance.\n" ++ "• For speech, pick SAMOSA AI's TTS and STT on the Speech screen — " ++ "its TTS handles mixed-language text, and its STT is the recommended " ++ "transcription engine.",style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)diff --git a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.ktindex d0816fa..0b8a189 100644--- a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt@@ -188,7 +188,7 @@ class AssistiveBallOverlay(context: Context) {}private fun currentSkinId(): String =- runCatching { settingsRepository.load().skinId }.getOrDefault(Skins.DEFAULT_ID)+ runCatching { settingsRepository.load().skinId }.getOrDefault(Skins.OVERLAY_FALLBACK_ID)/** The active skin, translated for View code. */private fun palette(): OverlaySkin = overlaySkin(appContext, currentSkinId())diff --git a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt b/app/src/main/java/com/gotcha/ui/CallChatWindow.ktindex 9ca6260..5270ae8 100644--- a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt+++ b/app/src/main/java/com/gotcha/ui/CallChatWindow.kt@@ -1074,7 +1074,7 @@ class CallChatWindow(context: Context) {private fun readyTint(): Int = overlaySkin(appContext,runCatching { SettingsRepository(appContext).load().skinId }- .getOrDefault(Skins.DEFAULT_ID)+ .getOrDefault(Skins.OVERLAY_FALLBACK_ID)).accentprivate companion object {diff --git a/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt b/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.ktindex 6188f23..ab60333 100644--- a/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt@@ -70,7 +70,7 @@ class ConfirmationOverlay(context: Context) {val colors = overlaySkin(appContext,runCatching { SettingsRepository(appContext).load().skinId }- .getOrDefault(Skins.DEFAULT_ID)+ .getOrDefault(Skins.OVERLAY_FALLBACK_ID))val container = LinearLayout(appContext).apply {orientation = LinearLayout.VERTICALdiff --git a/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt b/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.ktindex 7e71da7..55a5eb9 100644--- a/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt+++ b/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt@@ -98,8 +98,8 @@ fun PersonalInfoScreen()Text("For more personalized results, keep this profile up to date — or just " +- "ask Gotcha to add things like your personal website, GitHub link, " +- "or CV (PDF), and it will record them here for you.",+ "ask Gotcha to record things like your personal website, GitHub link, " ++ "or CV (PDF) in your profile for you.",style = MaterialTheme.typography.bodySmall,color = MaterialTheme.colorScheme.onSurfaceVariant)diff --git a/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt b/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.ktindex 80ece78..f170aac 100644--- a/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt@@ -71,7 +71,7 @@ class ScreenCompanionPanelOverlay(private val context: Context) {private fun skin(): OverlaySkin = overlaySkin(appContext,runCatching { SettingsRepository(appContext).load().skinId }- .getOrDefault(Skins.DEFAULT_ID)+ .getOrDefault(Skins.OVERLAY_FALLBACK_ID))fun setVisibleForCapture(visible: Boolean) {diff --git a/app/src/main/java/com/gotcha/ui/ScreenReadFlashOverlay.kt b/app/src/main/java/com/gotcha/ui/ScreenReadFlashOverlay.ktindex 919596f..7747040 100644--- a/app/src/main/java/com/gotcha/ui/ScreenReadFlashOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/ScreenReadFlashOverlay.kt@@ -34,7 +34,7 @@ class ScreenReadFlashOverlay(context: Context) {val colors = overlaySkin(appContext,runCatching { SettingsRepository(appContext).load().skinId }- .getOrDefault(Skins.DEFAULT_ID)+ .getOrDefault(Skins.OVERLAY_FALLBACK_ID))val flash = ScreenReadFlashView(appContext, colors)try {diff --git a/app/src/main/java/com/gotcha/ui/SkillsScreen.kt b/app/src/main/java/com/gotcha/ui/SkillsScreen.ktindex fe9fec9..eebd0d7 100644--- a/app/src/main/java/com/gotcha/ui/SkillsScreen.kt+++ b/app/src/main/java/com/gotcha/ui/SkillsScreen.kt@@ -55,10 +55,16 @@ fun SkillsScreen() {val initial = remember { load() }var disabledSkills by remember { mutableStateOf(initial.disabledSkills) }- // The Samosa AI host is built in and cannot be removed; re-add it in case an- // older version let it slip out of the saved set.+ val pinnedHost = BuildConfig.SAMOSA_SKILL_HOST+ // The Samosa AI host is built in and cannot be removed. Normalize its casing+ // (an older version may have persisted a case-variant) and re-add it, so it+ // always renders as exactly one "Built-in" row with no orphan duplicate.var communitySkillHosts by remember {- mutableStateOf(initial.communitySkillHosts + BuildConfig.SAMOSA_SKILL_HOST)+ mutableStateOf(+ initial.communitySkillHosts+ .filterNot { it.equals(pinnedHost, ignoreCase = true) }+ .toSet() + pinnedHost+ )}var communitySkillUrl by remember { mutableStateOf("") }var communitySkillPasteJson by remember { mutableStateOf("") }@@ -78,8 +84,11 @@ fun SkillsScreen(/** This page's fields, copied onto [base]. */fun applySkills(base: Settings) = base.copy(disabledSkills = disabledSkills,- // The Samosa AI host is pinned; saving always keeps it in the allowlist.- communitySkillHosts = communitySkillHosts + BuildConfig.SAMOSA_SKILL_HOST+ // The Samosa AI host is pinned; saving always keeps exactly one+ // canonical-cased entry in the allowlist.+ communitySkillHosts = communitySkillHosts+ .filterNot { it.equals(pinnedHost, ignoreCase = true) }+ .toSet() + pinnedHost)SettingsScaffold(title = SettingsPage.SKILLS.title, onBack = onBack, overlay = overlay) {@@ -345,7 +354,6 @@ fun SkillsScreen("Default: ${BuildConfig.SAMOSA_SKILL_HOST}.",style = MaterialTheme.typography.bodySmall)- val pinnedHost = BuildConfig.SAMOSA_SKILL_HOSTcommunitySkillHosts.forEach { host ->Row(modifier = Modifier.fillMaxWidth(),diff --git a/app/src/main/java/com/gotcha/ui/theme/Skin.kt b/app/src/main/java/com/gotcha/ui/theme/Skin.ktindex aa631e8..af2f49e 100644--- a/app/src/main/java/com/gotcha/ui/theme/Skin.kt+++ b/app/src/main/java/com/gotcha/ui/theme/Skin.kt@@ -379,7 +379,27 @@ object Skins {val all = listOf(Aura, Vellum, Orchid, Nocturne, DeepSpaceDark, DeepSpaceLight)+ /**+ * The skin id a fresh install lands on, and the value the theme uses when+ * nothing is otherwise chosen.+ *+ * This is the *product* default, not the safety fallback. [byId] still+ * degrades unknown ids to [DeepSpaceDark], and overlays fall back to+ * [OVERLAY_FALLBACK_ID] when the stored skin cannot be read — the safe+ * opaque original, so an error path never pops a light panel over an+ * arbitrary screen.+ */const val DEFAULT_ID = "vellum"+ /**+ * The skin id an overlay paints when the stored skin cannot be read.+ *+ * Deliberately the opaque Deep Space original, not [DEFAULT_ID]: an overlay+ * floats over somebody else's app, and a light frosted panel appearing over+ * an arbitrary screen in an error path is worse than the safe opaque dark+ * one the app has always used.+ */+ val OVERLAY_FALLBACK_ID: String get() = DeepSpaceDark.id+fun byId(id: String): Skin = all.firstOrNull { it.id == id } ?: DeepSpaceDark}diff --git a/app/src/test/java/com/gotcha/data/SkinMigrationTest.kt b/app/src/test/java/com/gotcha/data/SkinMigrationTest.ktindex f64196f..343439e 100644--- a/app/src/test/java/com/gotcha/data/SkinMigrationTest.kt+++ b/app/src/test/java/com/gotcha/data/SkinMigrationTest.kt@@ -21,12 +21,22 @@ class SkinMigrationTest {}/**- * SYSTEM was the default, so the overwhelming majority of installs are on- * it and never chose a theme. Vellum is the new default landing place.+ * SYSTEM was the stored default, so it is the theme the app actually showed+ * for most installs. Flipping that population from dark to light silently+ * would be a regression — it stays on Deep Space Dark.*/@Test- fun `someone who never chose a theme lands on the Vellum default`() {- assertEquals(SKIN_VELLUM, migrateSkinId("SYSTEM"))+ fun `someone on SYSTEM keeps the dark Deep Space original`() {+ assertEquals(SKIN_DEEP_SPACE_DARK, migrateSkinId("SYSTEM"))+ }++ /**+ * A fresh install never writes `theme_mode` (the new skin system replaced+ * it entirely), so null is the only true "never chose" population. That is+ * who lands on the Vellum default.+ */+ @Test+ fun `a fresh install that never chose a theme lands on the Vellum default`() {assertEquals(SKIN_VELLUM, migrateSkinId(null))}diff --git a/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.kt b/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.ktindex eb1a159..ca9c6d7 100644--- a/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.kt+++ b/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.kt@@ -73,6 +73,24 @@ class OverlaySkinTest {assertEquals(overlaySkin(context, Skins.DeepSpaceDark.id).accent, fallback.accent)}+ /**+ * When the stored skin cannot be read (e.g. encrypted-prefs corruption), the+ * overlays paint the safe opaque Deep Space original — not the light Vellum+ * product default. A light frosted panel popping up over an arbitrary screen+ * in an error path would be a regression, so the split is pinned here.+ */+ @Test+ fun `the overlay load-failure fallback is the opaque Deep Space original, not the light default`() {+ assertEquals(Skins.DeepSpaceDark.id, Skins.OVERLAY_FALLBACK_ID)+ assertTrue(+ "the load-failure fallback must not drift onto the light ${Skins.DEFAULT_ID} default",+ Skins.OVERLAY_FALLBACK_ID != Skins.DEFAULT_ID+ )+ val fallback = overlaySkin(context, Skins.OVERLAY_FALLBACK_ID)+ assertEquals(255, Color.alpha(fallback.surface))+ assertEquals(overlaySkin(context, Skins.DeepSpaceDark.id).surface, fallback.surface)+ }+/*** Depth over another app's screen comes from the edge, not from blur — so* the edge has to actually be visible against the surface it sits on. Which