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(settings): search the settings list

Durganshu8bf5c9a11cdf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75c5481..73ab4b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,16 @@ All notable changes to Gotcha are documented here.
## [Unreleased]
### Added
+- **Search the settings.** Fifteen settings pages hold well over a hundred
+ controls between them, and finding one meant scrolling the list and guessing
+ which page owned it — "wake word" is under Assistive Ball, "API key" under AI
+ › AI Configuration. A search field now sits pinned above the settings list:
+ type what the control is called and the list narrows to the pages that hold
+ it, matching titles, summaries and the everyday words for the fields inside
+ ("read aloud", "dark mode", "otp", "accessibility"). Pages that live inside a
+ hub — Speech, AI Configuration, Legal — show up too, named with the hub they
+ sit in and opened in one tap, which the list itself can't do. Clearing the
+ field brings the whole list back.
- **Voice and language pickers name the language.** The Speech page listed raw
codes — `hi`, `en-us`, `af_heart` — with nothing saying which language each
one is. Transcription language entries now read like `hi — Hindi`, the field
diff --git a/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt b/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt
index 0d2af09..0d5639d 100644
--- a/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt
+++ b/app/src/androidTest/java/com/gotcha/SettingsFlowTest.kt
@@ -169,6 +169,73 @@ class SettingsFlowTest {
composeRule.onNodeWithText("TTS Provider").assertExists()
}
+ @Test
+ fun settingsSearch_findsAPageByAControlInsideIt() {
+ val context = ApplicationProvider.getApplicationContext<android.content.Context>()
+ TestSeed.seedUnconfigured(context)
+
+ scenario = ActivityScenario.launch(MainActivity::class.java)
+ composeRule.waitForIdle()
+
+ // First run opens on AI Configuration inside the AI hub — two Backs to the list.
+ composeRule.onNodeWithTag("settings_back").performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_back").performClick()
+ composeRule.waitForIdle()
+
+ // "wake word" is a control inside the ball's page, not a row on the list.
+ composeRule.onNodeWithTag("settings_search").performTextReplacement("wake word")
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_assistive_ball_row").assertExists()
+ composeRule.onNodeWithTag("settings_termux_row").assertDoesNotExist()
+ // The tour and feedback rows are not pages, so they drop out of a search.
+ composeRule.onNodeWithTag("settings_feature_tour_row").assertDoesNotExist()
+
+ // Nothing matching says so rather than showing an empty list.
+ composeRule.onNodeWithTag("settings_search").performTextReplacement("qwertyuiop")
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_search_empty").assertExists()
+ composeRule.onNodeWithTag("settings_assistive_ball_row").assertDoesNotExist()
+
+ // Clearing restores the full list, tour row included.
+ composeRule.onNodeWithTag("settings_search_clear").performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_search_empty").assertDoesNotExist()
+ composeRule.onNodeWithTag("settings_feature_tour_row").performScrollTo().assertExists()
+ composeRule.onNodeWithTag("settings_termux_row").performScrollTo().assertExists()
+ }
+
+ @Test
+ fun settingsSearch_opensAPageNestedInsideAHub() {
+ val context = ApplicationProvider.getApplicationContext<android.content.Context>()
+ TestSeed.seedUnconfigured(context)
+
+ scenario = ActivityScenario.launch(MainActivity::class.java)
+ composeRule.waitForIdle()
+
+ composeRule.onNodeWithTag("settings_back").performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_back").performClick()
+ composeRule.waitForIdle()
+
+ // Speech lives inside the AI hub, so the home list never shows this row —
+ // the search result is the only way to reach it in one tap.
+ composeRule.onNodeWithTag("settings_search").performTextReplacement("read aloud")
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_speech_row").performScrollTo().performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithText("TTS Provider").assertExists()
+
+ // Back from a nested page lands on its hub, and the query is gone: the
+ // list that comes back is the whole list.
+ composeRule.onNodeWithTag("settings_back").performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_ai_config_row").assertExists()
+ composeRule.onNodeWithTag("settings_back").performClick()
+ composeRule.waitForIdle()
+ composeRule.onNodeWithTag("settings_termux_row").performScrollTo().assertExists()
+ }
+
@Test
fun aiConfig_keepsTheAdvancedKnobsCollapsedUntilAsked() {
val context = ApplicationProvider.getApplicationContext<android.content.Context>()
diff --git a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
index db41318..e243335 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
@@ -195,7 +195,9 @@ enum class SettingsPage(
fun SettingsNavRow(
page: SettingsPage,
onClick: () -> Unit,
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
+ /** Overrides the row label. Search results pass the "hub › page" path. */
+ title: String = page.title
) {
Row(
modifier = modifier
@@ -206,7 +208,7 @@ fun SettingsNavRow(
) {
Column(modifier = Modifier.weight(1f)) {
Text(
- text = page.title,
+ text = title,
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Medium
)
@@ -266,6 +268,10 @@ fun rememberSettingsOverlayState(): SettingsOverlayState {
/**
* The frame every settings page shares: a titled top bar with a back action, a
* scrolling content column, and the overlay anchored on top of it.
+ *
+ * [header] is the one thing that sits outside the scrolling column, pinned
+ * between the top bar and the content — the settings home list puts its search
+ * field there so it stays reachable however far the list has scrolled.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -273,6 +279,7 @@ fun SettingsScaffold(
title: String,
onBack: () -> Unit,
overlay: SettingsOverlayState,
+ header: (@Composable () -> Unit)? = null,
content: @Composable ColumnScope.() -> Unit
) {
Scaffold(
@@ -294,14 +301,20 @@ fun SettingsScaffold(
}
) { padding ->
Box(modifier = Modifier.fillMaxSize().padding(padding)) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .padding(16.dp)
- .verticalScroll(rememberScrollState()),
- verticalArrangement = Arrangement.spacedBy(12.dp),
- content = content
- )
+ Column(modifier = Modifier.fillMaxSize()) {
+ header?.let {
+ Box(modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) { it() }
+ }
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .weight(1f)
+ .padding(16.dp)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(12.dp),
+ content = content
+ )
+ }
// Centered rather than bottom-aligned: under the keyboard area BottomCenter
// reads as a stray toast instead of feedback attached to the field that
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index e6205ee..9e6b3b3 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -3,13 +3,24 @@ package com.gotcha.ui
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Close
+import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.saveable.rememberSaveable
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
@@ -210,7 +221,15 @@ fun SettingsScreen(
}
}
-/** The settings home list: one row per sub-page, plus the way back into the tour. */
+/**
+ * The settings home list: one row per sub-page, plus the way back into the tour.
+ *
+ * With 15 pages between them holding well over a hundred controls, the list on
+ * its own answers "where is the setting for X?" with a scroll and a guess, so a
+ * search field sits pinned above it. A query replaces the list with matching
+ * pages — including the ones nested inside a hub, which the list never shows —
+ * and an empty query leaves the list exactly as it was.
+ */
@Composable
private fun SettingsHome(
onBack: () -> Unit,
@@ -219,33 +238,119 @@ private fun SettingsHome(
onSendFeedback: () -> Unit
) {
val overlay = rememberSettingsOverlayState()
+ var query by rememberSaveable { mutableStateOf("") }
- SettingsScaffold(title = "Settings", onBack = onBack, overlay = overlay) {
- SettingsPage.topLevel.forEach { entry ->
- HorizontalDivider(thickness = 1.dp)
- SettingsNavRow(
- page = entry,
- onClick = { onOpenPage(entry) },
- modifier = Modifier
- .testTag(entry.testTag)
- .then(entry.tourAnchorModifier())
+ // Opening a page ends the search: coming back to a list still filtered by a
+ // query typed minutes ago reads as a list that has lost most of its rows.
+ val openPage = { page: SettingsPage ->
+ query = ""
+ onOpenPage(page)
+ }
+
+ SettingsScaffold(
+ title = "Settings",
+ onBack = onBack,
+ overlay = overlay,
+ header = { SettingsSearchField(query = query, onQueryChange = { query = it }) }
+ ) {
+ if (query.isBlank()) {
+ SettingsHomeRows(
+ onOpenPage = openPage,
+ onStartTour = onStartTour,
+ onSendFeedback = onSendFeedback
)
- // Re-entry into the guided setup sits just above About, so the menu
- // ends on the two rows a returning user is least likely to need.
- if (entry == SettingsPage.NOTIFICATIONS) {
+ } else {
+ SettingsSearchResults(query = query, onOpenPage = openPage)
+ }
+ }
+}
+
+/** The search field pinned above the home list. */
+@Composable
+private fun SettingsSearchField(query: String, onQueryChange: (String) -> Unit) {
+ OutlinedTextField(
+ value = query,
+ onValueChange = onQueryChange,
+ modifier = Modifier
+ .fillMaxWidth()
+ .testTag("settings_search"),
+ singleLine = true,
+ placeholder = { Text("Search settings") },
+ leadingIcon = { Icon(Icons.Filled.Search, contentDescription = null) },
+ trailingIcon = {
+ if (query.isNotEmpty()) {
+ IconButton(
+ onClick = { onQueryChange("") },
+ modifier = Modifier.testTag("settings_search_clear")
+ ) { Icon(Icons.Filled.Close, contentDescription = "Clear search") }
+ }
+ }
+ )
+}
+
+/** The unfiltered list: every top-level page, then the tour and feedback rows. */
+@Composable
+private fun ColumnScope.SettingsHomeRows(
+ onOpenPage: (SettingsPage) -> Unit,
+ onStartTour: () -> Unit,
+ onSendFeedback: () -> Unit
+) {
+ SettingsPage.topLevel.forEach { entry ->
+ HorizontalDivider(thickness = 1.dp)
+ SettingsNavRow(
+ page = entry,
+ onClick = { onOpenPage(entry) },
+ modifier = Modifier
+ .testTag(entry.testTag)
+ .then(entry.tourAnchorModifier())
+ )
+ // Re-entry into the guided setup sits just above About, so the menu
+ // ends on the two rows a returning user is least likely to need.
+ if (entry == SettingsPage.NOTIFICATIONS) {
+ HorizontalDivider(thickness = 1.dp)
+ FeatureTourRow(onClick = onStartTour)
+ // Feedback is the same shape; only rendered when the form URL is
+ // configured at build time (gitignored FEEDBACK_* config).
+ if (FeedbackChannel.isConfigured()) {
HorizontalDivider(thickness = 1.dp)
- FeatureTourRow(onClick = onStartTour)
- // Feedback is the same shape; only rendered when the form URL is
- // configured at build time (gitignored FEEDBACK_* config).
- if (FeedbackChannel.isConfigured()) {
- HorizontalDivider(thickness = 1.dp)
- FeedbackRow(onClick = onSendFeedback)
- }
+ FeedbackRow(onClick = onSendFeedback)
}
}
}
}
+/**
+ * Pages matching the query. Rows keep their home-list [SettingsPage.testTag] so
+ * a result is the same row by every name the tour and the tests know it by; a
+ * nested page shows its hub in the label instead of a tour anchor it would be
+ * spotlighting in the wrong place.
+ */
+@Composable
+private fun SettingsSearchResults(query: String, onOpenPage: (SettingsPage) -> Unit) {
+ val results = filterSettings(query)
+ if (results.isEmpty()) {
+ Text(
+ text = "No settings match “$query”",
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(vertical = 24.dp)
+ .testTag("settings_search_empty")
+ )
+ return
+ }
+ results.forEach { result ->
+ HorizontalDivider(thickness = 1.dp)
+ SettingsNavRow(
+ page = result.page,
+ onClick = { onOpenPage(result.page) },
+ modifier = Modifier.testTag(result.page.testTag),
+ title = result.breadcrumb
+ )
+ }
+}
+
/** The anchor the tour spotlights for this row, when it points at one at all. */
@Composable
private fun SettingsPage.tourAnchorModifier(): Modifier = when (this) {
diff --git a/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt b/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt
new file mode 100644
index 0000000..b7233af
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/SettingsSearchEntry.kt
@@ -0,0 +1,150 @@
+package com.gotcha.ui
+
+/**
+ * The search index behind the field at the top of the settings home list.
+ *
+ * A page's own title and summary are only half of what people type: nobody
+ * looks for "Assistive Ball and Wake Word" by its title — they type "wake
+ * word", "api key" or "read aloud", naming a *control* somewhere inside a page.
+ * [keywordsFor] carries those aliases, so the index answers for fields that have
+ * no row of their own on the home list.
+ *
+ * Kept free of Compose so the matching is a plain unit test.
+ */
+
+/** One searchable settings page: the page itself plus the words that find it. */
+data class SettingsSearchEntry(
+ val page: SettingsPage,
+ val keywords: List<String>
+) {
+ /**
+ * How the result names itself. A page inside a hub says which hub it is in —
+ * "AI › Speech (TTS / STT)" — because the home list never shows that row, so
+ * the result is the only place the path can be learned.
+ */
+ val breadcrumb: String
+ get() = page.parentPage()?.let { "${it.title} › ${page.title}" } ?: page.title
+
+ /** Everything this entry matches against, lowercased once at construction. */
+ private val haystack: String =
+ (listOf(page.title, page.summary) + keywords).joinToString(" ").lowercase()
+
+ internal fun matches(token: String): Boolean = haystack.contains(token)
+}
+
+/**
+ * Keyword lists read as prose here — one comma-separated blob per page — because
+ * a quoted-string list of forty aliases is a wall nobody rereads.
+ */
+private fun words(csv: String): List<String> =
+ csv.split(',').map { it.trim() }.filter { it.isNotEmpty() }
+
+/**
+ * Aliases for the controls a page owns, in the words people actually type.
+ *
+ * Exhaustive on purpose: a new [SettingsPage] fails to compile here rather than
+ * shipping a page that search can't find. An empty list is a fine answer when
+ * the title and summary already say everything.
+ */
+@Suppress("CyclomaticComplexMethod")
+private fun keywordsFor(page: SettingsPage): List<String> = when (page) {
+ SettingsPage.PERSONAL_INFO -> words(
+ """
+ name, currency, reply style, tone, about me, profile
+ """
+ )
+ SettingsPage.LANGUAGE -> words(
+ """
+ app language, voice language, reply language, translate, locale
+ """
+ )
+ SettingsPage.AI -> words(
+ """
+ assistant, llm, brain, provider
+ """
+ )
+ SettingsPage.AI_CONFIG -> words(
+ """
+ api key, base url, endpoint, model, provider, max tool rounds,
+ agent limits, timeout, samosa sign in, sign in, login, credits, openai,
+ temperature
+ """
+ )
+ SettingsPage.SPEECH -> words(
+ """
+ tts, stt, voice, transcription, transcribe, read aloud, read replies,
+ speak, microphone, kokoro, whisper
+ """
+ )
+ SettingsPage.PERMISSIONS -> words(
+ """
+ accessibility, notification access, device admin, root, health connect,
+ camera, location, contacts, sms, storage, display over other apps,
+ overlay, grant, allow
+ """
+ )
+ SettingsPage.TERMUX -> words(
+ """
+ linux, shell, command, terminal, ffmpeg, package, bash
+ """
+ )
+ SettingsPage.SKILLS -> words(
+ """
+ plugin, skill, community, import, mcp
+ """
+ )
+ SettingsPage.PROACTIVE -> words(
+ """
+ otp, screen scanning, offers, suggestions, clipboard, privacy
+ """
+ )
+ SettingsPage.ASSISTIVE_BALL -> words(
+ """
+ wake word, hey gotcha, floating ball, bubble, overlay, hands free,
+ hands-free, always listening, sensitivity
+ """
+ )
+ SettingsPage.APPEARANCE -> words(
+ """
+ theme, dark mode, light mode, wallpaper, skin, font, colors
+ """
+ )
+ SettingsPage.NOTIFICATIONS -> words(
+ """
+ alerts, sound, vibrate, server messages, announcements, sync
+ """
+ )
+ SettingsPage.ABOUT -> words(
+ """
+ version, contact, support, company, samosa
+ """
+ )
+ SettingsPage.ABOUT_SAMOSA -> words(
+ """
+ mission, products, pricing, developers, samosa ai
+ """
+ )
+ SettingsPage.LEGAL -> words(
+ """
+ terms, privacy policy, disclaimer, data retention, licence, license
+ """
+ )
+}
+
+/** Every settings page, in home-list declaration order. */
+val settingsSearchIndex: List<SettingsSearchEntry> =
+ SettingsPage.entries.map { SettingsSearchEntry(it, keywordsFor(it)) }
+
+/**
+ * Pages matching [query], case-insensitively, over title, summary and keywords.
+ *
+ * Every whitespace-separated word of the query has to match somewhere in the
+ * entry, so word order doesn't matter ("word wake" finds the ball) and each
+ * extra word narrows rather than widens the result. A blank query matches
+ * nothing: the caller shows the normal, unfiltered list instead.
+ */
+fun filterSettings(query: String): List<SettingsSearchEntry> {
+ val tokens = query.lowercase().split(' ', '\t', '\n').filter { it.isNotBlank() }
+ if (tokens.isEmpty()) return emptyList()
+ return settingsSearchIndex.filter { entry -> tokens.all { entry.matches(it) } }
+}
diff --git a/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt b/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt
new file mode 100644
index 0000000..ee7f15b
--- /dev/null
+++ b/app/src/test/java/com/gotcha/ui/SettingsSearchEntryTest.kt
@@ -0,0 +1,85 @@
+package com.gotcha.ui
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+/**
+ * The matching behind the settings search field. The cases named in issue #86
+ * are the point of the feature: each one is a control with no row of its own on
+ * the home list, found by the word someone would actually type for it.
+ */
+class SettingsSearchEntryTest {
+
+ private fun pagesFor(query: String) = filterSettings(query).map { it.page }
+
+ @Test
+ fun keywordsFindThePageOwningTheControl() {
+ assertTrue(SettingsPage.SPEECH in pagesFor("voice"))
+ assertTrue(SettingsPage.ASSISTIVE_BALL in pagesFor("wake word"))
+ assertTrue(SettingsPage.AI_CONFIG in pagesFor("api key"))
+ assertTrue(SettingsPage.SPEECH in pagesFor("read aloud"))
+ assertTrue(SettingsPage.PERMISSIONS in pagesFor("accessibility"))
+ }
+
+ @Test
+ fun matchingIsCaseInsensitive() {
+ assertEquals(pagesFor("api key"), pagesFor("API KEY"))
+ assertEquals(pagesFor("termux"), pagesFor("TeRmUx"))
+ }
+
+ @Test
+ fun wordOrderDoesNotMatter() {
+ assertEquals(pagesFor("wake word"), pagesFor("word wake"))
+ }
+
+ @Test
+ fun titlesAndSummariesMatchToo() {
+ assertTrue(SettingsPage.NOTIFICATIONS in pagesFor("Notifications"))
+ // "currency" is only in the Personal Info summary, not its keywords.
+ assertTrue(SettingsPage.PERSONAL_INFO in pagesFor("currency"))
+ }
+
+ @Test
+ fun eachExtraWordNarrowsTheResults() {
+ val voice = pagesFor("voice")
+ val voiceLanguage = pagesFor("voice language")
+ assertTrue(voiceLanguage.size <= voice.size)
+ assertTrue(SettingsPage.LANGUAGE in voiceLanguage)
+ }
+
+ @Test
+ fun blankQueryMatchesNothing() {
+ assertTrue(filterSettings("").isEmpty())
+ assertTrue(filterSettings(" ").isEmpty())
+ }
+
+ @Test
+ fun nonsenseQueryMatchesNothing() {
+ assertTrue(filterSettings("qwertyuiop").isEmpty())
+ }
+
+ @Test
+ fun everyPageIsSearchableByItsOwnTitle() {
+ SettingsPage.entries.forEach { page ->
+ assertTrue(
+ "${page.title} cannot be found by its own title",
+ page in pagesFor(page.title)
+ )
+ }
+ }
+
+ @Test
+ fun indexCoversEveryPageExactlyOnce() {
+ assertEquals(SettingsPage.entries.toList(), settingsSearchIndex.map { it.page })
+ }
+
+ @Test
+ fun nestedPagesNameTheirHub() {
+ val speech = settingsSearchIndex.first { it.page == SettingsPage.SPEECH }
+ assertEquals("AI › ${SettingsPage.SPEECH.title}", speech.breadcrumb)
+
+ val termux = settingsSearchIndex.first { it.page == SettingsPage.TERMUX }
+ assertEquals(SettingsPage.TERMUX.title, termux.breadcrumb)
+ }
+}