Skip to content
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

Fixes #844 in 0.35.0 #1455

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,13 @@ ImagePicker.clean().then(() => {
| showCropFrame (android only) | bool (default true) | Whether to show crop frame during cropping |
| hideBottomControls (android only) | bool (default false) | Whether to display bottom controls |
| enableRotationGesture (android only) | bool (default false) | Whether to enable rotating the image by hand gesture |
| cropperChooseText (ios only)  |           string (default choose)        | Choose button text |
| cropperChooseText (ios only) | string (default choose) | Choose button text |
| cropperCancelText (ios only) | string (default Cancel) | Cancel button text |
| limitedAlertTitleText (ios only) | string (default Access to photos is limited) | Limited alert title text
| limitedAlertMessageText (ios only) | string (default To access all of your photos, allow access to your full library in device settings.) | Limited alert message text
| limitedAlertCancelText (ios only) | string (default Cancel) | Limited alert cancel option text
| limitedAlertSelectPhotosText (ios only) | string (default Select More Photos) | Limited alert select photos option text
| limitedAlertOpenSettingsText (ios only) | string (default Change Settings) | Limited alert open settings option text

#### Smart Album Types (ios)

Expand Down
44 changes: 42 additions & 2 deletions ios/src/ImageCropPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Copyright © 2016 Facebook. All rights reserved.
//

#import <Photos/Photos.h>
#import <PhotosUI/PhotosUI.h>
#import <MobileCoreServices/MobileCoreServices.h>

#import "ImageCropPicker.h"
Expand Down Expand Up @@ -71,7 +73,12 @@ - (instancetype)init
@"forceJpg": @NO,
@"sortOrder": @"none",
@"cropperCancelText": @"Cancel",
@"cropperChooseText": @"Choose"
@"cropperChooseText": @"Choose",
@"limitedAlertTitleText": @"Access to photos is limited",
@"limitedAlertMessageText": @"To access all of your photos, allow access to your full library in device settings.",
@"limitedAlertCancelText": @"Cancel",
@"limitedAlertSelectPhotosText": @"Select More Photos",
@"limitedAlertOpenSettingsText": @"Change Settings"
};
self.compression = [[Compression alloc] init];
}
Expand Down Expand Up @@ -358,6 +365,39 @@ - (BOOL)cleanTmpDirectory {

[imagePickerController setModalPresentationStyle: UIModalPresentationFullScreen];
[[self getRootVC] presentViewController:imagePickerController animated:YES completion:nil];

#ifdef __IPHONE_14_0
if (@available(iOS 14, *)) {
// if limited show alert texts:
PHAuthorizationStatus accessLevel = [PHPhotoLibrary authorizationStatusForAccessLevel: PHAccessLevelReadWrite];
if (accessLevel == PHAuthorizationStatusLimited) {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:[self.options objectForKey:@"limitedAlertTitleText"]
message:[self.options objectForKey:@"limitedAlertMessageText"]
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* selectPhotos = [UIAlertAction actionWithTitle:[self.options objectForKey:@"limitedAlertSelectPhotosText"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[PHPhotoLibrary sharedPhotoLibrary] presentLimitedLibraryPickerFromViewController:imagePickerController];
}];
UIAlertAction* openSetttings = [UIAlertAction actionWithTitle:[self.options objectForKey:@"limitedAlertOpenSettingsText"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[application openURL:URL options:@{} completionHandler:nil];
}];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:[self.options objectForKey:@"limitedAlertCancelText"]
style:UIAlertActionStyleCancel
handler:nil];

[alert addAction:selectPhotos];
[alert addAction:openSetttings];
[alert addAction:defaultAction];
[[self getRootVC] presentViewController:alert animated:YES completion:nil];
}
}
#endif
});
}];
}
Expand Down Expand Up @@ -902,7 +942,7 @@ - (void)cropViewController:(TOCropViewController *)cropViewController didCropToI

- (void)cropViewController:(TOCropViewController *)cropViewController didFinishCancelled:(BOOL)cancelled {
[self dismissCropper:cropViewController selectionDone:NO completion:[self waitAnimationEnd:^{
if (self.currentSelectionMode == CROPPING) {
if (self.currentSelectionMode == CROPPING || self.currentSelectionMode == CAMERA) {
self.reject(ERROR_PICKER_CANCEL_KEY, ERROR_PICKER_CANCEL_MSG, nil);
}
}]];
Expand Down