-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(android): permit to specify a list of allowed mime-types #2145
base: main
Are you sure you want to change the base?
feat(android): permit to specify a list of allowed mime-types #2145
Conversation
@@ -125,35 +125,42 @@ public void launchImageLibrary(final ReadableMap options, final Callback callbac | |||
boolean isPhoto = this.options.mediaType.equals(mediaTypePhoto); | |||
boolean isVideo = this.options.mediaType.equals(mediaTypeVideo); | |||
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { | |||
boolean usePhotoPicker = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU; |
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 moved this check into a variable as it was used multiple times
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { | ||
boolean usePhotoPicker = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU; | ||
|
||
if (usePhotoPicker) { |
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.
Order of the statements has been inversed to avoid a negation in the if
statement
ac28ad4
to
753a0f4
Compare
@Johan-dutoit Could you have a look at this PR? It has been running in our production app for 2 months without issues. |
Bumping this comment |
753a0f4
to
55149ba
Compare
55149ba
to
a6197d7
Compare
Motivation (required)
The Android camera app has an option to store both JPEG and RAW (DNG format) files for each picture. When this option is enabled, both versions of the image are shown to the user (but without any indication of the file format, so the users sees every image twice).
This new options allows you to restrict the allowed MIME types, for example
restrictMimeTypes: ['image/jpeg', 'image/heic', 'image/png']
.On Android 13 (new Photo Picker), only the matching files are displayed, no more duplicates.
On older Android versions, every file is still displayed in the file explorer, but non-matching files are grayed and can not be selected.
This option can not be implemented on iOS, as the API only allows you to filter on predefined types (images, videos, slow-mos…).
Test Plan (required)
I used
restrictMimeTypes: ['image/jpeg', 'image/heic', 'image/png']
with the example app and tested the behaviour with and without the option on an Android 10 and Android 13 devices.