mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2026-04-29 00:02:13 +08:00
dc682b2532
- Does not need any permissions for reading images - The PHPickerViewController class is an alternative to UIImagePickerController. PHPickerViewController improves stability and reliability, and includes several benefits to developers and users, such as the following: - Deferred image loading and recovery UI - Reliable handling of large and complex assets, like RAW and panoramic images - User-selectable assets that aren’t available for UIImagePickerController - Configuration of the picker to display only Live Photos - Availability of PHLivePhoto objects without library access - Stricter validations against invalid inputs - See documentation of PHPickerViewController: https://developer.apple.com/documentation/photosui/phpickerviewcontroller?language=objc - Added tests for PHPickerViewController in `CameraTest.m` * Documentation and formatting - Document `takePicture` and `showCameraPicker` in `CDVCamera.m` - A pragmas for UIImagePickerControllerDelegate methods and CLLocationManager methods - Format some long methods declarations to multi-line instead single-line for better readability - Remove unnecessry `dispatch_async(dispatch_get_main_queue() ...` in `takePicture` before calling `showCameraPicker`. This is already done in `showCameraPicker`. - Source out code for permission denied alert dialog when accessing the camera or UIImagePickerController on iOS < 14 for picking images * feat(ios): proper formatting of methods - Use linux brace style: A brace have to be on a new line for method declarations - Remove unnecessary whitespaces in method declrations * doc: readme update - Better document usage descriptions - `NSPhotoLibraryUsageDescription` not needed for iOS 14+ when only picking images - Improve formatting for xml, js - sourceType `SAVEDPHOTOALBUM` is the same as `PHOTOLIBRARY` on Android and iOS 14+ - Use `PHOTOLIBRARY` as sourceType instead of `SAVEDPHOTOALBUM` in photo picker example * Android: Document `SAVEDPHOTOALBUM`` - Make clear that `SAVEDPHOTOALBUM` is the same like `PHOTOLIBRARY` and has only an effect on iOS < 14 - Format code when creating image chooser and document the request code parameter
99 lines
2.8 KiB
JavaScript
99 lines
2.8 KiB
JavaScript
/*
|
|
*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* @module Camera
|
|
*/
|
|
module.exports = {
|
|
/**
|
|
* @description
|
|
* Defines the output format of `Camera.getPicture` call.
|
|
*
|
|
* @enum {number}
|
|
*/
|
|
DestinationType: {
|
|
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI if possible */
|
|
DATA_URL: 0,
|
|
/** Return file uri (content://media/external/images/media/2 for Android) */
|
|
FILE_URI: 1
|
|
},
|
|
/**
|
|
* @enum {number}
|
|
*/
|
|
EncodingType: {
|
|
/** Return JPEG encoded image */
|
|
JPEG: 0,
|
|
/** Return PNG encoded image */
|
|
PNG: 1
|
|
},
|
|
/**
|
|
* @enum {number}
|
|
*/
|
|
MediaType: {
|
|
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
|
|
PICTURE: 0,
|
|
/** Allow selection of video only, ONLY RETURNS URL */
|
|
VIDEO: 1,
|
|
/** Allow selection from all media types */
|
|
ALLMEDIA: 2
|
|
},
|
|
/**
|
|
* @description
|
|
* Defines the output format of `Camera.getPicture` call.
|
|
*
|
|
* @enum {number}
|
|
*/
|
|
PictureSourceType: {
|
|
/**
|
|
* Choose image from the device's photo library.
|
|
**/
|
|
PHOTOLIBRARY: 0,
|
|
/** Take picture from camera */
|
|
CAMERA: 1,
|
|
/**
|
|
* 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: 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}
|
|
*/
|
|
Direction: {
|
|
/** Use the back-facing camera */
|
|
BACK: 0,
|
|
/** Use the front-facing camera */
|
|
FRONT: 1
|
|
}
|
|
};
|