-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker] add requestFullMetadata for iOS (optional permissions) - iOS changes #5713
[image_picker] add requestFullMetadata for iOS (optional permissions) - iOS changes #5713
Conversation
@stuartmorgan @cyanglaz I moved iOS specific changes to a separate branch, as suggested. |
@@ -16,7 +16,7 @@ dependencies: | |||
# The example app is bundled with the plugin so we use a path dependency on | |||
# the parent directory to use the current plugin's version. | |||
path: ../ | |||
image_picker_platform_interface: ^2.3.0 | |||
image_picker_platform_interface: ^2.5.0 |
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.
2.4.0?
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.
2.4.0 was the broken version that I reverted in 2.4.1
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.
Looks good with some minor nits
@@ -119,7 +119,12 @@ - (void)launchPHPickerWithContext:(nonnull FLTImagePickerMethodCallContext *)con | |||
_pickerViewController.presentationController.delegate = self; | |||
self.callContext = context; | |||
|
|||
[self checkPhotoAuthorizationForAccessLevel]; | |||
BOOL requestFullMetadata = context.requestFullMetadata; |
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.
Nit: there's no value to this local variable given how short and readable the right hand side is; you can just inline context.requestFullMetadata
into the if
condition.
@@ -129,14 +134,24 @@ - (void)launchUIImagePickerWithSource:(nonnull FLTSourceSpecification *)source | |||
imagePickerController.delegate = self; | |||
imagePickerController.mediaTypes = @[ (NSString *)kUTTypeImage ]; | |||
self.callContext = context; | |||
BOOL requestFullMetadata = context.requestFullMetadata; |
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.
Same here. Especially since this is only used once, and conditionally, so doesn't make sense to define at such a high level.
@@ -177,6 +179,27 @@ - (void)testPickMultiImageShouldUseUIImagePickerControllerOnPreiOS14 { | |||
[mockUIImagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]); | |||
} | |||
|
|||
- (void)testPickImageWithoutFullMetadataPreiOS14 { |
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.
Why is this test pre-14?
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 realized that it was a wrong test case, not fully covering the new flag's use case and vulnerable to false positives. I've changed it so it now verifies that there was no check for gallery authorization status.
@@ -227,14 +244,19 @@ - (void)pickVideoWithSource:(nonnull FLTSourceSpecification *)source | |||
} | |||
|
|||
self.callContext = context; | |||
BOOL requestFullMetadata = context.requestFullMetadata; |
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.
Same here; just inline the expression.
@@ -553,8 +575,13 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |||
NSNumber *maxHeight = self.callContext.maxSize.height; | |||
NSNumber *imageQuality = self.callContext.imageQuality; | |||
NSNumber *desiredImageQuality = [self getDesiredImageQuality:imageQuality]; | |||
BOOL requestFullMetadata = _callContext.requestFullMetadata; |
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.
Same.
PHAsset *originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
PHAsset *originalAsset; | ||
if (requestFullMetadata) { | ||
// Full metadata are available only in PHAsset, which requires gallery permission |
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.
Nit: missing period.
…ermissions-ios-changes � Conflicts: � packages/image_picker/image_picker_ios/CHANGELOG.md � packages/image_picker/image_picker_ios/pubspec.yaml
Friendly bump, looks like the nits were addressed. |
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.
Sorry, one more issue I missed last time.
@@ -234,7 +249,11 @@ - (void)pickVideoWithSource:(nonnull FLTSourceSpecification *)source | |||
camera:[self cameraDeviceForSource:source]]; | |||
break; | |||
case FLTSourceTypeGallery: | |||
[self checkPhotoAuthorizationWithImagePicker:imagePickerController]; | |||
if (context.requestFullMetadata) { |
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.
Doesn't this need the same @available
check and fallback?
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 just realized that this change for picking a video can't be used with the current platform interface. It doesn't allow passing requestFullMetadata
for both multi-image and videos. I can either improve the interface or remove this change for video picking (depending on what you think is better).
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 don't see any reason we wouldn't want support for this in the multi-image case, so updating that interface makes sense.
Looking at the result callback, is this change even relevant for video? It looks like the parameter is only used in a non-video codepath.
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.
Okay, I'll update the interface and create a PR soon. I'll also remove usage of requestFullMetadata
for the video path, since it it isn't used, as you've noticed.
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.
Looks like this is still missing the iOS 11 @available
check.
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've removed usage of requestFullMetadata
from here since it isn't supported in the video picking.
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.
LGTM when Stuart's comments are addressed.
@PiotrMitkowski Friendly ping :) Are you planning on continuing this PR? |
I will take a look at #5914 |
…ermissions-ios-changes � Conflicts: � packages/image_picker/image_picker_ios/CHANGELOG.md � packages/image_picker/image_picker_ios/pubspec.yaml � packages/image_picker/image_picker_ios/test/test_api.dart
…ermissions-ios-changes
…ermissions-ios-changes
…ermissions-ios-changes
@cyanglaz I've fixed the code based on your latest remarks. Right now, I can't see an option to request your another review, so I'm pinging through this comment :) |
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.
LGTM
cc @stuartmorgan
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.
A couple of small things, but otherwise looks good.
@@ -234,7 +249,11 @@ - (void)pickVideoWithSource:(nonnull FLTSourceSpecification *)source | |||
camera:[self cameraDeviceForSource:source]]; | |||
break; | |||
case FLTSourceTypeGallery: | |||
[self checkPhotoAuthorizationWithImagePicker:imagePickerController]; | |||
if (context.requestFullMetadata) { |
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.
Looks like this is still missing the iOS 11 @available
check.
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart'; | ||
|
||
import 'src/messages.g.dart'; |
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.
Why did you change this to a package-style import within the same package?
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 was checking if it could fix an issue with imports related to Pigeon, but then I've found a GitHub issue about it and forgot to revert this change. I'll do it now.
…ermissions-ios-changes
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.
LGTM!
|
…rmissions) - iOS changes (flutter/plugins#5713)
…rmissions) - iOS changes (flutter/plugins#5713)
Thanks for the great work! |
It's already available, note it's |
The PR you'll want to follow to know when you can use this feature as a plugin client is #5915 |
Just tried to implement that in my app and seems as it crashes due to permission issue after picking photos. |
Description
iOS changes for #5915
Related issues
flutter/flutter#65995
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.///
).