[mail-composer][android] fix composeAsync not resolving after send/ discard #20869
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.
Why
Fixes #20509
How
TL;DR - this fix restores the documented behavior, albeit with a visual bug that seems to be peculiar to Gmail.
I first tried to compare the send/ resolve flow to (what I thought) was the closest analog,
expo-sms
. TheonHostResume
lifecycle listener event is trigged in the SMS package, but not mail composer. Nothing along these lines worked (e.g., matching the Intent flags).It turns out that
expo-sharing
is perhaps a more appropriate comparison, because they both useIntent.createChooser
to create a share sheet (the mail composer's sheet mainly filters on email apps and can pass additional email-related keys). It seems likeonHostResume
never responds to returning from a share sheet. Sharing uses theActivityEventListener
instead.Anyway, this works, with one visual quirk that seems to be peculiar to the implementation of the Gmail client's new mail activity. Pressing back does not discard the email/ return to the app. It takes you back to your inbox. Once you do this, your only choice is to use the task switcher/ launcher to leave the email, and, in the task switcher, the image of the app doesn't update, continuing to show a picture of the email that you were composing.
Other apps demonstrate the same issue with sharing to Gmail (e.g., Twitter), though others don't (e.g., Facebook). Seems possible that this is related to task/ activity settings outside the control of this package, e.g.,
android:launchMode
.Comparing to external packages that fulfill a similar purpose, I found some (e.g.,
react-native-mail
) that resolve the promise as soon as the share sheet opens, which is an option, but would break the documented behavior and not match iOS.Test Plan
Scenarios:
See video (including visual bug at the end)
Checklist
expo prebuild
& EAS Build (eg: updated a module plugin).