Repository navigation
fix(sharing): download file before "Send copy to" - #17807
Open
ToteMeiSter wants to merge 1 commit into
Open
ToteMeiSter wants to merge 1 commit into
ToteMeiSter wants to merge 1 commit into
Conversation
"Send copy to" put the exposed file URI into the send intent without checking whether the file is stored on the device. For a file that was never downloaded getExposedFileUri() returns null, so the receiving app gets ACTION_SEND without EXTRA_STREAM and cannot send anything. A file that is not on the device now goes through SendShareDialog, which already downloads the file (DOWNLOAD_SEND) and sends it afterwards, like the "Send/share" menu entry of the details screen. Downloaded files keep using the system chooser. The download path is taken only when the host activity implements SendShareDialogDownloader, because ShareActivity hosts the sharing fragment too and would close the dialog without sending. Refs: nextcloud#17619 Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru> Assisted-by: Claude-Code:claude-opus-5-5
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This branch has not been deployed
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.
Problem
Closes #17619
The "Send copy to" button on the sharing tab of the file details builds the send intent with
OCFile.getExposedFileUri(). That method returnsnullwhen the file has no local copy. The sharing tab can be opened for a file that was never downloaded, so Telegram, WhatsApp and other apps receiveACTION_SENDwithoutEXTRA_STREAMand show "Unsupported content" or send nothing. For a file that is already on the device the button works.The button was added in #16183 without a download step. The previous share entry went through
SendShareDialog, which downloads the file first.Change
FileDetailSharingFragment: when the file is not on the device, the button callsFileOperationsHelper.sendShareFile(file, true). This is the same call the "Send/share" menu entry of the details screen uses.SendShareDialoglists the apps, downloads the file through the host'sSendShareDialogDownloader(FileDisplayActivity,DOWNLOAD_SEND) and sends it to the chosen app. A downloaded file still opens the system chooser. The download path is used only when the host activity implementsSendShareDialogDownloader;ShareActivityalso hosts the fragment and does not implement it, so it keeps the old behaviour.Notes
SendShareDialog. "Send copy to" was the only one that calledIntentUtil.createSendIntentdirectly.SendShareDialog/SendShareDialogDownloaderpath is reused. The host of the sharing tab,FileDisplayActivity, already implementsSendShareDialogDownloader.SendShareDialogsends a not downloaded image as the cached preview (sendCachedImage), not as the original. The menu entry behaves the same way today. Changing that is out of scope here.FileDetailSharingFragment. No file overlap with the other three PRs (fix(auto-upload): restart folder runs that stay enqueued on rescan #17805, fix(auto-upload): start auto upload right after resuming global upload pause #17806, fix(share): send original file instead of cached thumbnail #17808); trial merge of all four is clean. Logically it goes together with fix(share): send original file instead of cached thumbnail #17808 (SendShareDialog): with both merged, a not downloaded picture from "Send copy to" is downloaded and sent as the original.How to test
jacocoTestGplayDebugUnitTest).🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)
The change was drafted with Claude Code (
Assisted-by: Claude-Code:claude-opus-5-5).