diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/Camera.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/Camera.java index fcf4648aa2..fdbb2509f7 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/Camera.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/Camera.java @@ -103,10 +103,13 @@ private void doShow(PluginCall call) { private void showPrompt(final PluginCall call) { // We have all necessary permissions, open the camera + String promptLabelPhoto = call.getString("promptLabelPhoto", "From Photos"); + String promptLabelPicture = call.getString("promptLabelPicture", "Take Picture"); + JSObject fromPhotos = new JSObject(); - fromPhotos.put("title", "From Photos"); + fromPhotos.put("title", promptLabelPhoto); JSObject takePicture = new JSObject(); - takePicture.put("title", "Take Picture"); + takePicture.put("title", promptLabelPicture); Object[] options = new Object[] { fromPhotos, takePicture diff --git a/core/src/core-plugin-definitions.ts b/core/src/core-plugin-definitions.ts index fdf2df90ff..c45e848242 100644 --- a/core/src/core-plugin-definitions.ts +++ b/core/src/core-plugin-definitions.ts @@ -342,6 +342,19 @@ export interface CameraOptions { * iOS only: The presentation style of the Camera. Defaults to fullscreen. */ presentationStyle?: 'fullscreen' | 'popover'; + + /** + * If use CameraSource.Prompt only, can change Prompt label. + * default: + * promptLabelHeader : 'Photo' // iOS only + * promptLabelCancel : 'Cancel' // iOS only + * promptLabelPhoto : 'From Photos' + * promptLabelPicture : 'Take Picture' + */ + promptLabelHeader?: string; + promptLabelCancel?: string; + promptLabelPhoto?: string; + promptLabelPicture?: string; } export enum CameraSource { diff --git a/ios/Capacitor/Capacitor/Plugins/Camera.swift b/ios/Capacitor/Capacitor/Plugins/Camera.swift index f086940d7d..a2561d3d01 100644 --- a/ios/Capacitor/Capacitor/Plugins/Camera.swift +++ b/ios/Capacitor/Capacitor/Plugins/Camera.swift @@ -101,16 +101,21 @@ public class CAPCameraPlugin : CAPPlugin, UIImagePickerControllerDelegate, UINav func showPrompt(_ call: CAPPluginCall) { // Build the action sheet - let alert = UIAlertController(title: "Photo", message: nil, preferredStyle: UIAlertController.Style.actionSheet) - alert.addAction(UIAlertAction(title: "From Photos", style: .default, handler: { (action: UIAlertAction) in + let promptLabelHeader = call.getString("promptLabelHeader") ?? "Photo" + let promptLabelPhoto = call.getString("promptLabelPhoto") ?? "From Photos" + let promptLabelPicture = call.getString("promptLabelPicture") ?? "Take Picture" + let promptLabelCancel = call.getString("promptLabelCancel") ?? "Cancel" + + let alert = UIAlertController(title: promptLabelHeader, message: nil, preferredStyle: UIAlertController.Style.actionSheet) + alert.addAction(UIAlertAction(title: promptLabelPhoto, style: .default, handler: { (action: UIAlertAction) in self.showPhotos(call) })) - alert.addAction(UIAlertAction(title: "Take Picture", style: .default, handler: { (action: UIAlertAction) in + alert.addAction(UIAlertAction(title: promptLabelPicture, style: .default, handler: { (action: UIAlertAction) in self.showCamera(call) })) - alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction) in + alert.addAction(UIAlertAction(title: promptLabelCancel, style: .cancel, handler: { (action: UIAlertAction) in self.call?.error("User cancelled photos app") }))