-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker] add requestFullMetadata for iOS (optional permissions) - iOS changes #5713
Changes from 5 commits
c705774
bf73c73
d48e642
3b3435f
420a4c4
ca15f9e
dff7042
b9c4cef
b3d81e3
d95b117
4a41df1
932ae7c
2424828
5685468
2464c13
9252583
09a264a
6aaa4b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 |
||
video_player: ^2.1.4 | ||
|
||
dev_dependencies: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,11 @@ - (void)launchPHPickerWithContext:(nonnull FLTImagePickerMethodCallContext *)con | |
_pickerViewController.presentationController.delegate = self; | ||
self.callContext = context; | ||
|
||
[self checkPhotoAuthorizationForAccessLevel]; | ||
if (context.requestFullMetadata) { | ||
[self checkPhotoAuthorizationForAccessLevel]; | ||
} else { | ||
[self showPhotoLibraryWithPHPicker:_pickerViewController]; | ||
} | ||
} | ||
|
||
- (void)launchUIImagePickerWithSource:(nonnull FLTSourceSpecification *)source | ||
|
@@ -136,7 +140,16 @@ - (void)launchUIImagePickerWithSource:(nonnull FLTSourceSpecification *)source | |
camera:[self cameraDeviceForSource:source]]; | ||
break; | ||
case FLTSourceTypeGallery: | ||
[self checkPhotoAuthorizationWithImagePicker:imagePickerController]; | ||
if (@available(iOS 11, *)) { | ||
if (context.requestFullMetadata) { | ||
[self checkPhotoAuthorizationWithImagePicker:imagePickerController]; | ||
} else { | ||
[self showPhotoLibraryWithImagePicker:imagePickerController]; | ||
} | ||
} else { | ||
// Prior to iOS 11, accessing gallery requires authorization | ||
[self checkPhotoAuthorizationWithImagePicker:imagePickerController]; | ||
} | ||
break; | ||
default: | ||
[self sendCallResultWithError:[FlutterError errorWithCode:@"invalid_source" | ||
|
@@ -151,6 +164,7 @@ - (void)launchUIImagePickerWithSource:(nonnull FLTSourceSpecification *)source | |
- (void)pickImageWithSource:(nonnull FLTSourceSpecification *)source | ||
maxSize:(nonnull FLTMaxSize *)maxSize | ||
quality:(nullable NSNumber *)imageQuality | ||
fullMetadata:(NSNumber *)fullMetadata | ||
completion: | ||
(nonnull void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { | ||
[self cancelInProgressCall]; | ||
|
@@ -166,6 +180,7 @@ - (void)pickImageWithSource:(nonnull FLTSourceSpecification *)source | |
context.maxSize = maxSize; | ||
context.imageQuality = imageQuality; | ||
context.maxImageCount = 1; | ||
context.requestFullMetadata = [fullMetadata boolValue]; | ||
|
||
if (source.type == FLTSourceTypeGallery) { // Capture is not possible with PHPicker | ||
if (@available(iOS 14, *)) { | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this need the same There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is still missing the iOS 11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed usage of |
||
[self checkPhotoAuthorizationWithImagePicker:imagePickerController]; | ||
} else { | ||
[self showPhotoLibraryWithImagePicker:imagePickerController]; | ||
} | ||
break; | ||
default: | ||
[self sendCallResultWithError:[FlutterError errorWithCode:@"invalid_source" | ||
|
@@ -554,7 +573,11 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |
NSNumber *imageQuality = self.callContext.imageQuality; | ||
NSNumber *desiredImageQuality = [self getDesiredImageQuality:imageQuality]; | ||
|
||
PHAsset *originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
PHAsset *originalAsset; | ||
if (_callContext.requestFullMetadata) { | ||
// Full metadata are available only in PHAsset, which requires gallery permission. | ||
originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
} | ||
|
||
if (maxWidth != nil || maxHeight != nil) { | ||
image = [FLTImagePickerImageUtil scaledImage:image | ||
|
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.
nits: do not use +new
https://google.github.io/styleguide/objcguide.html#do-not-use-new