From cfac209da8e9c7cd2b45d184a2db8b79f3709bcf Mon Sep 17 00:00:00 2001 From: Zack Story Date: Sun, 3 Apr 2016 11:19:31 -0700 Subject: [PATCH] [permissions] rename checkCameraAuthorizationStatus to checkVideoAuthorizationStatus --- Camera.js | 2 +- ios/RCTCameraManager.m | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Camera.js b/Camera.js index 6808e3a..f83d8de 100644 --- a/Camera.js +++ b/Camera.js @@ -113,7 +113,7 @@ export default class Camera extends Component { }; static checkDeviceAuthorizationStatus = CameraManager.checkDeviceAuthorizationStatus; - static checkVideoAuthorizationStatus = CameraManager.checkCameraAuthorizationStatus; + static checkVideoAuthorizationStatus = CameraManager.checkVideoAuthorizationStatus; static checkAudioAuthorizationStatus = CameraManager.checkAudioAuthorizationStatus; setNativeProps(props) { diff --git a/ios/RCTCameraManager.m b/ios/RCTCameraManager.m index 3778b19..c14c553 100644 --- a/ios/RCTCameraManager.m +++ b/ios/RCTCameraManager.m @@ -23,7 +23,7 @@ RCT_EXPORT_MODULE(); - (UIView *)view { self.session = [AVCaptureSession new]; - + self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session]; self.previewLayer.needsDisplayOnBoundsChange = YES; @@ -173,7 +173,7 @@ RCT_EXPORT_METHOD(checkDeviceAuthorizationStatus:(RCTPromiseResolveBlock)resolve } -RCT_EXPORT_METHOD(checkCameraAuthorizationStatus:(RCTPromiseResolveBlock)resolve +RCT_EXPORT_METHOD(checkVideoAuthorizationStatus:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject) { __block NSString *mediaType = AVMediaTypeVideo; @@ -185,7 +185,7 @@ RCT_EXPORT_METHOD(checkCameraAuthorizationStatus:(RCTPromiseResolveBlock)resolve RCT_EXPORT_METHOD(checkAudioAuthorizationStatus:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject) { __block NSString *mediaType = AVMediaTypeAudio; - + [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) { resolve(@(granted)); }]; @@ -258,7 +258,7 @@ RCT_EXPORT_METHOD(changeOrientation:(NSInteger)orientation) { self.previewLayer.connection.videoOrientation = orientation; } } - + RCT_EXPORT_METHOD(changeMirrorImage:(BOOL)mirrorImage) { self.mirrorImage = mirrorImage; } @@ -554,18 +554,18 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej else if (target == RCTCameraCaptureTargetDisk) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths firstObject]; - + NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [[documentsDirectory stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]] stringByAppendingPathExtension:@"jpg"]; - + [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; responseString = fullPath; } - + else if (target == RCTCameraCaptureTargetTemp) { NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString]; NSString *fullPath = [NSString stringWithFormat:@"%@%@.jpg", NSTemporaryDirectory(), fileName]; - + [imageData writeToFile:fullPath atomically:YES]; responseString = fullPath; } @@ -711,10 +711,10 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL else if (self.videoTarget == RCTCameraCaptureTargetTemp) { NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString]; NSString *fullPath = [NSString stringWithFormat:@"%@%@.mov", NSTemporaryDirectory(), fileName]; - + NSFileManager * fileManager = [NSFileManager defaultManager]; NSError * error = nil; - + //moving to destination if (!([fileManager moveItemAtPath:[outputFileURL path] toPath:fullPath error:&error])) { self.videoReject(RCTErrorUnspecified, nil, RCTErrorWithMessage(error.description)); @@ -734,7 +734,7 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL if (metadata.type == barcodeType) { // Transform the meta-data coordinates to screen coords AVMetadataMachineReadableCodeObject *transformed = (AVMetadataMachineReadableCodeObject *)[_previewLayer transformedMetadataObjectForMetadataObject:metadata]; - + NSDictionary *event = @{ @"type": metadata.type, @"data": metadata.stringValue, @@ -868,7 +868,7 @@ didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL @"zoomFactor": [NSNumber numberWithDouble:zoomFactor], @"velocity": [NSNumber numberWithDouble:velocity] }; - + [self.bridge.eventDispatcher sendInputEventWithName:@"zoomChanged" body:event]; device.videoZoomFactor = zoomFactor;