Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,36 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
return super.onKeyDown(keyCode, event);
}

@Override
public void onBackPressed() {
// Check if document is displayed and was opened internally
if (documentFragment != null && documentContainer.getVisibility() == View.VISIBLE) {
// Check if the activity was launched without external data (internal file selection)
if (getIntent().getData() == null) {
// Return to landing screen instead of exiting
landingContainer.setVisibility(View.VISIBLE);
documentContainer.setVisibility(View.GONE);

// Clear the document fragment
getSupportFragmentManager()
.beginTransaction()
.remove(documentFragment)
.commitNow();
documentFragment = null;

// Clear the lastUri to reset state
lastUri = null;

analyticsManager.setCurrentScreen(this, "screen_main");

return;
}
}

// Default behavior for external files or when no document is shown
super.onBackPressed();
}

public void findDocument() {
final Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
Expand Down
Loading