From 1a62cc45f1701ba447483dff153fe5c97c2336c6 Mon Sep 17 00:00:00 2001
From: "pavel.k" <pavel.k@scopicsoftware.com>
Date: Sat, 11 Feb 2017 04:05:51 +0300
Subject: [PATCH] Added media type param

---
 ios/ImageCropPicker.m | 13 ++++++++-----
 package.json          |  4 ++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/ios/ImageCropPicker.m b/ios/ImageCropPicker.m
index 56191d9..22a591a 100644
--- a/ios/ImageCropPicker.m
+++ b/ios/ImageCropPicker.m
@@ -50,6 +50,7 @@ RCT_EXPORT_MODULE();
                                 @"multiple": @NO,
                                 @"cropping": @NO,
                                 @"cropperCircleOverlay": @NO,
+                                @"media": @"photo", // @"video" @"all"
                                 @"includeBase64": @NO,
                                 @"compressVideo": @YES,
                                 @"maxFiles": @5,
@@ -66,14 +67,14 @@ RCT_EXPORT_MODULE();
     return self;
 }
 
-- (void)checkCameraPermissions:(void(^)(BOOL granted))callback
+- (void)checkCameraPermissions:(NSString *)avMediaType completion(void(^)(BOOL granted))callback
 {
-    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
+    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:avMediaType];
     if (status == AVAuthorizationStatusAuthorized) {
         callback(YES);
         return;
     } else if (status == AVAuthorizationStatusNotDetermined){
-        [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
+        [AVCaptureDevice requestAccessForMediaType:avMediaType completionHandler:^(BOOL granted) {
             callback(granted);
             return;
         }];
@@ -114,7 +115,7 @@ RCT_EXPORT_METHOD(openCamera:(NSDictionary *)options
     self.reject(ERROR_PICKER_CANNOT_RUN_CAMERA_ON_SIMULATOR_KEY, ERROR_PICKER_CANNOT_RUN_CAMERA_ON_SIMULATOR_MSG, nil);
     return;
 #else
-    [self checkCameraPermissions:^(BOOL granted) {
+    [self checkCameraPermissions:(([[self.options objectForKey:@"cropping"] boolValue] || [[self.options objectForKey:@"media"] isEqualToString:@"photo"]) ? AVMediaTypePhoto : AVMediaTypeVideo) completion^(BOOL granted) {
         if (!granted) {
             self.reject(ERROR_PICKER_NO_CAMERA_PERMISSION_KEY, ERROR_PICKER_NO_CAMERA_PERMISSION_MSG, nil);
             return;
@@ -235,8 +236,10 @@ RCT_EXPORT_METHOD(openPicker:(NSDictionary *)options
                 imagePickerController.assetCollectionSubtypes = albumsToShow;
             }
 
-            if ([[self.options objectForKey:@"cropping"] boolValue]) {
+            if ([[self.options objectForKey:@"cropping"] boolValue] || [[self.options objectForKey:@"media"] isEqualToString:@"photo"]) {
                 imagePickerController.mediaType = QBImagePickerMediaTypeImage;
+            } else if ([[self.options objectForKey:@"media"] isEqualToString:@"video"]){
+                imagePickerController.mediaType = QBImagePickerMediaTypeVideo;
             } else {
                 imagePickerController.mediaType = QBImagePickerMediaTypeAny;
             }
diff --git a/package.json b/package.json
index 7148320..02eefdf 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
-  "name": "react-native-image-crop-picker",
+  "name": "react-native-image-crop-picker-media",
   "version": "0.12.3",
   "description": "Select single or multiple images, with croping option",
   "main": "index.js",
@@ -22,7 +22,7 @@
     "multiple",
     "camera"
   ],
-  "author": "Ivan Pusic",
+  "author": "Root",
   "license": "MIT",
   "bugs": {
     "url": "https://github.com/ivpusic/react-native-image-crop-picker/issues"
-- 
2.6.2

From db481471ec848d0072a90953f71050f7838eb6b1 Mon Sep 17 00:00:00 2001
From: rootpksr <rootpksr@gmail.com>
Date: Sat, 11 Feb 2017 04:23:33 +0300
Subject: [PATCH] Compile fix

---
 ios/ImageCropPicker.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ios/ImageCropPicker.m b/ios/ImageCropPicker.m
index 22a591a..2d58a55 100644
--- a/ios/ImageCropPicker.m
+++ b/ios/ImageCropPicker.m
@@ -67,7 +67,7 @@ RCT_EXPORT_MODULE();
     return self;
 }
 
-- (void)checkCameraPermissions:(NSString *)avMediaType completion(void(^)(BOOL granted))callback
+- (void)checkCameraPermissions:(NSString *)avMediaType completion:(void(^)(BOOL granted))callback
 {
     AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:avMediaType];
     if (status == AVAuthorizationStatusAuthorized) {
-- 
2.6.2

From c6cd54d01dc7845e1838945c511f9851b1402e8c Mon Sep 17 00:00:00 2001
From: rootpksr <rootpksr@gmail.com>
Date: Sat, 11 Feb 2017 05:48:57 +0300
Subject: [PATCH] Camera permissions

---
 ios/ImageCropPicker.m | 47 ++++++++++++++++++++++++++++-------------------
 package.json          |  2 +-
 2 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/ios/ImageCropPicker.m b/ios/ImageCropPicker.m
index 2d58a55..fedcfeb 100644
--- a/ios/ImageCropPicker.m
+++ b/ios/ImageCropPicker.m
@@ -114,28 +114,37 @@ RCT_EXPORT_METHOD(openCamera:(NSDictionary *)options
 #if TARGET_IPHONE_SIMULATOR
     self.reject(ERROR_PICKER_CANNOT_RUN_CAMERA_ON_SIMULATOR_KEY, ERROR_PICKER_CANNOT_RUN_CAMERA_ON_SIMULATOR_MSG, nil);
     return;
-#else
-    [self checkCameraPermissions:(([[self.options objectForKey:@"cropping"] boolValue] || [[self.options objectForKey:@"media"] isEqualToString:@"photo"]) ? AVMediaTypePhoto : AVMediaTypeVideo) completion^(BOOL granted) {
-        if (!granted) {
-            self.reject(ERROR_PICKER_NO_CAMERA_PERMISSION_KEY, ERROR_PICKER_NO_CAMERA_PERMISSION_MSG, nil);
-            return;
-        }
-
-        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
-        picker.delegate = self;
-        picker.allowsEditing = NO;
-        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
-        if ([[self.options objectForKey:@"useFrontCamera"] boolValue]) {
-            picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
-        }
-
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [[self getRootVC] presentViewController:picker animated:YES completion:nil];
-        });
-    }];
+    
+    if ([[self.options objectForKey:@"cropping"] boolValue] || [[self.options objectForKey:@"media"] isEqualToString:@"photo"]) {
+        [self cameraPermissionsGranted];
+    } else {
+        [self checkCameraPermissions:AVMediaTypeVideo completion:^(BOOL granted) {
+            if (!granted) {
+                self.reject(ERROR_PICKER_NO_CAMERA_PERMISSION_KEY, ERROR_PICKER_NO_CAMERA_PERMISSION_MSG, nil);
+                return;
+            }
+            
+            [self cameraPermissionsGranted];
+        }];
+    }
+    
 #endif
 }
 
+- (void)cameraPermissionsGranted {
+    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
+    picker.delegate = self;
+    picker.allowsEditing = NO;
+    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
+    if ([[self.options objectForKey:@"useFrontCamera"] boolValue]) {
+        picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
+    }
+    
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [[self getRootVC] presentViewController:picker animated:YES completion:nil];
+    });
+}
+
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
     UIImage *chosenImage = [info objectForKey:UIImagePickerControllerOriginalImage];
     [self processSingleImagePick:chosenImage withViewController:picker];
diff --git a/package.json b/package.json
index 02eefdf..396c74f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "react-native-image-crop-picker-media",
-  "version": "0.12.3",
+  "version": "0.12.6",
   "description": "Select single or multiple images, with croping option",
   "main": "index.js",
   "scripts": {
-- 
2.6.2

From 27c6a9bc8da9b15e5c7e31d58a0779d0510262ae Mon Sep 17 00:00:00 2001
From: rootpksr <rootpksr@gmail.com>
Date: Thu, 16 Feb 2017 11:41:56 +0300
Subject: [PATCH] Headers changes

---
 ios/imageCropPicker.xcodeproj/project.pbxproj | 10 ----------
 package.json                                  |  2 +-
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/ios/imageCropPicker.xcodeproj/project.pbxproj b/ios/imageCropPicker.xcodeproj/project.pbxproj
index 85f4d93..4574cb9 100644
--- a/ios/imageCropPicker.xcodeproj/project.pbxproj
+++ b/ios/imageCropPicker.xcodeproj/project.pbxproj
@@ -300,11 +300,6 @@
 			buildSettings = {
 				EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
 				FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/RSKImageCropper/build/Debug-iphoneos";
-				HEADER_SEARCH_PATHS = (
-					"$(inherited)",
-					"$(SRCROOT)/../example/node_modules/react-native/React/**",
-					"$(SRCROOT)/../example/node_modules/react-native/Libraries/Image/**",
-				);
 				LD_RUNPATH_SEARCH_PATHS = "";
 				ONLY_ACTIVE_ARCH = NO;
 				OTHER_LDFLAGS = (
@@ -321,11 +316,6 @@
 			buildSettings = {
 				EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
 				FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/RSKImageCropper/build/Debug-iphoneos";
-				HEADER_SEARCH_PATHS = (
-					"$(inherited)",
-					"$(SRCROOT)/../example/node_modules/react-native/React/**",
-					"$(SRCROOT)/../example/node_modules/react-native/Libraries/Image/**",
-				);
 				LD_RUNPATH_SEARCH_PATHS = "";
 				OTHER_LDFLAGS = (
 					"-ObjC",
diff --git a/package.json b/package.json
index 396c74f..aa2f304 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "react-native-image-crop-picker-media",
-  "version": "0.12.6",
+  "version": "0.12.7",
   "description": "Select single or multiple images, with croping option",
   "main": "index.js",
   "scripts": {
-- 
2.6.2

