mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2026-02-03 00:06:46 +08:00
fix(ios)! remove iPadOS popover code (#941)
- On iPadOS it was possible to configure a popover for setting the position, width and arrow position of the popover. The code used the deprecated `UIPopoverController`, which would have to be fixed. To keep the plugin also maintainable, this was removed. - The popover could repositioned with a `CameraPopoverHandle` on a `window.onorientationchange`. This was removed also. - Removed documentation for popover from `README.md`
This commit is contained in:
77
README.md
77
README.md
@@ -118,12 +118,8 @@ To add these entries into the `info.plist`, you can use the `edit-config` tag in
|
|||||||
* [.EncodingType](#module_Camera.EncodingType) : <code>enum</code>
|
* [.EncodingType](#module_Camera.EncodingType) : <code>enum</code>
|
||||||
* [.MediaType](#module_Camera.MediaType) : <code>enum</code>
|
* [.MediaType](#module_Camera.MediaType) : <code>enum</code>
|
||||||
* [.PictureSourceType](#module_Camera.PictureSourceType) : <code>enum</code>
|
* [.PictureSourceType](#module_Camera.PictureSourceType) : <code>enum</code>
|
||||||
* [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : <code>enum</code>
|
|
||||||
* [.Direction](#module_Camera.Direction) : <code>enum</code>
|
* [.Direction](#module_Camera.Direction) : <code>enum</code>
|
||||||
|
|
||||||
* [CameraPopoverHandle](#module_CameraPopoverHandle)
|
|
||||||
* [CameraPopoverOptions](#module_CameraPopoverOptions)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<a name="module_camera"></a>
|
<a name="module_camera"></a>
|
||||||
@@ -312,7 +308,6 @@ Optional parameters to customize the camera settings.
|
|||||||
| mediaType | <code>[MediaType](#module_Camera.MediaType)</code> | <code>PICTURE</code> | Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. |
|
| mediaType | <code>[MediaType](#module_Camera.MediaType)</code> | <code>PICTURE</code> | Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. |
|
||||||
| correctOrientation | <code>Boolean</code> | | Rotate the image to correct for the orientation of the device during capture. |
|
| correctOrientation | <code>Boolean</code> | | Rotate the image to correct for the orientation of the device during capture. |
|
||||||
| saveToPhotoAlbum | <code>Boolean</code> | | Save the image to the photo album on the device after capture.<br />See [Android Quirks](#cameragetpicturesuccesscallback-errorcallback-options). |
|
| saveToPhotoAlbum | <code>Boolean</code> | | Save the image to the photo album on the device after capture.<br />See [Android Quirks](#cameragetpicturesuccesscallback-errorcallback-options). |
|
||||||
| popoverOptions | <code>[CameraPopoverOptions](#module_CameraPopoverOptions)</code> | | iOS-only options that specify popover location in iPad. |
|
|
||||||
| cameraDirection | <code>[Direction](#module_Camera.Direction)</code> | <code>BACK</code> | Choose the camera to use (front- or back-facing). |
|
| cameraDirection | <code>[Direction](#module_Camera.Direction)</code> | <code>BACK</code> | Choose the camera to use (front- or back-facing). |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -370,24 +365,6 @@ Defines the output format of `Camera.getPicture` call.
|
|||||||
| CAMERA | <code>number</code> | <code>1</code> | Take picture from camera |
|
| CAMERA | <code>number</code> | <code>1</code> | Take picture from camera |
|
||||||
| SAVEDPHOTOALBUM | <code>number</code> | <code>2</code> | Same as `PHOTOLIBRARY`, when running on Android or iOS 14+. On iOS older than 14, an image can only be chosen from the device's Camera Roll album with this setting. |
|
| SAVEDPHOTOALBUM | <code>number</code> | <code>2</code> | Same as `PHOTOLIBRARY`, when running on Android or iOS 14+. On iOS older than 14, an image can only be chosen from the device's Camera Roll album with this setting. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="module_Camera.PopoverArrowDirection"></a>
|
|
||||||
|
|
||||||
### Camera.PopoverArrowDirection : <code>enum</code>
|
|
||||||
Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
|
|
||||||
|
|
||||||
**Kind**: static enum property of <code>[Camera](#module_Camera)</code>
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
| Name | Type | Default |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| ARROW_UP | <code>number</code> | <code>1</code> |
|
|
||||||
| ARROW_DOWN | <code>number</code> | <code>2</code> |
|
|
||||||
| ARROW_LEFT | <code>number</code> | <code>4</code> |
|
|
||||||
| ARROW_RIGHT | <code>number</code> | <code>8</code> |
|
|
||||||
| ARROW_ANY | <code>number</code> | <code>15</code> |
|
|
||||||
|
|
||||||
<a name="module_Camera.Direction"></a>
|
<a name="module_Camera.Direction"></a>
|
||||||
|
|
||||||
### Camera.Direction : <code>enum</code>
|
### Camera.Direction : <code>enum</code>
|
||||||
@@ -401,58 +378,6 @@ Matches iOS UIPopoverArrowDirection constants to specify arrow location on popov
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<a name="module_CameraPopoverOptions"></a>
|
|
||||||
|
|
||||||
## CameraPopoverOptions
|
|
||||||
iOS-only parameters that specify the anchor element location and arrow
|
|
||||||
direction of the popover when selecting images from an iPad's library
|
|
||||||
or album.
|
|
||||||
Note that the size of the popover may change to adjust to the
|
|
||||||
direction of the arrow and orientation of the screen. Make sure to
|
|
||||||
account for orientation changes when specifying the anchor element
|
|
||||||
location.
|
|
||||||
|
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
|
||||||
| --- | --- | --- | --- |
|
|
||||||
| [x] | <code>Number</code> | <code>0</code> | x pixel coordinate of screen element onto which to anchor the popover. |
|
|
||||||
| [y] | <code>Number</code> | <code>32</code> | y pixel coordinate of screen element onto which to anchor the popover. |
|
|
||||||
| [width] | <code>Number</code> | <code>320</code> | width, in pixels, of the screen element onto which to anchor the popover. |
|
|
||||||
| [height] | <code>Number</code> | <code>480</code> | height, in pixels, of the screen element onto which to anchor the popover. |
|
|
||||||
| [arrowDir] | <code>[PopoverArrowDirection](#module_Camera.PopoverArrowDirection)</code> | <code>ARROW_ANY</code> | Direction the arrow on the popover should point. |
|
|
||||||
| [popoverWidth] | <code>Number</code> | <code>0</code> | width of the popover (0 or not specified will use apple's default width). |
|
|
||||||
| [popoverHeight] | <code>Number</code> | <code>0</code> | height of the popover (0 or not specified will use apple's default height). |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<a name="module_CameraPopoverHandle"></a>
|
|
||||||
|
|
||||||
## CameraPopoverHandle
|
|
||||||
A handle to an image picker popover.
|
|
||||||
|
|
||||||
__Supported Platforms__
|
|
||||||
|
|
||||||
- iOS
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
```js
|
|
||||||
navigator.camera.getPicture(onSuccess, onFail,
|
|
||||||
{
|
|
||||||
destinationType: Camera.DestinationType.FILE_URI,
|
|
||||||
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
|
||||||
popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY, 300, 600)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reposition the popover if the orientation changes.
|
|
||||||
window.onorientationchange = function() {
|
|
||||||
var cameraPopoverHandle = new CameraPopoverHandle();
|
|
||||||
var cameraPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY, 400, 500);
|
|
||||||
cameraPopoverHandle.setPosition(cameraPopoverOptions);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
## `camera.getPicture` Errata
|
## `camera.getPicture` Errata
|
||||||
|
|
||||||
#### Example <a name="camera-getPicture-examples"></a>
|
#### Example <a name="camera-getPicture-examples"></a>
|
||||||
@@ -525,7 +450,7 @@ Can only return photos as data URI image.
|
|||||||
|
|
||||||
Including a JavaScript `alert()` in either of the callback functions
|
Including a JavaScript `alert()` in either of the callback functions
|
||||||
can cause problems. Wrap the alert within a `setTimeout()` to allow
|
can cause problems. Wrap the alert within a `setTimeout()` to allow
|
||||||
the iOS image picker or popover to fully close before the alert
|
the iOS image picker to fully close before the alert
|
||||||
displays:
|
displays:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|||||||
12
plugin.xml
12
plugin.xml
@@ -39,10 +39,6 @@
|
|||||||
<clobbers target="Camera" />
|
<clobbers target="Camera" />
|
||||||
</js-module>
|
</js-module>
|
||||||
|
|
||||||
<js-module src="www/CameraPopoverOptions.js" name="CameraPopoverOptions">
|
|
||||||
<clobbers target="CameraPopoverOptions" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<js-module src="www/Camera.js" name="camera">
|
<js-module src="www/Camera.js" name="camera">
|
||||||
<clobbers target="navigator.camera" />
|
<clobbers target="navigator.camera" />
|
||||||
</js-module>
|
</js-module>
|
||||||
@@ -91,10 +87,6 @@
|
|||||||
|
|
||||||
<preference name="ANDROIDX_CORE_VERSION" default="1.6.+"/>
|
<preference name="ANDROIDX_CORE_VERSION" default="1.6.+"/>
|
||||||
<framework src="androidx.core:core:$ANDROIDX_CORE_VERSION" />
|
<framework src="androidx.core:core:$ANDROIDX_CORE_VERSION" />
|
||||||
|
|
||||||
<js-module src="www/CameraPopoverHandle.js" name="CameraPopoverHandle">
|
|
||||||
<clobbers target="CameraPopoverHandle" />
|
|
||||||
</js-module>
|
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
<!-- ios -->
|
<!-- ios -->
|
||||||
@@ -106,10 +98,6 @@
|
|||||||
<preference name="CameraUsesGeolocation" value="false" />
|
<preference name="CameraUsesGeolocation" value="false" />
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<js-module src="www/ios/CameraPopoverHandle.js" name="CameraPopoverHandle">
|
|
||||||
<clobbers target="CameraPopoverHandle" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<header-file src="src/ios/UIImage+CropScaleOrientation.h" />
|
<header-file src="src/ios/UIImage+CropScaleOrientation.h" />
|
||||||
<source-file src="src/ios/UIImage+CropScaleOrientation.m" />
|
<source-file src="src/ios/UIImage+CropScaleOrientation.m" />
|
||||||
<header-file src="src/ios/CDVCamera.h" />
|
<header-file src="src/ios/CDVCamera.h" />
|
||||||
|
|||||||
@@ -72,10 +72,8 @@ typedef NSUInteger CDVMediaType;
|
|||||||
@property (assign) BOOL allowsEditing;
|
@property (assign) BOOL allowsEditing;
|
||||||
@property (assign) BOOL correctOrientation;
|
@property (assign) BOOL correctOrientation;
|
||||||
@property (assign) BOOL saveToPhotoAlbum;
|
@property (assign) BOOL saveToPhotoAlbum;
|
||||||
@property (strong) NSDictionary* popoverOptions;
|
|
||||||
@property (assign) UIImagePickerControllerCameraDevice cameraDirection;
|
@property (assign) UIImagePickerControllerCameraDevice cameraDirection;
|
||||||
|
|
||||||
@property (assign) BOOL popoverSupported;
|
|
||||||
@property (assign) BOOL usesGeolocation;
|
@property (assign) BOOL usesGeolocation;
|
||||||
@property (assign) BOOL cropToSize;
|
@property (assign) BOOL cropToSize;
|
||||||
|
|
||||||
@@ -89,7 +87,6 @@ typedef NSUInteger CDVMediaType;
|
|||||||
|
|
||||||
@property (copy) NSString* callbackId;
|
@property (copy) NSString* callbackId;
|
||||||
@property (copy) NSString* postUrl;
|
@property (copy) NSString* postUrl;
|
||||||
@property (strong) UIPopoverController* pickerPopoverController;
|
|
||||||
@property (assign) BOOL cropToSize;
|
@property (assign) BOOL cropToSize;
|
||||||
@property (strong) UIView* webView;
|
@property (strong) UIView* webView;
|
||||||
|
|
||||||
@@ -103,14 +100,12 @@ typedef NSUInteger CDVMediaType;
|
|||||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 // Always true on XCode12+
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 // Always true on XCode12+
|
||||||
@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
|
@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
|
||||||
UINavigationControllerDelegate,
|
UINavigationControllerDelegate,
|
||||||
UIPopoverControllerDelegate,
|
|
||||||
CLLocationManagerDelegate,
|
CLLocationManagerDelegate,
|
||||||
PHPickerViewControllerDelegate>
|
PHPickerViewControllerDelegate>
|
||||||
{}
|
{}
|
||||||
#else
|
#else
|
||||||
@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
|
@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
|
||||||
UINavigationControllerDelegate,
|
UINavigationControllerDelegate,
|
||||||
UIPopoverControllerDelegate,
|
|
||||||
CLLocationManagerDelegate>
|
CLLocationManagerDelegate>
|
||||||
{}
|
{}
|
||||||
#endif
|
#endif
|
||||||
@@ -122,7 +117,6 @@ typedef NSUInteger CDVMediaType;
|
|||||||
|
|
||||||
- (void)takePicture:(CDVInvokedUrlCommand*)command;
|
- (void)takePicture:(CDVInvokedUrlCommand*)command;
|
||||||
- (void)cleanup:(CDVInvokedUrlCommand*)command;
|
- (void)cleanup:(CDVInvokedUrlCommand*)command;
|
||||||
- (void)repositionPopover:(CDVInvokedUrlCommand*)command;
|
|
||||||
|
|
||||||
// UIImagePickerControllerDelegate methods
|
// UIImagePickerControllerDelegate methods
|
||||||
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
|
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
|
||||||
|
|||||||
@@ -37,8 +37,6 @@
|
|||||||
|
|
||||||
#define CDV_PHOTO_PREFIX @"cdv_photo_"
|
#define CDV_PHOTO_PREFIX @"cdv_photo_"
|
||||||
|
|
||||||
static NSSet* org_apache_cordova_validArrowDirections;
|
|
||||||
|
|
||||||
static NSString* toBase64(NSData* data)
|
static NSString* toBase64(NSData* data)
|
||||||
{
|
{
|
||||||
SEL s1 = NSSelectorFromString(@"cdv_base64EncodedString");
|
SEL s1 = NSSelectorFromString(@"cdv_base64EncodedString");
|
||||||
@@ -84,10 +82,8 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
pictureOptions.allowsEditing = [[command argumentAtIndex:7 withDefault:@(NO)] boolValue];
|
pictureOptions.allowsEditing = [[command argumentAtIndex:7 withDefault:@(NO)] boolValue];
|
||||||
pictureOptions.correctOrientation = [[command argumentAtIndex:8 withDefault:@(NO)] boolValue];
|
pictureOptions.correctOrientation = [[command argumentAtIndex:8 withDefault:@(NO)] boolValue];
|
||||||
pictureOptions.saveToPhotoAlbum = [[command argumentAtIndex:9 withDefault:@(NO)] boolValue];
|
pictureOptions.saveToPhotoAlbum = [[command argumentAtIndex:9 withDefault:@(NO)] boolValue];
|
||||||
pictureOptions.popoverOptions = [command argumentAtIndex:10 withDefault:nil];
|
pictureOptions.cameraDirection = [[command argumentAtIndex:10 withDefault:@(UIImagePickerControllerCameraDeviceRear)] unsignedIntegerValue];
|
||||||
pictureOptions.cameraDirection = [[command argumentAtIndex:11 withDefault:@(UIImagePickerControllerCameraDeviceRear)] unsignedIntegerValue];
|
|
||||||
|
|
||||||
pictureOptions.popoverSupported = NO;
|
|
||||||
pictureOptions.usesGeolocation = NO;
|
pictureOptions.usesGeolocation = NO;
|
||||||
|
|
||||||
return pictureOptions;
|
return pictureOptions;
|
||||||
@@ -104,11 +100,6 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
|
|
||||||
@implementation CDVCamera
|
@implementation CDVCamera
|
||||||
|
|
||||||
+ (void)initialize
|
|
||||||
{
|
|
||||||
org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
@synthesize hasPendingOperation, pickerController, locationManager;
|
@synthesize hasPendingOperation, pickerController, locationManager;
|
||||||
|
|
||||||
- (NSURL*)urlTransformer:(NSURL*)url
|
- (NSURL*)urlTransformer:(NSURL*)url
|
||||||
@@ -135,12 +126,6 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
return [(NSNumber*)useGeo boolValue];
|
return [(NSNumber*)useGeo boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)popoverSupported
|
|
||||||
{
|
|
||||||
return (NSClassFromString(@"UIPopoverController") != nil) &&
|
|
||||||
(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Called by JS function navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions)
|
Called by JS function navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions)
|
||||||
which will invoke the camera or photo picker to capture or select an image or video.
|
which will invoke the camera or photo picker to capture or select an image or video.
|
||||||
@@ -156,8 +141,7 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
- index 7 (allowsEditing): NSNumber(BOOL). Allow user to crop/edit. Default: NO.
|
- index 7 (allowsEditing): NSNumber(BOOL). Allow user to crop/edit. Default: NO.
|
||||||
- index 8 (correctOrientation): NSNumber(BOOL). Fix EXIF orientation. Default: NO.
|
- index 8 (correctOrientation): NSNumber(BOOL). Fix EXIF orientation. Default: NO.
|
||||||
- index 9 (saveToPhotoAlbum): NSNumber(BOOL). Save captured image to Photos. Default: NO.
|
- index 9 (saveToPhotoAlbum): NSNumber(BOOL). Save captured image to Photos. Default: NO.
|
||||||
- index 10 (popoverOptions): NSDictionary (iPad only). Popover positioning and sizing.
|
- index 10 (cameraDirection): NSNumber (UIImagePickerControllerCameraDevice). Front/Rear. Default: Rear.
|
||||||
- index 11 (cameraDirection): NSNumber (UIImagePickerControllerCameraDevice). Front/Rear. Default: Rear.
|
|
||||||
|
|
||||||
@discussion
|
@discussion
|
||||||
This method validates hardware availability and permissions (camera or photo library),
|
This method validates hardware availability and permissions (camera or photo library),
|
||||||
@@ -171,7 +155,6 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
|
|
||||||
[self.commandDelegate runInBackground:^{
|
[self.commandDelegate runInBackground:^{
|
||||||
CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command];
|
CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command];
|
||||||
pictureOptions.popoverSupported = [weakSelf popoverSupported];
|
|
||||||
pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
|
pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
|
||||||
pictureOptions.cropToSize = NO;
|
pictureOptions.cropToSize = NO;
|
||||||
|
|
||||||
@@ -279,12 +262,11 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
- Ensures presentation occurs on the main thread.
|
- Ensures presentation occurs on the main thread.
|
||||||
|
|
||||||
Behavior:
|
Behavior:
|
||||||
- Dismisses any visible popover before presenting a new picker (iPad).
|
- Configures delegates and media types
|
||||||
- Configures delegates, media types, and popover presentation as needed.
|
|
||||||
- Updates `hasPendingOperation` to reflect plugin activity state.
|
- Updates `hasPendingOperation` to reflect plugin activity state.
|
||||||
|
|
||||||
@param callbackId The Cordova callback identifier used to deliver results back to JavaScript.
|
@param callbackId The Cordova callback identifier used to deliver results back to JavaScript.
|
||||||
@param pictureOptions Parsed camera options (sourceType, mediaType, allowsEditing, popoverOptions, etc.).
|
@param pictureOptions Parsed camera options (sourceType, mediaType, allowsEditing, etc.).
|
||||||
*/
|
*/
|
||||||
- (void)showCameraPicker:(NSString*)callbackId withOptions:(CDVPictureOptions*)pictureOptions
|
- (void)showCameraPicker:(NSString*)callbackId withOptions:(CDVPictureOptions*)pictureOptions
|
||||||
{
|
{
|
||||||
@@ -309,28 +291,12 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
cameraPicker.callbackId = callbackId;
|
cameraPicker.callbackId = callbackId;
|
||||||
// we need to capture this state for memory warnings that dealloc this object
|
// we need to capture this state for memory warnings that dealloc this object
|
||||||
cameraPicker.webView = self.webView;
|
cameraPicker.webView = self.webView;
|
||||||
|
cameraPicker.modalPresentationStyle = UIModalPresentationCurrentContext;
|
||||||
// If a popover is already open, close it; we only want one at a time.
|
[self.viewController presentViewController:cameraPicker
|
||||||
if (([[self pickerController] pickerPopoverController] != nil) && [[[self pickerController] pickerPopoverController] isPopoverVisible]) {
|
animated:YES
|
||||||
[[[self pickerController] pickerPopoverController] dismissPopoverAnimated:YES];
|
completion:^{
|
||||||
[[[self pickerController] pickerPopoverController] setDelegate:nil];
|
|
||||||
[[self pickerController] setPickerPopoverController:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([self popoverSupported] && (pictureOptions.sourceType != UIImagePickerControllerSourceTypeCamera)) {
|
|
||||||
if (cameraPicker.pickerPopoverController == nil) {
|
|
||||||
cameraPicker.pickerPopoverController = [[NSClassFromString(@"UIPopoverController") alloc] initWithContentViewController:cameraPicker];
|
|
||||||
}
|
|
||||||
[self displayPopover:pictureOptions.popoverOptions];
|
|
||||||
self.hasPendingOperation = NO;
|
self.hasPendingOperation = NO;
|
||||||
} else {
|
}];
|
||||||
cameraPicker.modalPresentationStyle = UIModalPresentationCurrentContext;
|
|
||||||
[self.viewController presentViewController:cameraPicker
|
|
||||||
animated:YES
|
|
||||||
completion:^{
|
|
||||||
self.hasPendingOperation = NO;
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,17 +492,6 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (void)repositionPopover:(CDVInvokedUrlCommand*)command
|
|
||||||
{
|
|
||||||
if (([[self pickerController] pickerPopoverController] != nil) && [[[self pickerController] pickerPopoverController] isPopoverVisible]) {
|
|
||||||
|
|
||||||
[[[self pickerController] pickerPopoverController] dismissPopoverAnimated:NO];
|
|
||||||
|
|
||||||
NSDictionary* options = [command argumentAtIndex:0 withDefault:nil];
|
|
||||||
[self displayPopover:options];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSInteger)integerValueForKey:(NSDictionary*)dict key:(NSString*)key defaultValue:(NSInteger)defaultValue
|
- (NSInteger)integerValueForKey:(NSDictionary*)dict key:(NSString*)key defaultValue:(NSInteger)defaultValue
|
||||||
{
|
{
|
||||||
NSInteger value = defaultValue;
|
NSInteger value = defaultValue;
|
||||||
@@ -549,55 +504,18 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)displayPopover:(NSDictionary*)options
|
|
||||||
{
|
|
||||||
NSInteger x = 0;
|
|
||||||
NSInteger y = 32;
|
|
||||||
NSInteger width = 320;
|
|
||||||
NSInteger height = 480;
|
|
||||||
UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
|
|
||||||
|
|
||||||
if (options) {
|
|
||||||
x = [self integerValueForKey:options key:@"x" defaultValue:0];
|
|
||||||
y = [self integerValueForKey:options key:@"y" defaultValue:32];
|
|
||||||
width = [self integerValueForKey:options key:@"width" defaultValue:320];
|
|
||||||
height = [self integerValueForKey:options key:@"height" defaultValue:480];
|
|
||||||
arrowDirection = [self integerValueForKey:options key:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
|
|
||||||
if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithUnsignedInteger:arrowDirection]]) {
|
|
||||||
arrowDirection = UIPopoverArrowDirectionAny;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[[self pickerController] pickerPopoverController] setDelegate:self];
|
|
||||||
[[[self pickerController] pickerPopoverController] presentPopoverFromRect:CGRectMake(x, y, width, height)
|
|
||||||
inView:[self.webView superview]
|
|
||||||
permittedArrowDirections:arrowDirection
|
|
||||||
animated:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
// UINavigationControllerDelegate method
|
// UINavigationControllerDelegate method
|
||||||
- (void)navigationController:(UINavigationController*)navigationController
|
- (void)navigationController:(UINavigationController*)navigationController
|
||||||
willShowViewController:(UIViewController*)viewController
|
willShowViewController:(UIViewController*)viewController
|
||||||
animated:(BOOL)animated
|
animated:(BOOL)animated
|
||||||
{
|
{
|
||||||
|
// Backward compatibility for iOS < 14
|
||||||
|
// Set title "Videos", when picking videos with the legacy UIImagePickerController
|
||||||
if([navigationController isKindOfClass:[UIImagePickerController class]]) {
|
if([navigationController isKindOfClass:[UIImagePickerController class]]) {
|
||||||
// If popoverWidth and popoverHeight are specified and are greater than 0,
|
UIImagePickerController* imagePickerController = (UIImagePickerController*)navigationController;
|
||||||
// then set popover size, else use apple's default popoverSize
|
|
||||||
NSDictionary* options = self.pickerController.pictureOptions.popoverOptions;
|
|
||||||
|
|
||||||
if(options) {
|
|
||||||
NSInteger popoverWidth = [self integerValueForKey:options key:@"popoverWidth" defaultValue:0];
|
|
||||||
NSInteger popoverHeight = [self integerValueForKey:options key:@"popoverHeight" defaultValue:0];
|
|
||||||
|
|
||||||
if(popoverWidth > 0 && popoverHeight > 0) {
|
|
||||||
[viewController setPreferredContentSize:CGSizeMake(popoverWidth,popoverHeight)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UIImagePickerController* imagePicker = (UIImagePickerController*)navigationController;
|
|
||||||
|
|
||||||
// Set "Videos" title if mediaType is not for images
|
// Set title "Videos" when picking not images
|
||||||
if(![imagePicker.mediaTypes containsObject:(NSString*)kUTTypeImage]) {
|
if(![imagePickerController.mediaTypes containsObject:(NSString*)kUTTypeImage]) {
|
||||||
[viewController.navigationItem setTitle:NSLocalizedString(@"Videos", nil)];
|
[viewController.navigationItem setTitle:NSLocalizedString(@"Videos", nil)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,21 +556,6 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)popoverControllerDidDismissPopover:(id)popoverController
|
|
||||||
{
|
|
||||||
UIPopoverController* pc = (UIPopoverController*)popoverController;
|
|
||||||
|
|
||||||
[pc dismissPopoverAnimated:YES];
|
|
||||||
pc.delegate = nil;
|
|
||||||
if (self.pickerController && self.pickerController.callbackId && self.pickerController.pickerPopoverController) {
|
|
||||||
self.pickerController.pickerPopoverController = nil;
|
|
||||||
NSString* callbackId = self.pickerController.callbackId;
|
|
||||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
|
|
||||||
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
|
|
||||||
}
|
|
||||||
self.hasPendingOperation = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString*)getMimeForEncoding:(CDVEncodingType)encoding
|
- (NSString*)getMimeForEncoding:(CDVEncodingType)encoding
|
||||||
{
|
{
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
@@ -1007,14 +910,7 @@ static NSString* MIME_JPEG = @"image/jpeg";
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (cameraPicker.pictureOptions.popoverSupported && (cameraPicker.pickerPopoverController != nil)) {
|
[[cameraPicker presentingViewController] dismissViewControllerAnimated:YES completion:invoke];
|
||||||
[cameraPicker.pickerPopoverController dismissPopoverAnimated:YES];
|
|
||||||
cameraPicker.pickerPopoverController.delegate = nil;
|
|
||||||
cameraPicker.pickerPopoverController = nil;
|
|
||||||
invoke();
|
|
||||||
} else {
|
|
||||||
[[cameraPicker presentingViewController] dismissViewControllerAnimated:YES completion:invoke];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// older api calls newer didFinishPickingMediaWithInfo
|
// older api calls newer didFinishPickingMediaWithInfo
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
{
|
{
|
||||||
NSArray* args;
|
NSArray* args;
|
||||||
CDVPictureOptions* options;
|
CDVPictureOptions* options;
|
||||||
NSDictionary* popoverOptions;
|
|
||||||
|
|
||||||
// No arguments, check whether the defaults are set
|
// No arguments, check whether the defaults are set
|
||||||
args = @[];
|
args = @[];
|
||||||
@@ -79,14 +78,10 @@
|
|||||||
XCTAssertEqual(options.allowsEditing, NO);
|
XCTAssertEqual(options.allowsEditing, NO);
|
||||||
XCTAssertEqual(options.correctOrientation, NO);
|
XCTAssertEqual(options.correctOrientation, NO);
|
||||||
XCTAssertEqual(options.saveToPhotoAlbum, NO);
|
XCTAssertEqual(options.saveToPhotoAlbum, NO);
|
||||||
XCTAssertEqualObjects(options.popoverOptions, nil);
|
|
||||||
XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceRear);
|
XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceRear);
|
||||||
XCTAssertEqual(options.popoverSupported, NO);
|
|
||||||
XCTAssertEqual(options.usesGeolocation, NO);
|
XCTAssertEqual(options.usesGeolocation, NO);
|
||||||
|
|
||||||
// Set each argument, check whether they are set. different from defaults
|
// Set each argument, check whether they are set. different from defaults
|
||||||
popoverOptions = @{ @"x" : @1, @"y" : @2, @"width" : @3, @"height" : @4, @"popoverWidth": @200, @"popoverHeight": @300 };
|
|
||||||
|
|
||||||
args = @[
|
args = @[
|
||||||
@(49),
|
@(49),
|
||||||
@(DestinationTypeDataUrl),
|
@(DestinationTypeDataUrl),
|
||||||
@@ -98,7 +93,6 @@
|
|||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
popoverOptions,
|
|
||||||
@(UIImagePickerControllerCameraDeviceFront),
|
@(UIImagePickerControllerCameraDeviceFront),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -115,22 +109,17 @@
|
|||||||
XCTAssertEqual(options.allowsEditing, YES);
|
XCTAssertEqual(options.allowsEditing, YES);
|
||||||
XCTAssertEqual(options.correctOrientation, YES);
|
XCTAssertEqual(options.correctOrientation, YES);
|
||||||
XCTAssertEqual(options.saveToPhotoAlbum, YES);
|
XCTAssertEqual(options.saveToPhotoAlbum, YES);
|
||||||
XCTAssertEqualObjects(options.popoverOptions, popoverOptions);
|
|
||||||
XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceFront);
|
XCTAssertEqual(options.cameraDirection, (int)UIImagePickerControllerCameraDeviceFront);
|
||||||
XCTAssertEqual(options.popoverSupported, NO);
|
|
||||||
XCTAssertEqual(options.usesGeolocation, NO);
|
XCTAssertEqual(options.usesGeolocation, NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testCameraPickerCreate
|
- (void)testCameraPickerCreate
|
||||||
{
|
{
|
||||||
NSDictionary* popoverOptions;
|
|
||||||
NSArray* args;
|
NSArray* args;
|
||||||
CDVPictureOptions* pictureOptions;
|
CDVPictureOptions* pictureOptions;
|
||||||
CDVCameraPicker* picker;
|
CDVCameraPicker* picker;
|
||||||
|
|
||||||
// Source is Camera, and image type - Camera always uses UIImagePickerController
|
// Source is Camera, uses always UIImagePickerController
|
||||||
|
|
||||||
popoverOptions = @{ @"x" : @1, @"y" : @2, @"width" : @3, @"height" : @4, @"popoverWidth": @200, @"popoverHeight": @300 };
|
|
||||||
args = @[
|
args = @[
|
||||||
@(49),
|
@(49),
|
||||||
@(DestinationTypeDataUrl),
|
@(DestinationTypeDataUrl),
|
||||||
@@ -142,7 +131,6 @@
|
|||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
popoverOptions,
|
|
||||||
@(UIImagePickerControllerCameraDeviceFront),
|
@(UIImagePickerControllerCameraDeviceFront),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -173,7 +161,6 @@
|
|||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
popoverOptions,
|
|
||||||
@(UIImagePickerControllerCameraDeviceFront),
|
@(UIImagePickerControllerCameraDeviceFront),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -203,7 +190,6 @@
|
|||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
@YES,
|
@YES,
|
||||||
popoverOptions,
|
|
||||||
@(UIImagePickerControllerCameraDeviceFront),
|
@(UIImagePickerControllerCameraDeviceFront),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* globals Camera, resolveLocalFileSystemURL, FileEntry, CameraPopoverOptions, LocalFileSystem */
|
/* globals Camera, resolveLocalFileSystemURL, FileEntry, LocalFileSystem */
|
||||||
/* eslint-env jasmine */
|
/* eslint-env jasmine */
|
||||||
|
|
||||||
exports.defineAutoTests = function () {
|
exports.defineAutoTests = function () {
|
||||||
@@ -156,13 +156,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
|||||||
clearStatus();
|
clearStatus();
|
||||||
const options = extractOptions();
|
const options = extractOptions();
|
||||||
log('Getting picture with options: ' + JSON.stringify(options));
|
log('Getting picture with options: ' + JSON.stringify(options));
|
||||||
const popoverHandle = navigator.camera.getPicture(getPictureWin, onGetPictureError, options);
|
navigator.camera.getPicture(getPictureWin, onGetPictureError, options);
|
||||||
|
|
||||||
// Reposition the popover if the orientation changes.
|
|
||||||
window.onorientationchange = function () {
|
|
||||||
const newPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, 0, 300, 400);
|
|
||||||
popoverHandle.setPosition(newPopoverOptions);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logCallback (apiName, success) {
|
function logCallback (apiName, success) {
|
||||||
|
|||||||
53
types/index.d.ts
vendored
53
types/index.d.ts
vendored
@@ -36,11 +36,6 @@ interface Camera {
|
|||||||
cameraSuccess: (data: string) => void,
|
cameraSuccess: (data: string) => void,
|
||||||
cameraError: (message: string) => void,
|
cameraError: (message: string) => void,
|
||||||
cameraOptions?: CameraOptions): void;
|
cameraOptions?: CameraOptions): void;
|
||||||
// Next will work only on iOS
|
|
||||||
//getPicture(
|
|
||||||
// cameraSuccess: (data: string) => void,
|
|
||||||
// cameraError: (message: string) => void,
|
|
||||||
// cameraOptions?: CameraOptions): CameraPopoverHandle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CameraOptions {
|
interface CameraOptions {
|
||||||
@@ -100,46 +95,6 @@ interface CameraOptions {
|
|||||||
* BACK: 1
|
* BACK: 1
|
||||||
*/
|
*/
|
||||||
cameraDirection?: number;
|
cameraDirection?: number;
|
||||||
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
|
|
||||||
popoverOptions?: CameraPopoverOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A handle to the popover dialog created by navigator.camera.getPicture. Used on iOS only.
|
|
||||||
*/
|
|
||||||
interface CameraPopoverHandle {
|
|
||||||
/**
|
|
||||||
* Set the position of the popover.
|
|
||||||
* @param popoverOptions the CameraPopoverOptions that specify the new position.
|
|
||||||
*/
|
|
||||||
setPosition(popoverOptions: CameraPopoverOptions): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* iOS-only parameters that specify the anchor element location and arrow direction
|
|
||||||
* of the popover when selecting images from an iPad's library or album.
|
|
||||||
*/
|
|
||||||
interface CameraPopoverOptions {
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
/**
|
|
||||||
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
|
|
||||||
* Matches iOS UIPopoverArrowDirection constants.
|
|
||||||
* ARROW_UP : 1,
|
|
||||||
* ARROW_DOWN : 2,
|
|
||||||
* ARROW_LEFT : 4,
|
|
||||||
* ARROW_RIGHT : 8,
|
|
||||||
* ARROW_ANY : 15
|
|
||||||
*/
|
|
||||||
arrowDir : number;
|
|
||||||
popoverWidth: number;
|
|
||||||
popoverHeight: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare class CameraPopoverOptions implements CameraPopoverOptions {
|
|
||||||
constructor(x?: number, y?: number, width?: number, height?: number, arrowDir?: number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var Camera: {
|
declare var Camera: {
|
||||||
@@ -166,12 +121,4 @@ declare var Camera: {
|
|||||||
CAMERA: number;
|
CAMERA: number;
|
||||||
SAVEDPHOTOALBUM: number;
|
SAVEDPHOTOALBUM: number;
|
||||||
}
|
}
|
||||||
// Used only on iOS
|
|
||||||
PopoverArrowDirection: {
|
|
||||||
ARROW_UP: number;
|
|
||||||
ARROW_DOWN: number;
|
|
||||||
ARROW_LEFT: number;
|
|
||||||
ARROW_RIGHT: number;
|
|
||||||
ARROW_ANY: number;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
const argscheck = require('cordova/argscheck');
|
const argscheck = require('cordova/argscheck');
|
||||||
const exec = require('cordova/exec');
|
const exec = require('cordova/exec');
|
||||||
const Camera = require('./Camera');
|
const Camera = require('./Camera');
|
||||||
// XXX: commented out
|
|
||||||
// CameraPopoverHandle = require('./CameraPopoverHandle');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace navigator
|
* @namespace navigator
|
||||||
@@ -73,7 +71,6 @@ for (const key in Camera) {
|
|||||||
* @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`.
|
* @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`.
|
||||||
* @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture.
|
* @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture.
|
||||||
* @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture.
|
* @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture.
|
||||||
* @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad.
|
|
||||||
* @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing).
|
* @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -140,7 +137,6 @@ cameraExport.getPicture = function (successCallback, errorCallback, options) {
|
|||||||
const allowEdit = !!options.allowEdit;
|
const allowEdit = !!options.allowEdit;
|
||||||
const correctOrientation = !!options.correctOrientation;
|
const correctOrientation = !!options.correctOrientation;
|
||||||
const saveToPhotoAlbum = !!options.saveToPhotoAlbum;
|
const saveToPhotoAlbum = !!options.saveToPhotoAlbum;
|
||||||
const popoverOptions = getValue(options.popoverOptions, null);
|
|
||||||
const cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
|
const cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
|
||||||
|
|
||||||
if (allowEdit) {
|
if (allowEdit) {
|
||||||
@@ -148,11 +144,9 @@ cameraExport.getPicture = function (successCallback, errorCallback, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
|
const args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
|
||||||
mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
|
mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, cameraDirection];
|
||||||
|
|
||||||
exec(successCallback, errorCallback, 'Camera', 'takePicture', args);
|
exec(successCallback, errorCallback, 'Camera', 'takePicture', args);
|
||||||
// XXX: commented out
|
|
||||||
// return new CameraPopoverHandle();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -75,17 +75,6 @@ module.exports = {
|
|||||||
**/
|
**/
|
||||||
SAVEDPHOTOALBUM: 2
|
SAVEDPHOTOALBUM: 2
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
|
|
||||||
* @enum {number}
|
|
||||||
*/
|
|
||||||
PopoverArrowDirection: {
|
|
||||||
ARROW_UP: 1,
|
|
||||||
ARROW_DOWN: 2,
|
|
||||||
ARROW_LEFT: 4,
|
|
||||||
ARROW_RIGHT: 8,
|
|
||||||
ARROW_ANY: 15
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ignore in favour of iOS' one
|
|
||||||
* A handle to an image picker popover.
|
|
||||||
*/
|
|
||||||
const CameraPopoverHandle = function () {
|
|
||||||
this.setPosition = function (popoverOptions) {
|
|
||||||
console.log('CameraPopoverHandle.setPosition is only supported on iOS.');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = CameraPopoverHandle;
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
const Camera = require('./Camera');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace navigator
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* iOS-only parameters that specify the anchor element location and arrow
|
|
||||||
* direction of the popover when selecting images from an iPad's library
|
|
||||||
* or album.
|
|
||||||
* Note that the size of the popover may change to adjust to the
|
|
||||||
* direction of the arrow and orientation of the screen. Make sure to
|
|
||||||
* account for orientation changes when specifying the anchor element
|
|
||||||
* location.
|
|
||||||
* @module CameraPopoverOptions
|
|
||||||
* @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover.
|
|
||||||
* @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover.
|
|
||||||
* @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover.
|
|
||||||
* @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover.
|
|
||||||
* @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point.
|
|
||||||
* @param {Number} [popoverWidth=0] - width of the popover (0 or not specified will use apple's default width).
|
|
||||||
* @param {Number} [popoverHeight=0] - height of the popover (0 or not specified will use apple's default height).
|
|
||||||
*/
|
|
||||||
const CameraPopoverOptions = function (x, y, width, height, arrowDir, popoverWidth, popoverHeight) {
|
|
||||||
// information of rectangle that popover should be anchored to
|
|
||||||
this.x = x || 0;
|
|
||||||
this.y = y || 32;
|
|
||||||
this.width = width || 320;
|
|
||||||
this.height = height || 480;
|
|
||||||
this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
|
|
||||||
this.popoverWidth = popoverWidth || 0;
|
|
||||||
this.popoverHeight = popoverHeight || 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = CameraPopoverOptions;
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
const exec = require('cordova/exec');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace navigator
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A handle to an image picker popover.
|
|
||||||
*
|
|
||||||
* __Supported Platforms__
|
|
||||||
*
|
|
||||||
* - iOS
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* navigator.camera.getPicture(onSuccess, onFail,
|
|
||||||
* {
|
|
||||||
* destinationType: Camera.DestinationType.FILE_URI,
|
|
||||||
* sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
|
||||||
* popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY, 300, 600)
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* // Reposition the popover if the orientation changes.
|
|
||||||
* window.onorientationchange = function() {
|
|
||||||
* var cameraPopoverHandle = new CameraPopoverHandle();
|
|
||||||
* var cameraPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY, 400, 500);
|
|
||||||
* cameraPopoverHandle.setPosition(cameraPopoverOptions);
|
|
||||||
* }
|
|
||||||
* @module CameraPopoverHandle
|
|
||||||
*/
|
|
||||||
const CameraPopoverHandle = function () {
|
|
||||||
/**
|
|
||||||
* Can be used to reposition the image selection dialog,
|
|
||||||
* for example, when the device orientation changes.
|
|
||||||
* @memberof CameraPopoverHandle
|
|
||||||
* @instance
|
|
||||||
* @method setPosition
|
|
||||||
* @param {module:CameraPopoverOptions} popoverOptions
|
|
||||||
*/
|
|
||||||
this.setPosition = function (popoverOptions) {
|
|
||||||
const args = [popoverOptions];
|
|
||||||
exec(null, null, 'Camera', 'repositionPopover', args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = CameraPopoverHandle;
|
|
||||||
Reference in New Issue
Block a user