-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[image_picker] Image picker fix alert #3881
Changes from 7 commits
e13dc30
1117af5
5178493
6d7c1a4
5be7968
40decd7
96f98cb
f59451f
0c8c105
64ae3ef
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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,6 @@ | ||||||
| ## 0.7.6 | ||||||
| * Implement UIAlertController with a preferredStyle of UIAlertControllerStyleAlert since UIAlertView is deprecated. | ||||||
|
Contributor
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. nit: add back-ticks to indicate the
Suggested change
Contributor
Author
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. done. |
||||||
|
|
||||||
| ## 0.7.5+1 | ||||||
|
|
||||||
| * Fixes a rotation problem where Select Photos limited access is chosen but the image that is picked | ||||||
|
|
@@ -7,7 +10,7 @@ is not included selected photos and image is scaled. | |||||
|
|
||||||
| * Fixes an issue where image rotation is wrong when Select Photos chose and image is scaled. | ||||||
| * Migrate to PHPicker for iOS 14 and higher versions to pick image from the photo library. | ||||||
| * Implement the limited permission to pick photo from the photo library when Select Photo is chose. | ||||||
| * Implement the limited permission to pick photo from the photo library when Select Photo is chosen. | ||||||
|
|
||||||
| ## 0.7.4 | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,11 +190,17 @@ - (void)showCamera { | |
| animated:YES | ||
| completion:nil]; | ||
| } else { | ||
| [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) | ||
| message:NSLocalizedString(@"Camera not available.", nil) | ||
| delegate:nil | ||
| cancelButtonTitle:NSLocalizedString(@"OK", nil) | ||
| otherButtonTitles:nil] show]; | ||
| UIAlertController *cameraErrorAlert = | ||
| [UIAlertController alertControllerWithTitle:@"Error" | ||
| message:@"Camera not available." | ||
| preferredStyle:UIAlertControllerStyleAlert]; | ||
| [cameraErrorAlert addAction:[UIAlertAction actionWithTitle:@"OK" | ||
| style:UIAlertActionStyleDefault | ||
| handler:^(UIAlertAction *action){ | ||
| }]]; | ||
| [[self viewControllerWithWindow:nil] presentViewController:cameraErrorAlert | ||
| animated:YES | ||
| completion:nil]; | ||
| self.result(nil); | ||
| self.result = nil; | ||
| _arguments = nil; | ||
|
|
@@ -211,17 +217,15 @@ - (void)checkCameraAuthorization { | |
| case AVAuthorizationStatusNotDetermined: { | ||
| [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo | ||
| completionHandler:^(BOOL granted) { | ||
| if (granted) { | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| if (granted) { | ||
| if (granted) { | ||
|
Contributor
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. Why the double
Contributor
Author
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. it is fixed. |
||
| [self showCamera]; | ||
| } | ||
| }); | ||
| } else { | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| } else { | ||
| [self errorNoCameraAccess:AVAuthorizationStatusDenied]; | ||
| }); | ||
| } | ||
| } | ||
| }); | ||
| }]; | ||
| }; break; | ||
| case AVAuthorizationStatusDenied: | ||
|
|
@@ -364,41 +368,39 @@ - (void)picker:(PHPickerViewController *)picker | |
| completionHandler:^(__kindof id<NSItemProviderReading> _Nullable image, | ||
| NSError *_Nullable error) { | ||
| if ([image isKindOfClass:[UIImage class]]) { | ||
| if (image != nil) { | ||
| __block UIImage *localImage = image; | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| PHAsset *originalAsset = | ||
| [FLTImagePickerPhotoAssetUtil getAssetFromPHPickerResult:result]; | ||
|
|
||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| localImage = [FLTImagePickerImageUtil scaledImage:localImage | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight | ||
| isMetadataAvailable:originalAsset != nil]; | ||
| } | ||
|
|
||
| if (!originalAsset) { | ||
| // Image picked without an original asset (e.g. User took a photo directly) | ||
| [self saveImageWithPickerInfo:nil | ||
| image:localImage | ||
| imageQuality:desiredImageQuality]; | ||
| } else { | ||
| [[PHImageManager defaultManager] | ||
| requestImageDataForAsset:originalAsset | ||
| options:nil | ||
| resultHandler:^( | ||
| NSData *_Nullable imageData, NSString *_Nullable dataUTI, | ||
| UIImageOrientation orientation, NSDictionary *_Nullable info) { | ||
| // maxWidth and maxHeight are used only for GIF images. | ||
| [self saveImageWithOriginalImageData:imageData | ||
| image:localImage | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight | ||
| imageQuality:desiredImageQuality]; | ||
| }]; | ||
| } | ||
| }); | ||
| } | ||
| __block UIImage *localImage = image; | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| PHAsset *originalAsset = | ||
| [FLTImagePickerPhotoAssetUtil getAssetFromPHPickerResult:result]; | ||
|
|
||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| localImage = [FLTImagePickerImageUtil scaledImage:localImage | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight | ||
| isMetadataAvailable:originalAsset != nil]; | ||
| } | ||
|
|
||
| if (!originalAsset) { | ||
| // Image picked without an original asset (e.g. User took a photo directly) | ||
| [self saveImageWithPickerInfo:nil | ||
| image:localImage | ||
| imageQuality:desiredImageQuality]; | ||
| } else { | ||
| [[PHImageManager defaultManager] | ||
| requestImageDataForAsset:originalAsset | ||
| options:nil | ||
| resultHandler:^( | ||
| NSData *_Nullable imageData, NSString *_Nullable dataUTI, | ||
| UIImageOrientation orientation, NSDictionary *_Nullable info) { | ||
| // maxWidth and maxHeight are used only for GIF images. | ||
| [self saveImageWithOriginalImageData:imageData | ||
| image:localImage | ||
| maxWidth:maxWidth | ||
| maxHeight:maxHeight | ||
| imageQuality:desiredImageQuality]; | ||
| }]; | ||
| } | ||
| }); | ||
| } | ||
| }]; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ name: image_picker | |
| description: Flutter plugin for selecting images from the Android and iOS image | ||
| library, and taking new pictures with the camera. | ||
| homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker | ||
| version: 0.7.5+1 | ||
| version: 0.7.6 | ||
|
Contributor
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. Since there's no public API change, it should be 0.7.5+2
Contributor
Author
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. done. |
||
|
|
||
| flutter: | ||
| plugin: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.