From 4afdd6de2c5128d182f97ab10288c0582e98b87a Mon Sep 17 00:00:00 2001 From: QuerTeal <11648267+QuerTeal@users.noreply.github.com> Date: Mon, 28 Sep 2026 00:49:30 +0900 Subject: [PATCH] android(fix): let back exit the app from the root screen SwipeBackSceneContent registers a PredictiveBackHandler that is always enabled. On the root screen (no previous entry) it still consumed the back gesture/button, so pressing back did nothing instead of leaving the app. Only enable it when there is a previous entry to go back to. The onboarding BackHandler had the same problem on its first page; enable it only while the carousel can scroll backward. Co-Authored-By: Claude Opus 5.5 --- .../kavishdevar/librepods/presentation/navigation/SwipeBack.kt | 3 ++- .../presentation/screens/onboarding/OnboardingScreen.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/navigation/SwipeBack.kt b/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/navigation/SwipeBack.kt index 66e115f04..93d0930cf 100644 --- a/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/navigation/SwipeBack.kt +++ b/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/navigation/SwipeBack.kt @@ -166,7 +166,8 @@ private fun SwipeBackSceneContent( } } - PredictiveBackHandler { progressFlow -> + // only intercept back when there is a screen to go back to, otherwise let the activity handle it (exit the app) + PredictiveBackHandler(enabled = previousEntry != null) { progressFlow -> try { progressFlow.collect { backEvent -> if (previousEntry == null) return@collect diff --git a/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/screens/onboarding/OnboardingScreen.kt b/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/screens/onboarding/OnboardingScreen.kt index 7e16b0d0b..b40cb73e6 100644 --- a/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/screens/onboarding/OnboardingScreen.kt +++ b/android/app/src/main/kotlin/me/kavishdevar/librepods/presentation/screens/onboarding/OnboardingScreen.kt @@ -72,7 +72,7 @@ fun OnboardingScreen( val animationScope = rememberCoroutineScope() - BackHandler { + BackHandler(enabled = state.canScrollBackward) { animationScope.launch { if (state.canScrollBackward) { val targetItem = if (isSupported && state.currentItem == 3) 1 else state.currentItem - 1