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): move Notifications onto its own page, last on the list

Durganshu Mishra2360eb9bcd4b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da11618..b616dd6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,21 @@ for that feature.
Personal Info fields tipped the accumulated count past detekt's complexity
ceiling.
+### Changed — Notifications is a page like everything else
+
+Notifications sat at the top of the settings home list, above every category
+row, which put the least-used setting in the place the eye lands first.
+
+- **ui/NotificationsScreen.kt** (new): the vibration and chime switches move to
+ a page of their own, last in `SettingsPage` and so last on the home list.
+ Appearance stays inline — one three-way control, applied on touch.
+- The page keeps its apply-on-touch behaviour and has no Save button, which is
+ the point: switching one on plays it once. A preview you had to save first
+ would be feedback about a setting you had already committed to.
+- **SettingsToggleRow** gained `switchTestTag`, so the notification tags stay on
+ the `Switch` rather than moving to the row around it — a tag on the row finds
+ a node that isn't toggleable, and a test clicking it would no-op in silence.
+
### Changed — Settings is now a list of pages, not one long scroll
Settings was a single scrolling screen with five accordions, one of which
@@ -42,8 +57,9 @@ the system Settings app: a home list of categories, each opening its own page,
Back returning to the list.
- **ui/SettingsScreen.kt**: reduced from 1930 lines to a nav host over the new
- `SettingsPage` enum plus the home list. Appearance and Notifications stay on the
- home list — two controls each, applied on touch. The open page is
+ `SettingsPage` enum plus the home list. Appearance and Notifications stayed on
+ the home list at this point — two controls each, applied on touch; Notifications
+ moved to a page of its own afterwards (see above). The open page is
`rememberSaveable`, so a rotation doesn't return the user to the list.
- **ui/SettingsCommon.kt** (new): `SettingsPage` (title, summary and test tag per
category, so a new category is one enum entry), `SettingsScaffold`,
diff --git a/app/src/main/java/com/gotcha/ui/NotificationsScreen.kt b/app/src/main/java/com/gotcha/ui/NotificationsScreen.kt
new file mode 100644
index 0000000..c9bf2e8
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/NotificationsScreen.kt
@@ -0,0 +1,62 @@
+package com.gotcha.ui
+
+import androidx.compose.material3.MaterialTheme
+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.platform.LocalContext
+import com.gotcha.audio.CompletionFeedback
+import com.gotcha.data.Settings
+
+/**
+ * The Notifications page: what the phone does the moment a reply arrives.
+ *
+ * The only page with no Save button, and deliberately so — switching one on
+ * plays it once, which is the whole point. A preview that had to be saved first
+ * would be feedback about a setting the user had already committed to.
+ */
+@Composable
+fun NotificationsScreen(
+ load: () -> Settings,
+ onSave: ((Settings) -> Settings) -> Unit,
+ onBack: () -> Unit
+) {
+ val initial = remember { load() }
+ var notifyVibration by remember { mutableStateOf(initial.notifyVibrationEnabled) }
+ var notifyChime by remember { mutableStateOf(initial.notifyChimeEnabled) }
+
+ val overlay = rememberSettingsOverlayState()
+ val localContext = LocalContext.current
+
+ SettingsScaffold(title = SettingsPage.NOTIFICATIONS.title, onBack = onBack, overlay = overlay) {
+ Text(
+ "Played as soon as a reply arrives. Turn both off for no alert.",
+ style = MaterialTheme.typography.bodySmall
+ )
+ SettingsToggleRow(
+ label = "Vibration",
+ checked = notifyVibration,
+ onCheckedChange = {
+ notifyVibration = it
+ onSave { s -> s.copy(notifyVibrationEnabled = it) }
+ if (it) CompletionFeedback.replyArrived(localContext, vibrate = true, chime = false)
+ },
+ isLarge = true,
+ switchTestTag = "settings_notify_vibration"
+ )
+ SettingsToggleRow(
+ label = "Chime",
+ checked = notifyChime,
+ onCheckedChange = {
+ notifyChime = it
+ onSave { s -> s.copy(notifyChimeEnabled = it) }
+ if (it) CompletionFeedback.replyArrived(localContext, vibrate = false, chime = true)
+ },
+ isLarge = true,
+ switchTestTag = "settings_notify_chime"
+ )
+ }
+}
diff --git a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
index 034fc23..bdf34e0 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
@@ -83,6 +83,11 @@ enum class SettingsPage(val title: String, val summary: String, val testTag: Str
"Proactive Assistance",
"Offers, OTP detection, what may be scanned",
"settings_proactive_row"
+ ),
+ NOTIFICATIONS(
+ "Notifications",
+ "How you're alerted when a reply arrives",
+ "settings_notifications_row"
)
}
@@ -279,13 +284,20 @@ fun SamosaAuthSection(
}
}
-/** A label with a trailing switch — the settings screens' standard boolean row. */
+/**
+ * A label with a trailing switch — the settings screens' standard boolean row.
+ *
+ * [switchTestTag] tags the `Switch` rather than the row, so a test that clicks
+ * it actually toggles something; a tag on the row would find a node that isn't
+ * toggleable and no-op silently.
+ */
@Composable
fun SettingsToggleRow(
label: String,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
isLarge: Boolean = false,
+ switchTestTag: String? = null,
modifier: Modifier = Modifier
) {
Row(
@@ -297,7 +309,11 @@ fun SettingsToggleRow(
label,
style = if (isLarge) MaterialTheme.typography.bodyLarge else MaterialTheme.typography.bodyMedium
)
- Switch(checked = checked, onCheckedChange = onCheckedChange)
+ Switch(
+ checked = checked,
+ onCheckedChange = onCheckedChange,
+ modifier = if (switchTestTag != null) Modifier.testTag(switchTestTag) else Modifier
+ )
}
}
diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
index 5568af3..af7b3eb 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt
@@ -1,8 +1,6 @@
package com.gotcha.ui
import androidx.activity.compose.BackHandler
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
@@ -10,7 +8,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SegmentedButton
import androidx.compose.material3.SegmentedButtonDefaults
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
-import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -18,14 +15,11 @@ 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.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.LocalContext
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.audio.CompletionFeedback
import com.gotcha.data.Settings
import com.gotcha.data.ThemeMode
import com.gotcha.i18n.Language
@@ -33,9 +27,9 @@ 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
- * and Notifications stay on the home list — two controls each, applied the
- * moment they are touched, so a page of their own would be emptier than the row
- * that opened it.
+ * 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.
*
* Every page saves through [onSave]'s mutator, writing only the fields it owns.
*/
@@ -130,9 +124,13 @@ fun SettingsScreen(
onSave = onSave,
onBack = backToHome
)
- null -> SettingsHome(
+ SettingsPage.NOTIFICATIONS -> NotificationsScreen(
load = load,
onSave = onSave,
+ onBack = backToHome
+ )
+ null -> SettingsHome(
+ load = load,
onBack = onBack,
onOpenPage = { page = it },
onThemeChange = onThemeChange
@@ -140,23 +138,19 @@ fun SettingsScreen(
}
}
-/** The settings home list: the immediate toggles, then a row per sub-page. */
+/** The settings home list: the Appearance control, then a row per sub-page. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun SettingsHome(
load: () -> Settings,
- onSave: ((Settings) -> Settings) -> Unit,
onBack: () -> Unit,
onOpenPage: (SettingsPage) -> Unit,
onThemeChange: (ThemeMode) -> Unit
) {
val initial = remember { load() }
- var notifyVibration by remember { mutableStateOf(initial.notifyVibrationEnabled) }
- var notifyChime by remember { mutableStateOf(initial.notifyChimeEnabled) }
var themeMode by remember { mutableStateOf(initial.themeMode) }
val overlay = rememberSettingsOverlayState()
- val localContext = LocalContext.current
SettingsScaffold(title = "Settings", onBack = onBack, overlay = overlay) {
// ---- Appearance (applies immediately) ----
@@ -183,52 +177,6 @@ private fun SettingsHome(
HorizontalDivider(thickness = 1.dp)
- // ---- Notifications (applies immediately) ----
- Text(
- "Notifications",
- style = MaterialTheme.typography.titleMedium,
- fontWeight = FontWeight.Bold
- )
- Text(
- "Played as soon as a reply arrives. Turn both off for no alert.",
- style = MaterialTheme.typography.bodySmall
- )
- // Switching one on plays it once, so the user knows what to expect.
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text("Vibration", style = MaterialTheme.typography.bodyLarge)
- Switch(
- checked = notifyVibration,
- onCheckedChange = {
- notifyVibration = it
- onSave { s -> s.copy(notifyVibrationEnabled = it) }
- if (it) CompletionFeedback.replyArrived(localContext, vibrate = true, chime = false)
- },
- modifier = Modifier.testTag("settings_notify_vibration")
- )
- }
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- Text("Chime", style = MaterialTheme.typography.bodyLarge)
- Switch(
- checked = notifyChime,
- onCheckedChange = {
- notifyChime = it
- onSave { s -> s.copy(notifyChimeEnabled = it) }
- if (it) CompletionFeedback.replyArrived(localContext, vibrate = false, chime = true)
- },
- modifier = Modifier.testTag("settings_notify_chime")
- )
- }
-
- HorizontalDivider(thickness = 1.dp)
-
// ---- One row per sub-page ----
SettingsPage.entries.forEachIndexed { index, entry ->
if (index > 0) HorizontalDivider(thickness = 1.dp)