Skip to content

Fix opening PDF files with external viewers#152

Open
zerox80 wants to merge 3 commits into
opencloud-eu:mainfrom
zerox80:fix/pdf-open-with
Open

Fix opening PDF files with external viewers#152
zerox80 wants to merge 3 commits into
opencloud-eu:mainfrom
zerox80:fix/pdf-open-with

Conversation

@zerox80
Copy link
Copy Markdown
Contributor

@zerox80 zerox80 commented May 9, 2026

Summary

Fixes #139.

This changes the file-open intent MIME type selection so known file extensions are used when the stored MIME type is generic or missing. Concrete MIME types reported by the server are kept as-is; this keeps WebDAV metadata as the source of truth while still opening downloaded *.pdf files with application/pdf when the stored type is application/octet-stream, */*, blank, or missing.

The same MIME fallback is used in both OCFile file-open flows, and the manifest declares Android 11+ package visibility queries needed by explicit handler lookups for view/send intents.

Changes

  • Add MimetypeIconUtil.getBestMimeTypeForOpen(...)
  • Use the same generic-MIME fallback when opening OCFiles from both file-open flows
  • Add Android 11+ <queries> entries for VIEW, SEND, and SEND_MULTIPLE
  • Add unit coverage for generic, wildcard, null/blank, unknown-extension, no-extension, and concrete-MIME behavior

Validation

  • ./gradlew.bat :opencloudApp:testOriginalDebugUnitTest --tests eu.opencloud.android.utils.MimetypeIconUtilTest
  • ./gradlew.bat detekt
  • ./gradlew.bat assembleDebug
  • Verified the merged manifest contains the VIEW, SEND, and SEND_MULTIPLE package visibility queries

@zerox80 zerox80 marked this pull request as ready for review May 9, 2026 16:29
@guruz
Copy link
Copy Markdown
Contributor

guruz commented May 10, 2026

Use filename-based MIME detection when opening OCFiles

Hmm.
Why not have WebDAV return the mimetype?
Do we not know the mimetype when displaying the file list?
I'm not a fan of adding much code to re-invent stuff.

Add Android 11+ entries for VIEW, SEND, and SEND_MULTIPLE

Is this really needed? I didn't investigate it, but can't we just tell Android openThisFile("application/pdf", "/path/to/the.pdf") ?

@zerox80 zerox80 force-pushed the fix/pdf-open-with branch from 0e1ca72 to 87b5ae2 Compare May 10, 2026 17:52
@zerox80
Copy link
Copy Markdown
Contributor Author

zerox80 commented May 10, 2026

updated this to keep it more conservative:

  • webdav/server mime types still win if they are specific
  • extension fallback only kicks in for generic/missing types like application/octet-stream, */*, blank/null
  • both ocfile open paths now use the same mime helper
  • added the android 11+ queries because we call queryIntentActivities, not because startActivity needs them

also updated the pr description to match this.

@zerox80 zerox80 force-pushed the fix/pdf-open-with branch 2 times, most recently from 66c3abc to 74fc9d7 Compare May 10, 2026 20: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 not opening pdf files

2 participants