-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
patch expo-image-picker to support "browse" on android #2384
patch expo-image-picker to support "browse" on android #2384
Conversation
* @see [androidx.activity.result.contract.ActivityResultContracts.GetMultipleContents] | ||
*/ | ||
internal class ImageLibraryContract( | ||
- private val appContextProvider: AppContextProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed code starts here
This was a lie. I tested in a sandbox on sdk 23 and it worked. see #2394. tested and it does work from 23 up. |
@haileyok going to review this asap but dropping in real quick to say if you're interested in a job, I definitely want to chat (paul@blueskyweb.xyz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell you how much I appreciate this one. It's been on the todo list for so long.
I'm cleaning up the patchfile with 95%ish confidence that I'm just removing build intermediates. If I get that wrong, we've got this PR to look at again in the future.
fixes #1617
Right now, expo-image-picker is using
PickVisualMedia
. This does not support the "Browse" option to select files elsewhere on the device except the gallery. Instead, we want to useGetContent
. See https://android-developers.googleblog.com/2023/04/photo-picker-everywhere.htmlThis patches expo-image-picker to do so. Tested on SDK 34, 28, and
2325. Tested accessing images from files as well as Google Drive with good success.This is meant to be a temporary fix, and I didn't implement the logic for selecting videos. It's only a few extra lines, however we have to be careful that we properly create the intent (the mime can't be anything other than
image/*
orvideo/*
otherwise it won't use the image picker).We also have to use
Intent.EXTRA_ALLOW_MULTIPLE
which only accepts a boolean, not a limit. To that end, I've made a minor change inpicker.shared.ts
to slice the result and make sure we only return four images. Not the most ideal option, but I think the benefits of fixing this seemingly annoying issue outweigh that. To try and make it clear to the user, we present a toast if they select more than four images.Of course whenever multiple is disabled we still only allow the selection of one file.
I think Google's intent is to make
PickVisualMedia
work in the future in the same way, so hopefully this isn't something that will need to be in the codebase for too long. They said by the end of the year though and...here we are 🙃