This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[image_picker] optionally disable PHAsset & iOS permission request #3090
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result | |
_arguments = call.arguments; | ||
|
||
int imageSource = [[_arguments objectForKey:@"source"] intValue]; | ||
BOOL usePhaAsset = [[_arguments objectForKey:@"iosPhaAsset"] boolValue]; | ||
|
||
switch (imageSource) { | ||
case SOURCE_CAMERA: { | ||
|
@@ -86,7 +87,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result | |
break; | ||
} | ||
case SOURCE_GALLERY: | ||
[self checkPhotoAuthorization]; | ||
if (usePhaAsset) { | ||
[self checkPhotoAuthorization]; | ||
break; | ||
} | ||
[self showPhotoLibrary]; | ||
break; | ||
default: | ||
result([FlutterError errorWithCode:@"invalid_source" | ||
|
@@ -108,6 +113,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result | |
_arguments = call.arguments; | ||
|
||
int imageSource = [[_arguments objectForKey:@"source"] intValue]; | ||
BOOL usePhaAsset = [[_arguments objectForKey:@"iosPhaAsset"] boolValue]; | ||
if ([[_arguments objectForKey:@"maxDuration"] isKindOfClass:[NSNumber class]]) { | ||
NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; | ||
_imagePickerController.videoMaximumDuration = max; | ||
|
@@ -118,7 +124,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result | |
[self checkCameraAuthorization]; | ||
break; | ||
case SOURCE_GALLERY: | ||
[self checkPhotoAuthorization]; | ||
if (usePhaAsset) { | ||
[self checkPhotoAuthorization]; | ||
break; | ||
} | ||
[self showPhotoLibrary]; | ||
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. As above, this may need a check for iOS 11 or higher |
||
break; | ||
default: | ||
result([FlutterError errorWithCode:@"invalid_source" | ||
|
@@ -299,6 +309,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |
NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; | ||
NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; | ||
NSNumber *imageQuality = [_arguments objectForKey:@"imageQuality"]; | ||
BOOL usePhaAsset = [[_arguments objectForKey:@"iosPhaAsset"] boolValue]; | ||
|
||
if (![imageQuality isKindOfClass:[NSNumber class]]) { | ||
imageQuality = @1; | ||
|
@@ -312,7 +323,10 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |
image = [FLTImagePickerImageUtil scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; | ||
} | ||
|
||
PHAsset *originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
PHAsset *originalAsset; | ||
if (usePhaAsset) { | ||
originalAsset = [FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:info]; | ||
} | ||
if (!originalAsset) { | ||
// Image picked without an original asset (e.g. User took a photo directly) | ||
[self saveImageWithPickerInfo:info image:image imageQuality:imageQuality]; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 may actually need a check for iOS 11 or higher