Repository navigation
fix(share): send original file instead of cached thumbnail - #17808
Open
ToteMeiSter wants to merge 1 commit into
Open
ToteMeiSter wants to merge 1 commit into
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! |
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
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).