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.

refactor: improve code readability and documentation in tour-related components

Durganshu Mishraf727d5c946de
diff --git a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
index cf1c4e5..3c4f3f6 100644
--- a/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
+++ b/app/src/main/java/com/gotcha/ui/SettingsCommon.kt
@@ -315,7 +315,9 @@ fun SamosaAuthSection(
Button(
onClick = onSignIn,
enabled = !busy,
- modifier = Modifier.fillMaxWidth().then(signInModifier)
+ modifier = Modifier
+ .fillMaxWidth()
+ .then(signInModifier)
) { Text(if (busy) "Signing in…" else "Sign in with Google") }
}
}
diff --git a/app/src/main/java/com/gotcha/ui/tour/TourAnchors.kt b/app/src/main/java/com/gotcha/ui/tour/TourAnchors.kt
index 7ea6ffe..fd5109b 100644
--- a/app/src/main/java/com/gotcha/ui/tour/TourAnchors.kt
+++ b/app/src/main/java/com/gotcha/ui/tour/TourAnchors.kt
@@ -53,14 +53,15 @@ class TourAnchors {
private val handles = mutableStateMapOf<TourAnchor, AnchorHandle>()
/**
- * The visible bounds of [anchor], or null when it is not on screen.
+ * The bounds of [anchor] in root coordinates, or null when nothing is registered.
*
- * Deliberately the *clipped* bounds. A control scrolled out of its list
- * still exists and still reports a position, and treating that as a
- * spotlight punches the hole somewhere the user cannot see while blocking
- * every part of the screen they can — which is precisely the trap the tour
- * must never spring. Null here means "not visible", and the overlay asks
- * [bringIntoView] to fix that rather than drawing a hole into nothing.
+ * These are [androidx.compose.ui.layout.boundsInRoot] — unclipped. A control
+ * scrolled out of its list still exists and still reports a position here,
+ * so on its own this would let a spotlight punch a hole somewhere the user
+ * cannot see while blocking every part of the screen they can — precisely
+ * the trap the tour must never spring. [TourOverlay] avoids that by calling
+ * [bringIntoView] before it trusts these bounds, scrolling the anchor into
+ * view rather than drawing a hole into nothing.
*/
operator fun get(anchor: TourAnchor): Rect? =
handles[anchor]?.bounds?.takeIf { !it.isEmpty }
diff --git a/app/src/main/java/com/gotcha/ui/tour/TourController.kt b/app/src/main/java/com/gotcha/ui/tour/TourController.kt
index 344d676..95d9478 100644
--- a/app/src/main/java/com/gotcha/ui/tour/TourController.kt
+++ b/app/src/main/java/com/gotcha/ui/tour/TourController.kt
@@ -73,7 +73,7 @@ class TourController(
onPersist(current?.id, false)
}
- /** Abandons the tour without marking it complete — "Skip tour". */
+ /** Abandons the tour — "Skip tour". Marks it complete so it does not return. */
fun cancel() {
index = -1
onPersist(null, true)
diff --git a/app/src/main/java/com/gotcha/ui/tour/TourOverlay.kt b/app/src/main/java/com/gotcha/ui/tour/TourOverlay.kt
index b8170e2..518009e 100644
--- a/app/src/main/java/com/gotcha/ui/tour/TourOverlay.kt
+++ b/app/src/main/java/com/gotcha/ui/tour/TourOverlay.kt
@@ -70,7 +70,10 @@ private val CARD_GAP = 12.dp
/** How far the cut-out is inflated beyond the control itself. */
private val HOLE_PADDING = 6.dp
-/** Grace period before deciding a [TourStep.requiresAnchor] control is really absent. */
+/**
+ * Grace period before deciding a [TourStep.requiresAnchor] control is really absent.
+ * Long enough to cover a settings-page scroll plus a layout pass on a mid-range device.
+ */
private const val ANCHOR_GRACE_MS = 1200L
/**