diff --git a/src/android/CameraPreviewFragment.java b/src/android/CameraPreviewFragment.java index b904749..94eaa52 100644 --- a/src/android/CameraPreviewFragment.java +++ b/src/android/CameraPreviewFragment.java @@ -370,7 +370,7 @@ public void setLocation(Location loc) { } - public void switchToUltraWideCamera(String device, CameraSwitchedCallback cameraSwitchedCallback) { + public void switchCameraTo(String device, CameraSwitchedCallback cameraSwitchedCallback) { Handler mainHandler = new Handler(Looper.getMainLooper()); mainHandler.post(new Runnable() { @SuppressLint("RestrictedApi") diff --git a/src/android/SimpleCameraPreview.java b/src/android/SimpleCameraPreview.java index 10f3443..98658df 100644 --- a/src/android/SimpleCameraPreview.java +++ b/src/android/SimpleCameraPreview.java @@ -78,8 +78,8 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo case "deviceHasUltraWideCamera": return deviceHasUltraWideCamera(callbackContext); - case "switchToUltraWideCamera": - return switchToUltraWideCamera(args.getString(0), callbackContext); + case "switchCameraTo": + return switchCameraTo(args.getString(0), callbackContext); default: break; } @@ -337,13 +337,13 @@ public void run() { } } - private boolean switchToUltraWideCamera(String device, CallbackContext callbackContext) { + private boolean switchCameraTo(String device, CallbackContext callbackContext) { if (fragment == null) { callbackContext.error("Camera is closed, cannot switch camera"); return true; } - fragment.switchToUltraWideCamera(device, (boolean result) -> { + fragment.switchCameraTo(device, (boolean result) -> { PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result); callbackContext.sendPluginResult(pluginResult); }); diff --git a/src/ios/CameraSessionManager.h b/src/ios/CameraSessionManager.h index cfb1f05..d3c82be 100644 --- a/src/ios/CameraSessionManager.h +++ b/src/ios/CameraSessionManager.h @@ -8,7 +8,7 @@ - (void) setupSession:(NSString *)defaultCamera completion:(void(^)(BOOL started))completion options:(NSDictionary *)options photoSettings:(AVCapturePhotoSettings *)photoSettings; - (void) setFlashMode:(NSInteger)flashMode photoSettings:(AVCapturePhotoSettings *)photoSettings; - (void) torchSwitch:(NSInteger)torchState; -- (void) switchToUltraWideCamera:(NSString *)cameraMode completion:(void (^)(BOOL success))completion; +- (void) switchCameraTo:(NSString *)cameraMode completion:(void (^)(BOOL success))completion; - (BOOL) deviceHasUltraWideCamera; - (void) updateOrientation:(AVCaptureVideoOrientation)orientation; - (AVCaptureVideoOrientation) getCurrentOrientation:(UIInterfaceOrientation)toInterfaceOrientation; diff --git a/src/ios/CameraSessionManager.m b/src/ios/CameraSessionManager.m index 0183542..fe1b3de 100644 --- a/src/ios/CameraSessionManager.m +++ b/src/ios/CameraSessionManager.m @@ -176,7 +176,7 @@ - (void) torchSwitch:(NSInteger)torchState{ } } -- (void)switchToUltraWideCamera:(NSString*)cameraMode completion:(void (^)(BOOL success))completion { +- (void)switchCameraTo:(NSString*)cameraMode completion:(void (^)(BOOL success))completion { if (![self deviceHasUltraWideCamera]) { if (completion) { completion(NO); @@ -221,8 +221,6 @@ - (void)switchToUltraWideCamera:(NSString*)cameraMode completion:(void (^)(BOOL } else { NSLog(@"Ultra-wide camera not found"); } - } else { - // Fallback on earlier versions } completion ? completion(cameraSwitched): NULL; diff --git a/src/ios/SimpleCameraPreview.h b/src/ios/SimpleCameraPreview.h index 8ddbc69..0e77694 100644 --- a/src/ios/SimpleCameraPreview.h +++ b/src/ios/SimpleCameraPreview.h @@ -16,7 +16,7 @@ - (void) capture:(CDVInvokedUrlCommand*)command; - (void) setSize:(CDVInvokedUrlCommand*)command; - (void) torchSwitch: (CDVInvokedUrlCommand*)command; -- (void) switchToUltraWideCamera: (CDVInvokedUrlCommand*) command; +- (void) switchCameraTo: (CDVInvokedUrlCommand*) command; - (void) deviceHasUltraWideCamera: (CDVInvokedUrlCommand*) command; - (void) deviceHasFlash: (CDVInvokedUrlCommand*)command; @property (nonatomic) CameraSessionManager *sessionManager; diff --git a/src/ios/SimpleCameraPreview.m b/src/ios/SimpleCameraPreview.m index 6f4856c..feb5f45 100644 --- a/src/ios/SimpleCameraPreview.m +++ b/src/ios/SimpleCameraPreview.m @@ -156,11 +156,11 @@ - (void) torchSwitch:(CDVInvokedUrlCommand*)command{ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } -- (void) switchToUltraWideCamera:(CDVInvokedUrlCommand*)command{ +- (void) switchCameraTo:(CDVInvokedUrlCommand*)command{ NSString *device = [command.arguments objectAtIndex:0]; BOOL cameraSwitched = FALSE; if (self.sessionManager != nil) { - [self.sessionManager switchToUltraWideCamera: device completion:^(BOOL success) { + [self.sessionManager switchCameraTo: device completion:^(BOOL success) { if (success) { NSLog(@"Camera switched successfully"); CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:TRUE]; diff --git a/www/SimpleCameraPreview.js b/www/SimpleCameraPreview.js index 352b794..7b1b9e8 100755 --- a/www/SimpleCameraPreview.js +++ b/www/SimpleCameraPreview.js @@ -28,10 +28,10 @@ SimpleCameraPreview.torchSwitch = function (options, onSuccess, onError) { exec(onSuccess, onError, PLUGIN_NAME, "torchSwitch", [options]); }; -SimpleCameraPreview.switchToUltraWideCamera = function (options, onSuccess, onError) { +SimpleCameraPreview.switchCameraTo = function (options, onSuccess, onError) { options = options || {}; options.captureDevice = options.captureDevice || "default"; - exec(onSuccess, onError, PLUGIN_NAME, "switchToUltraWideCamera", [options.captureDevice]); + exec(onSuccess, onError, PLUGIN_NAME, "switchCameraTo", [options.captureDevice]); }; SimpleCameraPreview.deviceHasFlash = function (onSuccess, onError) {