Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/src/main/java/org/fairscan/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,18 @@ class MainActivity : ComponentActivity() {
back = {
val origin = viewModel.currentScreen.value
viewModel.navigateBack()

// If there is nothing to navigate back to, exit the app.
val destination = viewModel.currentScreen.value
if (destination == origin && launchMode == LaunchMode.EXTERNAL_SCAN_TO_PDF) {
setResult(RESULT_CANCELED)
finish()
if (destination == origin) {
if (launchMode == LaunchMode.EXTERNAL_SCAN_TO_PDF) {
setResult(RESULT_CANCELED)
finish()
} else {
// Delegate to OS back handler instead of finishing
// to benefit from activity caching for the next start.
onBackPressedDispatcher.onBackPressed()
}
}
}
)
Expand Down