Fix Android share completion and link intents - #10
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Android implementation of the share plugin by making share sessions reliably complete (so share() can be called repeatedly) and by structuring link payloads so Android’s Sharesheet recognizes URLs as links.
Changes:
- Resolve/reset Android share session state via an activity-result callback, with lifecycle resume as a fallback.
- Preserve URL detection by putting URLs in
Intent.EXTRA_TEXTand using title/subject for the title/text. - Add Android unit tests covering share-session completion and intent payload mapping.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| android/test-support/tauri-api/src/main/java/app/tauri/plugin/Plugin.kt | Extends the test-support Plugin stub with startActivityForResult to support new activity-result flow in tests. |
| android/test-support/tauri-api/src/main/java/app/tauri/annotation/ActivityCallback.kt | Adds a test-support @ActivityCallback annotation used by the plugin callback. |
| android/src/main/java/SharePlugin.kt | Updates share flow to use activity-result completion and updates intent extras for link recognition. |
| android/src/main/java/ShareSessionState.kt | Introduces a small state machine to manage share session lifecycle and completion. |
| android/src/main/java/ShareIntentPayload.kt | Encapsulates mapping from share options to (title/body) intent extras for correct Sharesheet behavior. |
| android/src/test/java/ShareSessionStateUnitTest.kt | Adds regression tests for session completion/reset behavior. |
| android/src/test/java/ShareIntentPayloadUnitTest.kt | Adds regression tests for intent payload mapping (URL vs text/title). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+150
to
155
| @ActivityCallback | ||
| fun shareResult(invoke: Invoke, result: ActivityResult) { | ||
| if (shareSession.completeFromActivityResult()) { | ||
| resolvePendingShare(invoke) | ||
| } | ||
| } |
Contributor
|
@AbassHammed Wow, thank you for that quick turnaround! 🏆 |
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.
share()can be called repeatedly.EXTRA_TEXTso Android recognizes them as links.Tests: Android, JavaScript, TypeScript, and Rust test suites pass.
Fixes #8
Fixes #9