Repository navigation
fix(share): send original file instead of cached thumbnail - #17808
ToteMeiSter wants to merge 1 commit into
Conversation
A picture that was not downloaded was sent as a content URI of DiskLruImageCacheFileProvider, which serves a downscaled thumbnail from the preview cache. The provider is exported with the MANAGE_DOCUMENTS permission, so other apps could not read it either. Every file that is not on the device now goes through SendShareDialogDownloader: the original is downloaded and then sent. The audio player implements the downloader like the image preview does. A host without a downloader shows a message instead of closing the dialog silently. The choice is made by SendShareAction and covered by a unit test. DiskLruImageCacheFileProvider is removed together with its manifest entry, injector and image_cache_provider_authority. "Set as" is hidden for a picture that is not downloaded, because it used the same provider. The thumbnail descriptor for DocumentsStorageProvider moves into that class. Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru> Assisted-by: Claude-Code:claude-opus-5-5 Assisted-by: Claude-Code:claude-sonnet-5-5
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Problem
Refs #17414
When a picture is not stored on the device,
SendShareDialogdoes not download it. It callsFileOperationsHelper.sendCachedImage, which puts acontent://org.nextcloud.imageCache.provider/...URI intoACTION_SEND. That URI is served byDiskLruImageCacheFileProvider, which returns the preview thumbnail from the disk cache, not the original file. The receiving app gets a downscaled PNG instead of the photo.The provider is exported with
android:permission="android.permission.MANAGE_DOCUMENTS". Only the system documents UI holds that permission, so most apps (for example Google Messages, #17414) cannot open the URI at all.The cached path was added in 2015 (
a1bc147849) and extended to the file list in 2016 (d1d99c5e3f) to send a picture without downloading it. Every other file type already goes throughSendShareDialogDownloader, which downloads the original and then sends it.Change
SendShareDialog.onSendButtonClick: no special case for pictures. A downloaded file is sent at once. A file that is not on the device is downloaded through the host'sSendShareDialogDownloaderand sent afterwards. A host without a downloader shows "This file can't be sent from here because it isn't on your device yet" instead of closing the dialog without feedback. After this PR no such host is left; the message guards future hosts.SendShareAction(new enum) holds this decision, so it is unit-tested without the Android SDK.DiskLruImageCacheFileProvideris removed: the class, the manifest entry, the Dagger injector andimage_cache_provider_authorityin allsetup.xmlfiles. Its thumbnail descriptor was also used byDocumentsStorageProvider.openDocumentThumbnail; that code moves intoDocumentsStorageProviderunchanged.AudioPlayerActivityimplementsSendShareDialogDownloaderthrough the existingSendShareDownloader, the same wayPreviewImageActivitydoes.FileMenuFilternow hides the entry for such a picture, like "Open with". Every caller ofsetPictureAsgoes through this filter.actionbar_send_filewas only used bysendCachedImageand is removed.Hosts of
SendShareDialog:FileDisplayActivityPreviewImageActivityAudioPlayerActivityNotes
SendShareDialogas well. Without this PR a picture would still arrive as the cached thumbnail. The two branches merge without conflicts.How to test
SendShareActionTest(4 cases). The existing unit tests pass (jacocoTestGplayDebugUnitTest).FileMenuFilterIT.filter_setPictureAs_onlyForDownloadedImages(compiled, not run locally).🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)
The change was drafted with Claude Code (
Assisted-by: Claude-Code:claude-opus-5-5).