Skip to content

Conversation

Copy link

Copilot AI commented Jul 13, 2025

Fixes #392 - App now returns to main screen instead of closing when pressing back after opening documents through internal file chooser.

Problem

When users opened documents via the app's file chooser or recent documents, pressing the back button would close the entire app instead of returning to the main screen. This was unexpected UX behavior that differed from typical Android navigation patterns.

The correct behavior should be:

  • Internal navigation (file chooser/recent docs): Back button → return to main screen
  • External launch (opened from file manager/email): Back button → close app

Solution

Added tracking of document source and custom back button handling to provide appropriate navigation based on how the document was opened.

Key Changes

  • Track document source: Added documentOpenedInternally boolean flag
  • Internal navigation: Set flag to true for file chooser and recent documents
  • External navigation: Set flag to false for app launches with intent data
  • Custom back handling: Use modern OnBackPressedCallback with conditional logic
  • Return navigation: Added showLandingScreen() method to navigate back to main screen

Navigation Behavior After Fix

  • ✅ File chooser → document → BACK → main screen (was: close app)
  • ✅ Recent documents → document → BACK → main screen (was: close app)
  • ✅ External app → document → BACK → close app (unchanged)
  • ✅ Fullscreen mode → BACK → exit fullscreen (unchanged)

Files Modified

  • MainActivity.java: Added source tracking and back button handling (~35 lines)
  • RecentDocumentDialogFragment.java: Use internal navigation method (1 line)

The implementation is minimal and surgical, preserving all existing functionality while solving the UX issue described in the original problem statement.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx1536M -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.9-bin/90cnw93cvbtalezasaz0blq0a/gradle-8.9/lib/gradle-daemon-main-8.9.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.9-bin/90cnw93cvbtalezasaz0blq0a/gradle-8.9/lib/agents/gradle-instrumentation-agent-8.9.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.9 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits July 13, 2025 09:02
Co-authored-by: TomTasche <128734+TomTasche@users.noreply.github.com>
Co-authored-by: TomTasche <128734+TomTasche@users.noreply.github.com>
Co-authored-by: TomTasche <128734+TomTasche@users.noreply.github.com>
Co-authored-by: TomTasche <128734+TomTasche@users.noreply.github.com>
Copilot AI changed the title [WIP] @opendocument-app/OpenDocument.droid/issues/392 Fix back button navigation for documents opened within app Jul 13, 2025
Copilot AI requested a review from TomTasche July 13, 2025 09:11
Copilot finished work on behalf of TomTasche July 13, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App closes on going back from document view

2 participants