Repository navigation
fix(share): keep the common MIME type when sharing several files on Android - #2618
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
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.
Closes #2605
Description
On Android,
shareFilessets the intent type to*/*as soon as more than one file is shared, even when every file has a known MIME type. Issue #2605 reports that WhatsApp treats such a*/*ACTION_SEND_MULTIPLEintent as text-only and sends only thetext.This change sets the intent type to the most specific type that covers every shared file:
image/jpeg.<type>/*when the files share only the top-level type, for exampleimage/*for a JPEG and a PNG.*/*when the top-level types differ or any type is unknown, as before.Single-file shares keep their current behavior.
Testing
SharePluginTest, a JVM unit test for the newgetCommonMimeTypehelper../gradlew testDebugUnitTest --tests "com.capacitorjs.plugins.share.*"inshare/android: 3 tests pass../gradlew clean build testinshare/androidpasses.npx prettier --check "android/src/**/*.java" --plugin=prettier-plugin-javainsharepasses.