Repository navigation
android: Attach opens Android's chooser (files, photos, camera); Qt's file dialog hears the answer - #2132
Closed
trissim wants to merge 1 commit into
Closed
android: Attach opens Android's chooser (files, photos, camera); Qt's file dialog hears the answer#2132trissim wants to merge 1 commit into
trissim wants to merge 1 commit into
Conversation
… file dialog hears the answer On the phone Attach showed Qt's widget file dialog, a desktop dialog that lists only the app's own directories (Tristan: "it shows the same file picker as if it was on desktop ... bring up the native file picker: is it a photo, is it a camera, or is it a file"). Two owners were in the way. pyqt-reactive's theme turned native dialogs off on every platform (PyQT-reactive#66 keeps them on phones). And python-for-android's PythonActivity overrides onActivityResult without calling super, so Qt's receivers - its native file dialog's - never heard a result: QtActivityResults hands each result to Qt's package-private entry, as QtActivityBase does, and ToadActivity calls it. ToadActivity offers Qt's document request to AttachChooser: ACTION_GET_CONTENT for the same types in Android's chooser (Files, Photos, Drive), with a camera capture into a new MediaStore photo (Pictures/Toad) as its first choice. Either answer reaches Qt's dialog as a content URI, which file_pickers.read_picked already reads. Desktops keep the themed dialog; WindowFilePicker stays the one choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
Author
|
Merged as part of #2133, gated together with four other branches. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tristan, 2026-11-18: "the attach feature ... on mobile shows the same file picker as if it was on desktop. On Android I would rather it bring up the native file picker dialog — is it a photo, is it a camera, or is it a file — ... You can keep that existing window file picker for the desktop version."
Why the desktop dialog showed on the phone
Two owners were in the way:
AA_DontUseNativeDialogson every platform, so Qt drew its widget dialog. The phone's log confirms it: Toad never launched a document intent. theming: phones keep the system's file picker; desktops keep the themed dialog PyQT-reactive#66 (merged, b63f12386) keeps native dialogs where the system's picker is the only way into storage (android,ios).PythonActivity.onActivityResultnotifies only its own listeners and never callssuper. Qt's receivers, including the native file dialog's, never heard a result.QtActivityBase.onActivityResultisActivity.onActivityResultfollowed byQtNative.onActivityResult(javap of the shipped Qt6Android.jar). The second call is package-private, soorg.qtproject.qt.android.QtActivityResults.delivercalls it, andToadActivity.onActivityResultcalls that after p4a's override.The chooser
ToadActivity.startActivityForResultoffers Qt's document request (ACTION_OPEN_DOCUMENT+CATEGORY_OPENABLE) toAttachChooser. That becomes Android's chooser:ACTION_GET_CONTENTfor the same types (Files, Photos, Drive);Pictures/Toad.The answer reaches Qt's dialog as a content URI either way: the app's own URI, or the camera's photo with its pending flag cleared. A chooser left any other way deletes the pending photo.
file_pickers.read_pickedalready reads content URIs through QFile, so no Python path changes.Desktop: unchanged, the themed QFileDialog.
WindowFilePickerstays the one choice; its documented meaning was already "the platform's file dialog; a phone shows its own".Checks
javac --release 11compilesToadActivity(against p4a's qt-bootstrapPythonActivityand Qt6Android/Qt6AndroidBindings.jar),AttachChooserandQtActivityResults.composer(desktop Attach still opens the themed QFileDialog), plus ratchet, shadow andcheck.sh.Not provable off the device
Each of these is checked by building the APK and tapping Attach on the phone:
GET_CONTENTURI. ItstakePersistableUriPermissionthrows for such URIs;QJniObjectclears the exception;QFileInfo(content://…).fileName()gives the display name.🤖 Generated with Claude Code
https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3