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 review and the CI prefs flake
Rishabh Bajpai53d3be6c2a8c
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.ktindex 8f2c584..39a2bdd 100644--- a/app/src/main/java/com/gotcha/MainActivity.kt+++ b/app/src/main/java/com/gotcha/MainActivity.kt@@ -479,15 +479,16 @@ class MainActivity : ComponentActivity() {}}// The launch video over everything, content initializing- // underneath it. Back is held while it plays: two seconds of- // branding must not read as a way to quit the app.+ // underneath it. Back skips it rather than quitting: nobody+ // asked to leave, they asked to get in faster.if (showSplash) {- BackHandler {}+ BackHandler { showSplash = false }SplashVideoOverlay(contentReady = splashContentReady,onFinished = { showSplash = false },- // Playback has started, so a rotation from here opens- // straight into the app instead of replaying the video.+ // The overlay has mounted, so a rotation from here+ // opens straight into the app instead of replaying+ // the video.onStarted = { SplashGate.played = true })}diff --git a/app/src/main/java/com/gotcha/ui/SplashOverlay.kt b/app/src/main/java/com/gotcha/ui/SplashOverlay.ktindex 5974779..534c2da 100644--- a/app/src/main/java/com/gotcha/ui/SplashOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/SplashOverlay.kt@@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.fillMaxHeightimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.runtime.Composable-import androidx.compose.runtime.DisposableEffectimport androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOf@@ -32,25 +31,27 @@ import androidx.compose.ui.viewinterop.AndroidViewimport com.gotcha.Rimport kotlinx.coroutines.delay-/** The footage's own aspect ratio: 1080x1920 portrait. */+/** The footage's own aspect ratio: 720x1280 portrait. */private const val VIDEO_ASPECT = 9f / 16f-/** Failsafe: a wedged decoder must never hold the launch hostage. */-private const val SPLASH_TIMEOUT_MS = 12_000L+/**+ * Failsafe for a wedged decoder: prepare plus two seconds of footage should+ * never take this long, and past it something is wrong enough that holding+ * the launch longer only punishes the user.+ */+private const val SPLASH_TIMEOUT_MS = 4_000L/** The fade from the video's last frame into the app. */private const val SPLASH_FADE_MS = 300/**- * Whether the overlay may go away. The video is the minimum: it is two seconds- * long and cannot finish earlier, so a fast device still watches the whole- * launch. Past it, dismissal waits for the app shell ([contentReady]) — on a- * slow start the last frame holds as the logo. The timeout releases either- * wait on its own, so a decoder that never calls back cannot hold the launch- * hostage.+ * The launch overlay's dismissal rule: the two-second video is the minimum,+ * the app shell gates the rest, and the timeout releases either wait on its+ * own. A decoder failure counts as finished: the fallback logo holds instead+ * of the last frame, under the same rule.*/-fun shouldDismissSplash(videoEnded: Boolean, contentReady: Boolean, timedOut: Boolean): Boolean =- (videoEnded && contentReady) || timedOut+fun shouldDismissSplash(playbackFinished: Boolean, contentReady: Boolean, timedOut: Boolean): Boolean =+ (playbackFinished && contentReady) || timedOut/*** The cold-start launch video, played once per process while the app@@ -90,14 +91,11 @@ fun SplashVideoOverlay(val alpha by animateFloatAsState(targetValue = if (fading) 0f else 1f,animationSpec = tween(SPLASH_FADE_MS),+ // With animations disabled the fade finishes at once; the delay below+ // would leave an invisible overlay swallowing taps for 300ms.+ finishedListener = { if (it == 0f) onFinished() },label = "splashFade")- LaunchedEffect(fading) {- if (fading) {- delay(SPLASH_FADE_MS.toLong())- onFinished()- }- }// The footage's own night gradient behind the video: sampled off the first// frame, so the fit bars on taller screens melt into the footage instead@@ -123,8 +121,9 @@ fun SplashVideoOverlay() {BoxWithConstraints(modifier = Modifier.fillMaxSize()) {// Scale to fit, never stretch: the footage is 9:16 and phones are- // taller, so the height binds and matching ground fills the rest.- // A full-bleed crop would eat the logo on narrow screens.+ // taller, so the width binds and matching ground fills the bands+ // above and below. A full-bleed crop would eat the logo on+ // narrow screens.val widthToHeight = maxWidth / maxHeightval videoModifier = if (widthToHeight < VIDEO_ASPECT) {Modifier.fillMaxWidth().aspectRatio(VIDEO_ASPECT)@@ -140,10 +139,13 @@ fun SplashVideoOverlay(.then(videoModifier))} else {- var player by remember { mutableStateOf<VideoView?>(null) }AndroidView(factory = { ctx ->VideoView(ctx).apply {+ // A silent brand moment must not pause the user's+ // music or podcast: VideoView takes audio focus by+ // default, even with nothing to play.+ setAudioFocusRequest(android.media.AudioManager.AUDIOFOCUS_NONE)// Listeners first: a local resource can prepare// before the next line runs.setOnPreparedListener { mp ->@@ -163,16 +165,13 @@ fun SplashVideoOverlay("android.resource://${ctx.packageName}/${R.raw.gotcha_splash}"))- player = this}},+ onRelease = { player -> player.stopPlayback() },modifier = Modifier.align(Alignment.Center).then(videoModifier))- DisposableEffect(Unit) {- onDispose { player?.stopPlayback() }- }}}}diff --git a/app/src/main/res/values-night-v31/themes.xml b/app/src/main/res/values-night-v31/themes.xmldeleted file mode 100644index d6840cd..0000000--- a/app/src/main/res/values-night-v31/themes.xml+++ /dev/null@@ -1,13 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<!--- Night-mode twin of values-v31/themes.xml. The splash matches the video's- dark starfield in both modes now; only the window follows the night ground.--->-<resources>- <style name="Theme.Gotcha" parent="android:Theme.Material.Light.NoActionBar">- <item name="android:windowBackground">@color/launch_background</item>- <item name="android:windowSplashScreenBackground">@color/splash_background</item>- <item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_logo</item>- <item name="android:windowSplashScreenAnimationDuration">1000</item>- </style>-</resources>diff --git a/app/src/main/res/values-v31/themes.xml b/app/src/main/res/values-v31/themes.xmlindex da60e69..917df92 100644--- a/app/src/main/res/values-v31/themes.xml+++ b/app/src/main/res/values-v31/themes.xml@@ -11,6 +11,9 @@<style name="Theme.Gotcha" parent="android:Theme.Material.Light.NoActionBar"><!-- Stops the white flash before Compose's first frame. See colors.xml. --><item name="android:windowBackground">@color/launch_background</item>+ <!-- Restored from values-v29: without this, OEM force-dark inverts+ Compose screens on API 31+ too. -->+ <item name="android:forceDarkAllowed">false</item><item name="android:windowSplashScreenBackground">@color/splash_background</item><item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_logo</item><item name="android:windowSplashScreenAnimationDuration">1000</item>diff --git a/app/src/test/java/com/gotcha/data/SettingsSkinMigrationTest.kt b/app/src/test/java/com/gotcha/data/SettingsSkinMigrationTest.ktindex c97ff86..32c8197 100644--- a/app/src/test/java/com/gotcha/data/SettingsSkinMigrationTest.kt+++ b/app/src/test/java/com/gotcha/data/SettingsSkinMigrationTest.kt@@ -26,10 +26,11 @@ class SettingsSkinMigrationTest {@Beforefun setUp() {FakeAndroidKeyStore.setUp()- // Hermetic prefs: the whole suite shares one Robolectric JVM, and other- // classes leave encrypted settings behind that this class must not see.- context.getSharedPreferences(SETTINGS_PREFS_FILE, Context.MODE_PRIVATE)- .edit().clear().apply()+ // Hermetic prefs: the suite shares one JVM, and EncryptedSharedPrefs+ // reads the file from disk on creation while apply() flushes async,+ // so a leftover file from another class races the first read. A+ // synchronous delete leaves no race.+ context.deleteSharedPreferences(SETTINGS_PREFS_FILE)repository = SettingsRepository(context)}diff --git a/app/src/test/java/com/gotcha/ui/SplashDismissTest.kt b/app/src/test/java/com/gotcha/ui/SplashDismissTest.ktindex 749889c..a677afd 100644--- a/app/src/test/java/com/gotcha/ui/SplashDismissTest.kt+++ b/app/src/test/java/com/gotcha/ui/SplashDismissTest.kt@@ -6,26 +6,35 @@ import org.junit.Test/*** The launch overlay's dismissal rule: the two-second video is the minimum,- * the app shell gates the rest, and the timeout is the back stop.+ * the app shell gates the rest, and the timeout releases either wait on its+ * own. A decoder failure counts as finished ([videoFailed] feeds the same+ * flag), so the fallback logo holds under the same rule.*/class SplashDismissTest {@Test- fun `the video alone never dismisses before it ends`() {- assertFalse(shouldDismissSplash(videoEnded = false, contentReady = true, timedOut = false))- assertFalse(shouldDismissSplash(videoEnded = false, contentReady = false, timedOut = false))+ fun `nothing dismisses before playback ends`() {+ assertFalse(shouldDismissSplash(playbackFinished = false, contentReady = true, timedOut = false))+ assertFalse(shouldDismissSplash(playbackFinished = false, contentReady = false, timedOut = false))}@Test- fun `after the video, dismissal waits for the app shell`() {- assertFalse(shouldDismissSplash(videoEnded = true, contentReady = false, timedOut = false))- assertTrue(shouldDismissSplash(videoEnded = true, contentReady = true, timedOut = false))+ fun `after playback, dismissal waits for the app shell`() {+ assertFalse(shouldDismissSplash(playbackFinished = true, contentReady = false, timedOut = false))+ assertTrue(shouldDismissSplash(playbackFinished = true, contentReady = true, timedOut = false))}@Test- fun `the timeout releases a stuck launch even if the video never ends`() {- assertTrue(shouldDismissSplash(videoEnded = true, contentReady = false, timedOut = true))- assertTrue(shouldDismissSplash(videoEnded = false, contentReady = false, timedOut = true))- assertTrue(shouldDismissSplash(videoEnded = false, contentReady = true, timedOut = true))+ fun `a failed playback dismisses like a finished one`() {+ val failed = true+ assertFalse(shouldDismissSplash(playbackFinished = failed, contentReady = false, timedOut = false))+ assertTrue(shouldDismissSplash(playbackFinished = failed, contentReady = true, timedOut = false))+ }++ @Test+ fun `the timeout releases a stuck launch even if playback never ends`() {+ assertTrue(shouldDismissSplash(playbackFinished = true, contentReady = false, timedOut = true))+ assertTrue(shouldDismissSplash(playbackFinished = false, contentReady = false, timedOut = true))+ assertTrue(shouldDismissSplash(playbackFinished = false, contentReady = true, timedOut = true))}}