-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[image_picker_android] Adds Android 13 photo picker functionality #3267
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
Conversation
verify(mockActivity) | ||
.startActivityForResult( | ||
any(Intent.class), | ||
eq(ImagePickerDelegate.REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY_USING_PHOTO_PICKER)); |
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.
(Continuing from flutter/plugins#7043 (comment) on the pre-migration version of this PR, and from Discord.)
This is checking what "request code" we passed to startActivityForResult
. But the request code doesn't have any effect on what UI the system presents to the user, or anything like that — it's a number we make up for our own internal tracking, so that our onActivityResult
can know what to do with the result it gets.
The thing that controls whether the system shows the spiffy new photo picker, or does something else, is the "action" in the Intent. So that would be the thing to inspect if writing this style of unit test.
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.
Here's probably the clearest upstream docs on that — in particular the "Action" subsection:
https://developer.android.com/guide/components/intents-filters
Then in the reference docs there's
https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)
https://developer.android.com/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent)
and the voluminous intro of
https://developer.android.com/reference/android/content/Intent.html
.
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.
Here's probably the clearest upstream docs on that — in particular the "Action" subsection: https://developer.android.com/guide/components/intents-filters
Is this something we want want to implement for this PR then? Looks like all the tests currently only check that the intent has the correct tag so I imagine we'd want to refactor those tests to also confirm the correct action.
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 imagine we'd want to refactor those tests to also confirm the correct action.
I think that would be a good improvement, but my suggestion for this PR would be to leave the tests for other functionality as they are.
…Contracts to decide which photo_picker should be used based on SDK version instead of handling the checks manually.
the error causing the failing test:
|
Is there any kind of approval process to bump the min SDK or am I good to make that change? |
Flutter in general supports API 16, so I imagine folks will want to keep these plugins supporting API 16 too. It looks like both of these I'm a bit surprised that the AndroidX folks didn't add a fallback to So I think you'll need to check for API 19, and below that version fall back to the same code that's currently here. Fortunately I don't think that makes things much more complicated; it basically just means adding the same code this version adds, but not deleting the old code. And the old code is pretty short. |
Yeah, it definitely seems odd, especially since they are already doing some SDK checks with the photo picker. I'll implement this change today and ping you for another review! |
Fyi flutter is in the process of bumping support to a min of api 19. FWIW I am waiting on terrinneal to give this a pass before digging in. |
Ah, good to know, thanks! If I owned this code I think I'd want to keep the API 16 support until that process completes and Flutter itself actually does bump the minimum to 19. At least I would in this case, where the cost of continued support is just to keep a few lines of existing code, wrapped in a conditional where it only runs on the old versions. But I wouldn't feel strongly about it. |
I agree, I'll continue with the original plan of checking the current API version before deciding what code to run. @reidbaker Appreciate you bringing that up! |
We will need to maintain support for API 16 for now. My intention with surfacing that error wasn't to suggest that it needed to be updated in that way. Sorry for the confusion. I've been digging in to future intent with this plugin moving forward, so it is taking me a little longer than expected to be able to approve this pr. Hoping to be able to move forward with it asap. |
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.
Flutter in general supports API 16, so I imagine folks will want to keep these plugins supporting API 16 too.
We will need to maintain support for API 16 for now. My intention with surfacing that error wasn't to suggest that it needed to be updated in that way. Sorry for the confusion.
…used, otherwise defaults to old Intent.ACTION_GET_CONTENT behavior.
No apologies necessary, really appreciate the review! Wrapped functionality in an if statement to check the SDK version. Ready for another review! |
...picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
Show resolved
Hide resolved
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.
This all seems good to me, thanks for sending this in, and handling all of the revisions as well!
auto label is removed for flutter/packages, pr: 3267, due to - This commit is not mergeable and has conflicts. Please rebase your PR and fix all the conflicts. |
I think I fixed the conflicts by removing a version that didnt have a changelog message. |
(This looks great to me! Thanks @FXschwartz for all your work on it.) |
auto label is removed for flutter/packages, pr: 3267, due to - The status or check suite repo_checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
* main: (3910 commits) [various] Align Flutter and Dart SDK constraints (flutter#3349) Roll Flutter from c590086 to f2f8005 (14 revisions) (flutter#3373) [webview_flutter] Enable warnings-as-errors on Android (flutter#3356) [ci] Increase Android platform test sharding (flutter#3365) Roll Flutter from f032a4d to c590086 (69 revisions) (flutter#3366) [Espresso] Update truth package to 1.1.3 (flutter#3358) [google_maps] Relax the Android renderer requset test (flutter#3364) [pigeon] Only check generated files on master (flutter#3357) [webview]: Bump androidx.webkit:webkit from 1.5.0 to 1.6.0 in /packages/webview_flutter/webview_flutter_android/android (flutter#3243) [ci+various] Partially enable javac warning checks (flutter#3293) [webview_flutter] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3336) [local_auth] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3335) [google_sign_in] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3330) [google_maps_flutter] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3329) [video_player] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3328) [file_selector] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3325) [go_router_builder] Fix the example for default values in the README (flutter#3231) Update annotation and espresso dependencies (flutter#3271) [tool] Provide a --base-branch flag (flutter#3322) [image_picker_android] Adds Android 13 photo picker functionality (flutter#3267) ...
…utter#3267) [image_picker_android] Adds Android 13 photo picker functionality
NOTE: This PR was moved over from the
flutter/plugins
repo - flutter/plugins#7043Description
This PR adds the new Android 13 photo picker functionality to Android devices running SDK version 33 or later as well as bumps the compileSdkVersion from 31 to 33. If an Android device is older, it will use the previous standard image picker. Below are two devices, the left running SDK 30 and the right running SDK 33.
List which issues are fixed by this PR. You must list at least one issue.
Fixes flutter/flutter#104250
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.