@capacitor/camera 1.2.4 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/CapacitorCamera.podspec +1 -1
- package/README.md +19 -20
- package/android/build.gradle +12 -13
- package/android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.java +127 -35
- package/android/src/main/java/com/capacitorjs/plugins/camera/ImageUtils.java +6 -5
- package/dist/docs.json +0 -16
- package/dist/esm/definitions.d.ts +0 -8
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/CameraExtensions.swift +1 -1
- package/ios/Plugin/CameraPlugin.swift +6 -7
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,96 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 4.0.0-beta.0 (2022-06-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **camera:** Append change listener only once ([#486](https://github.com/ionic-team/capacitor-plugins/issues/486)) ([5b7021e](https://github.com/ionic-team/capacitor-plugins/commit/5b7021e210649f8501a20ba6549903ecb6d42dcd))
|
|
12
|
+
* **camera:** Append exif to android images ([#480](https://github.com/ionic-team/capacitor-plugins/issues/480)) ([cad8a30](https://github.com/ionic-team/capacitor-plugins/commit/cad8a30c562202fb819a4d260d5307f1b6b8fa44))
|
|
13
|
+
* **camera:** avoid error if image has no orientation ([#554](https://github.com/ionic-team/capacitor-plugins/issues/554)) ([dc8a55a](https://github.com/ionic-team/capacitor-plugins/commit/dc8a55a71cdaaf7ad86aee8470a0c7b8284653c4))
|
|
14
|
+
* **camera:** cleanup camera images if not needed ([#563](https://github.com/ionic-team/capacitor-plugins/issues/563)) ([a2e4f43](https://github.com/ionic-team/capacitor-plugins/commit/a2e4f4339119698e8dd066a5f2f8f065ab2e4727))
|
|
15
|
+
* **camera:** correct photo resizing on iOS ([#460](https://github.com/ionic-team/capacitor-plugins/issues/460)) ([bc56e03](https://github.com/ionic-team/capacitor-plugins/commit/bc56e034c711b172a7ff503cabd2970adbc14b86))
|
|
16
|
+
* **camera:** decode content uri when retrieving image from gallery ([#277](https://github.com/ionic-team/capacitor-plugins/issues/277)) ([a6cd1ad](https://github.com/ionic-team/capacitor-plugins/commit/a6cd1adc241bf21e4f7f06d24c0db4a4d7382dbc))
|
|
17
|
+
* **camera:** Don't save gallery images on iOS 14+ ([#696](https://github.com/ionic-team/capacitor-plugins/issues/696)) ([7b2cc88](https://github.com/ionic-team/capacitor-plugins/commit/7b2cc88f6e83265c991ae9f81cfc3f6bed346250))
|
|
18
|
+
* **camera:** fix camera source on Android ([#164](https://github.com/ionic-team/capacitor-plugins/issues/164)) ([e67f7c6](https://github.com/ionic-team/capacitor-plugins/commit/e67f7c6b06b20d7c3e8f0925c40fd75d23d9d717))
|
|
19
|
+
* **camera:** Make allowEdit work on all devices ([#552](https://github.com/ionic-team/capacitor-plugins/issues/552)) ([5224177](https://github.com/ionic-team/capacitor-plugins/commit/5224177f77bdce1c8f028e2cef41614fa687502f))
|
|
20
|
+
* **camera:** Make input file hidden ([#484](https://github.com/ionic-team/capacitor-plugins/issues/484)) ([cdc1835](https://github.com/ionic-team/capacitor-plugins/commit/cdc1835f3bbfb8db8e18fccace6103d83dd9edaa))
|
|
21
|
+
* **camera:** Make web use source options ([#487](https://github.com/ionic-team/capacitor-plugins/issues/487)) ([7870e6b](https://github.com/ionic-team/capacitor-plugins/commit/7870e6b6ca196265640fc0ba3c1f52ddca075607))
|
|
22
|
+
* **camera:** process picked image only once ([#782](https://github.com/ionic-team/capacitor-plugins/issues/782)) ([897dcaf](https://github.com/ionic-team/capacitor-plugins/commit/897dcaf839a6cb83256485c32df2ca0e7b439124))
|
|
23
|
+
* **camera:** Properly reset orientation exif if corrected ([#545](https://github.com/ionic-team/capacitor-plugins/issues/545)) ([ad8c325](https://github.com/ionic-team/capacitor-plugins/commit/ad8c325af0a2459f5a7788be08a8da4118717671))
|
|
24
|
+
* **camera:** query IMAGE_CAPTURE intent required by SDK 30 ([#160](https://github.com/ionic-team/capacitor-plugins/issues/160)) ([6484991](https://github.com/ionic-team/capacitor-plugins/commit/6484991d76d57bac0cbc82b9f050e146ec4732da))
|
|
25
|
+
* **camera:** Remove capture attribute from multiple photo picker ([#687](https://github.com/ionic-team/capacitor-plugins/issues/687)) ([e551ef7](https://github.com/ionic-team/capacitor-plugins/commit/e551ef77eebe331cc7bf13c9c0eab5a0bd2da0d1))
|
|
26
|
+
* **camera:** Remove unused saveCall ([#401](https://github.com/ionic-team/capacitor-plugins/issues/401)) ([95920da](https://github.com/ionic-team/capacitor-plugins/commit/95920da4d1844ed76a162651d5492a22a4038d26))
|
|
27
|
+
* **camera:** Reset exif orientation if corrected ([#510](https://github.com/ionic-team/capacitor-plugins/issues/510)) ([a65c05e](https://github.com/ionic-team/capacitor-plugins/commit/a65c05e0de8f53e7371c194047a75797d53879b5))
|
|
28
|
+
* **camera:** Resize not respecting aspect ratio on iOS ([#568](https://github.com/ionic-team/capacitor-plugins/issues/568)) ([ea2b801](https://github.com/ionic-team/capacitor-plugins/commit/ea2b8012aab7e5ea34cfa34735f7f55ba76a3882))
|
|
29
|
+
* **camera:** return original image if editing is cancelled ([#566](https://github.com/ionic-team/capacitor-plugins/issues/566)) ([4786841](https://github.com/ionic-team/capacitor-plugins/commit/4786841099403a4d3d59aaf9103e8fa02aa8e4e2))
|
|
30
|
+
* **camera:** Return proper exif when picking multiple images ([#712](https://github.com/ionic-team/capacitor-plugins/issues/712)) ([8451237](https://github.com/ionic-team/capacitor-plugins/commit/8451237e46f24c59e74e350eaa9b31e6d99a68a0))
|
|
31
|
+
* **camera:** return single picture on pickImages ([#783](https://github.com/ionic-team/capacitor-plugins/issues/783)) ([9d65db1](https://github.com/ionic-team/capacitor-plugins/commit/9d65db1e74117fd1c1e7cd9bbba7efaeb4c13e0c))
|
|
32
|
+
* **camera:** saveToGallery for edited images ([#602](https://github.com/ionic-team/capacitor-plugins/issues/602)) ([b5ac27d](https://github.com/ionic-team/capacitor-plugins/commit/b5ac27d59181ec3acc2909b2569d8ab45a829b1c))
|
|
33
|
+
* **camera:** set camera direction for web ([#665](https://github.com/ionic-team/capacitor-plugins/issues/665)) ([4afedb9](https://github.com/ionic-team/capacitor-plugins/commit/4afedb96f3b745a86d9cacd33ca71c42ae3fb8d4))
|
|
34
|
+
* **camera:** Use Locale.ROOT on toUpperCase ([#812](https://github.com/ionic-team/capacitor-plugins/issues/812)) ([6d689ac](https://github.com/ionic-team/capacitor-plugins/commit/6d689acc48e3746ddd35bd5e1e8d7f239cb7f8df))
|
|
35
|
+
* add es2017 lib to tsconfig ([#180](https://github.com/ionic-team/capacitor-plugins/issues/180)) ([2c3776c](https://github.com/ionic-team/capacitor-plugins/commit/2c3776c38ca025c5ee965dec10ccf1cdb6c02e2f))
|
|
36
|
+
* correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
|
|
37
|
+
* Correct missing source_files path ([#590](https://github.com/ionic-team/capacitor-plugins/issues/590)) ([24e0fc2](https://github.com/ionic-team/capacitor-plugins/commit/24e0fc27cc314049012ab9915fa5e7bfb03313e1))
|
|
38
|
+
* inline source code in esm map files ([#760](https://github.com/ionic-team/capacitor-plugins/issues/760)) ([a960489](https://github.com/ionic-team/capacitor-plugins/commit/a960489a19db0182b90d187a50deff9dfbe51038))
|
|
39
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
40
|
+
* **camera:** return file URL for path, not system path ([#170](https://github.com/ionic-team/capacitor-plugins/issues/170)) ([8a9e5c3](https://github.com/ionic-team/capacitor-plugins/commit/8a9e5c3dba3b232a1cca9f9a1e9b4520022abc09))
|
|
41
|
+
* **camera:** Return the full webPath ([#502](https://github.com/ionic-team/capacitor-plugins/issues/502)) ([e849732](https://github.com/ionic-team/capacitor-plugins/commit/e849732dbcf5e85d1df09835c53ff5738fbb4ded))
|
|
42
|
+
* **camera:** set settings again on callbacks ([#595](https://github.com/ionic-team/capacitor-plugins/issues/595)) ([908bd68](https://github.com/ionic-team/capacitor-plugins/commit/908bd688767e374cf8e96b3def08bd33dcdfd2aa))
|
|
43
|
+
* support deprecated types from Capacitor 2 ([#139](https://github.com/ionic-team/capacitor-plugins/issues/139)) ([2d7127a](https://github.com/ionic-team/capacitor-plugins/commit/2d7127a488e26f0287951921a6db47c49d817336))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
* set targetSDK default value to 31 ([#824](https://github.com/ionic-team/capacitor-plugins/issues/824)) ([3ee10de](https://github.com/ionic-team/capacitor-plugins/commit/3ee10de98067984c1a4e75295d001c5a895c47f4))
|
|
49
|
+
* set targetSDK default value to 32 ([#970](https://github.com/ionic-team/capacitor-plugins/issues/970)) ([fa70d96](https://github.com/ionic-team/capacitor-plugins/commit/fa70d96f141af751aae53ceb5642c46b204f5958))
|
|
50
|
+
* Upgrade gradle to 7.4 ([#826](https://github.com/ionic-team/capacitor-plugins/issues/826)) ([5db0906](https://github.com/ionic-team/capacitor-plugins/commit/5db0906f6264287c4f8e69dbaecf19d4d387824b))
|
|
51
|
+
* Use java 11 ([#910](https://github.com/ionic-team/capacitor-plugins/issues/910)) ([5acb2a2](https://github.com/ionic-team/capacitor-plugins/commit/5acb2a288a413492b163e4e97da46a085d9e4be0))
|
|
52
|
+
* **android:** implements Activity Result API changes for permissions and activity results ([#222](https://github.com/ionic-team/capacitor-plugins/issues/222)) ([f671b9f](https://github.com/ionic-team/capacitor-plugins/commit/f671b9f4b472806ef43db6dcf302d4503cf1828c))
|
|
53
|
+
* **camera:** Add new method for multiple image picking from gallery ([#671](https://github.com/ionic-team/capacitor-plugins/issues/671)) ([a49c590](https://github.com/ionic-team/capacitor-plugins/commit/a49c5901683da12438fbafbd1bf6ae91133d18ed))
|
|
54
|
+
* **camera:** Return if image was saved to gallery ([#599](https://github.com/ionic-team/capacitor-plugins/issues/599)) ([594af3b](https://github.com/ionic-team/capacitor-plugins/commit/594af3be0982371e6c61e4bdb830c6bbb3963913))
|
|
55
|
+
* **camera:** Support for 1 Gallery app ([#791](https://github.com/ionic-team/capacitor-plugins/issues/791)) ([77e8c97](https://github.com/ionic-team/capacitor-plugins/commit/77e8c979394d5fb1804fc097ecaeee46a973e640))
|
|
56
|
+
* **camera:** Support for Samsung Gallery app on pickImages ([#706](https://github.com/ionic-team/capacitor-plugins/issues/706)) ([fd059fc](https://github.com/ionic-team/capacitor-plugins/commit/fd059fcd2e53661e95e230f684a6d32408db6787))
|
|
57
|
+
* **camera:** use a distinguishable permission denied string for camera and photos ([#379](https://github.com/ionic-team/capacitor-plugins/issues/379)) ([c71657f](https://github.com/ionic-team/capacitor-plugins/commit/c71657f7e14eae4efd4d2c7d00d77a7b329a7920))
|
|
58
|
+
* **camera:** Use same error messages for permission deny ([#404](https://github.com/ionic-team/capacitor-plugins/issues/404)) ([fffcd47](https://github.com/ionic-team/capacitor-plugins/commit/fffcd47f0237b6997bfa4ce430ef29392047ea0e))
|
|
59
|
+
* add commonjs output format ([#179](https://github.com/ionic-team/capacitor-plugins/issues/179)) ([8e9e098](https://github.com/ionic-team/capacitor-plugins/commit/8e9e09862064b3f6771d7facbc4008e995d9b463))
|
|
60
|
+
* Camera plugin ([#33](https://github.com/ionic-team/capacitor-plugins/issues/33)) ([4864928](https://github.com/ionic-team/capacitor-plugins/commit/48649288b1ba45e1901ad077b3b7b7314de04d4a))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## [1.3.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.3.0...@capacitor/camera@1.3.1) (2022-03-03)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Bug Fixes
|
|
70
|
+
|
|
71
|
+
* **camera:** Return the image on dismiss completion ([#849](https://github.com/ionic-team/capacitor-plugins/issues/849)) ([f083841](https://github.com/ionic-team/capacitor-plugins/commit/f0838416c6cf731aaae83fcb4986568357878b41))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# [1.3.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.2.4...@capacitor/camera@1.3.0) (2022-02-10)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### Bug Fixes
|
|
81
|
+
|
|
82
|
+
* **camera:** process picked image only once ([#782](https://github.com/ionic-team/capacitor-plugins/issues/782)) ([897dcaf](https://github.com/ionic-team/capacitor-plugins/commit/897dcaf839a6cb83256485c32df2ca0e7b439124))
|
|
83
|
+
* **camera:** return single picture on pickImages ([#783](https://github.com/ionic-team/capacitor-plugins/issues/783)) ([9d65db1](https://github.com/ionic-team/capacitor-plugins/commit/9d65db1e74117fd1c1e7cd9bbba7efaeb4c13e0c))
|
|
84
|
+
* **camera:** Use Locale.ROOT on toUpperCase ([#812](https://github.com/ionic-team/capacitor-plugins/issues/812)) ([6d689ac](https://github.com/ionic-team/capacitor-plugins/commit/6d689acc48e3746ddd35bd5e1e8d7f239cb7f8df))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Features
|
|
88
|
+
|
|
89
|
+
* **camera:** Support for 1 Gallery app ([#791](https://github.com/ionic-team/capacitor-plugins/issues/791)) ([77e8c97](https://github.com/ionic-team/capacitor-plugins/commit/77e8c979394d5fb1804fc097ecaeee46a973e640))
|
|
90
|
+
* **camera:** Support for Samsung Gallery app on pickImages ([#706](https://github.com/ionic-team/capacitor-plugins/issues/706)) ([fd059fc](https://github.com/ionic-team/capacitor-plugins/commit/fd059fcd2e53661e95e230f684a6d32408db6787))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
6
96
|
## [1.2.4](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.2.3...@capacitor/camera@1.2.4) (2022-01-19)
|
|
7
97
|
|
|
8
98
|
|
package/CapacitorCamera.podspec
CHANGED
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}', 'camera/ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -38,8 +38,8 @@ Additionally, because the Camera API launches a separate Activity to handle taki
|
|
|
38
38
|
|
|
39
39
|
This plugin will use the following project variables (defined in your app's `variables.gradle` file):
|
|
40
40
|
|
|
41
|
-
- `$androidxExifInterfaceVersion`: version of `androidx.exifinterface:exifinterface` (default: `1.3.
|
|
42
|
-
- `$androidxMaterialVersion`: version of `com.google.android.material:material` (default: `1.
|
|
41
|
+
- `$androidxExifInterfaceVersion`: version of `androidx.exifinterface:exifinterface` (default: `1.3.3`)
|
|
42
|
+
- `$androidxMaterialVersion`: version of `com.google.android.material:material` (default: `1.6.1`)
|
|
43
43
|
|
|
44
44
|
## PWA Notes
|
|
45
45
|
|
|
@@ -177,24 +177,23 @@ Request camera and photo album permissions
|
|
|
177
177
|
|
|
178
178
|
#### ImageOptions
|
|
179
179
|
|
|
180
|
-
| Prop
|
|
181
|
-
|
|
|
182
|
-
| **`quality`**
|
|
183
|
-
| **`allowEditing`**
|
|
184
|
-
| **`resultType`**
|
|
185
|
-
| **`saveToGallery`**
|
|
186
|
-
| **`width`**
|
|
187
|
-
| **`height`**
|
|
188
|
-
| **`
|
|
189
|
-
| **`
|
|
190
|
-
| **`
|
|
191
|
-
| **`
|
|
192
|
-
| **`
|
|
193
|
-
| **`
|
|
194
|
-
| **`
|
|
195
|
-
| **`
|
|
196
|
-
| **`
|
|
197
|
-
| **`promptLabelPicture`** | <code>string</code> | Text value to use when displaying the prompt. The label of the button to open the camera. | <code>: 'Take Picture'</code> | 1.0.0 |
|
|
180
|
+
| Prop | Type | Description | Default | Since |
|
|
181
|
+
| ------------------------ | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ----- |
|
|
182
|
+
| **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 | | 1.0.0 |
|
|
183
|
+
| **`allowEditing`** | <code>boolean</code> | Whether to allow the user to crop or make small edits (platform specific). On iOS 14+ it's only supported for <a href="#camerasource">CameraSource.Camera</a>, but not for <a href="#camerasource">CameraSource.Photos</a>. | | 1.0.0 |
|
|
184
|
+
| **`resultType`** | <code><a href="#cameraresulttype">CameraResultType</a></code> | How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported | | 1.0.0 |
|
|
185
|
+
| **`saveToGallery`** | <code>boolean</code> | Whether to save the photo to the gallery. If the photo was picked from the gallery, it will only be saved if edited. | <code>: false</code> | 1.0.0 |
|
|
186
|
+
| **`width`** | <code>number</code> | The width of the saved image | | 1.0.0 |
|
|
187
|
+
| **`height`** | <code>number</code> | The height of the saved image | | 1.0.0 |
|
|
188
|
+
| **`correctOrientation`** | <code>boolean</code> | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | <code>: true</code> | 1.0.0 |
|
|
189
|
+
| **`source`** | <code><a href="#camerasource">CameraSource</a></code> | The source to get the photo from. By default this prompts the user to select either the photo album or take a photo. | <code>: CameraSource.Prompt</code> | 1.0.0 |
|
|
190
|
+
| **`direction`** | <code><a href="#cameradirection">CameraDirection</a></code> | iOS and Web only: The camera direction. | <code>: CameraDirection.Rear</code> | 1.0.0 |
|
|
191
|
+
| **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the Camera. | <code>: 'fullscreen'</code> | 1.0.0 |
|
|
192
|
+
| **`webUseInput`** | <code>boolean</code> | Web only: Whether to use the PWA Element experience or file input. The default is to use PWA Elements if installed and fall back to file input. To always use file input, set this to `true`. Learn more about PWA Elements: https://capacitorjs.com/docs/pwa-elements | | 1.0.0 |
|
|
193
|
+
| **`promptLabelHeader`** | <code>string</code> | Text value to use when displaying the prompt. | <code>: 'Photo'</code> | 1.0.0 |
|
|
194
|
+
| **`promptLabelCancel`** | <code>string</code> | Text value to use when displaying the prompt. iOS only: The label of the 'cancel' button. | <code>: 'Cancel'</code> | 1.0.0 |
|
|
195
|
+
| **`promptLabelPhoto`** | <code>string</code> | Text value to use when displaying the prompt. The label of the button to select a saved image. | <code>: 'From Photos'</code> | 1.0.0 |
|
|
196
|
+
| **`promptLabelPicture`** | <code>string</code> | Text value to use when displaying the prompt. The label of the button to open the camera. | <code>: 'Take Picture'</code> | 1.0.0 |
|
|
198
197
|
|
|
199
198
|
|
|
200
199
|
#### GalleryPhotos
|
package/android/build.gradle
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.
|
|
3
|
-
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2
|
|
4
|
-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.
|
|
5
|
-
androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.3.
|
|
6
|
-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.
|
|
7
|
-
androidxMaterialVersion = project.hasProperty('androidxMaterialVersion') ? rootProject.ext.androidxMaterialVersion : '1.
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
4
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
5
|
+
androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.3.3'
|
|
6
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
7
|
+
androidxMaterialVersion = project.hasProperty('androidxMaterialVersion') ? rootProject.ext.androidxMaterialVersion : '1.6.1'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
buildscript {
|
|
@@ -13,17 +13,17 @@ buildscript {
|
|
|
13
13
|
mavenCentral()
|
|
14
14
|
}
|
|
15
15
|
dependencies {
|
|
16
|
-
classpath 'com.android.tools.build:gradle:
|
|
16
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
apply plugin: 'com.android.library'
|
|
21
21
|
|
|
22
22
|
android {
|
|
23
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
23
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
24
24
|
defaultConfig {
|
|
25
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
26
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
25
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
26
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
27
27
|
versionCode 1
|
|
28
28
|
versionName "1.0"
|
|
29
29
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -38,15 +38,14 @@ android {
|
|
|
38
38
|
abortOnError false
|
|
39
39
|
}
|
|
40
40
|
compileOptions {
|
|
41
|
-
sourceCompatibility JavaVersion.
|
|
42
|
-
targetCompatibility JavaVersion.
|
|
41
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
42
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
repositories {
|
|
47
47
|
google()
|
|
48
48
|
mavenCentral()
|
|
49
|
-
jcenter()
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
|
|
@@ -3,13 +3,18 @@ package com.capacitorjs.plugins.camera;
|
|
|
3
3
|
import android.Manifest;
|
|
4
4
|
import android.app.Activity;
|
|
5
5
|
import android.content.ActivityNotFoundException;
|
|
6
|
+
import android.content.ContentResolver;
|
|
7
|
+
import android.content.ContentValues;
|
|
6
8
|
import android.content.Intent;
|
|
7
9
|
import android.content.pm.PackageManager;
|
|
8
10
|
import android.content.pm.ResolveInfo;
|
|
9
11
|
import android.graphics.Bitmap;
|
|
10
12
|
import android.graphics.BitmapFactory;
|
|
11
13
|
import android.net.Uri;
|
|
14
|
+
import android.os.Build;
|
|
12
15
|
import android.os.Bundle;
|
|
16
|
+
import android.os.Environment;
|
|
17
|
+
import android.os.Parcelable;
|
|
13
18
|
import android.provider.MediaStore;
|
|
14
19
|
import android.util.Base64;
|
|
15
20
|
import androidx.activity.result.ActivityResult;
|
|
@@ -33,8 +38,10 @@ import java.io.FileNotFoundException;
|
|
|
33
38
|
import java.io.FileOutputStream;
|
|
34
39
|
import java.io.IOException;
|
|
35
40
|
import java.io.InputStream;
|
|
41
|
+
import java.io.OutputStream;
|
|
36
42
|
import java.util.ArrayList;
|
|
37
43
|
import java.util.List;
|
|
44
|
+
import java.util.Locale;
|
|
38
45
|
import java.util.Map;
|
|
39
46
|
import java.util.concurrent.Executor;
|
|
40
47
|
import java.util.concurrent.Executors;
|
|
@@ -97,7 +104,7 @@ public class CameraPlugin extends Plugin {
|
|
|
97
104
|
@PluginMethod
|
|
98
105
|
public void pickImages(PluginCall call) {
|
|
99
106
|
settings = getSettings(call);
|
|
100
|
-
openPhotos(call, true);
|
|
107
|
+
openPhotos(call, true, false);
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
private void doShow(PluginCall call) {
|
|
@@ -192,17 +199,20 @@ public class CameraPlugin extends Plugin {
|
|
|
192
199
|
*/
|
|
193
200
|
@PermissionCallback
|
|
194
201
|
private void cameraPermissionsCallback(PluginCall call) {
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
if (call.getMethodName().equals("pickImages")) {
|
|
203
|
+
openPhotos(call, true, true);
|
|
204
|
+
} else {
|
|
205
|
+
if (settings.getSource() == CameraSource.CAMERA && getPermissionState(CAMERA) != PermissionState.GRANTED) {
|
|
206
|
+
Logger.debug(getLogTag(), "User denied camera permission: " + getPermissionState(CAMERA).toString());
|
|
207
|
+
call.reject(PERMISSION_DENIED_ERROR_CAMERA);
|
|
208
|
+
return;
|
|
209
|
+
} else if (settings.getSource() == CameraSource.PHOTOS && getPermissionState(PHOTOS) != PermissionState.GRANTED) {
|
|
210
|
+
Logger.debug(getLogTag(), "User denied photos permission: " + getPermissionState(PHOTOS).toString());
|
|
211
|
+
call.reject(PERMISSION_DENIED_ERROR_PHOTOS);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
doShow(call);
|
|
203
215
|
}
|
|
204
|
-
|
|
205
|
-
doShow(call);
|
|
206
216
|
}
|
|
207
217
|
|
|
208
218
|
private CameraSettings getSettings(PluginCall call) {
|
|
@@ -228,7 +238,7 @@ public class CameraPlugin extends Plugin {
|
|
|
228
238
|
return null;
|
|
229
239
|
}
|
|
230
240
|
try {
|
|
231
|
-
return CameraResultType.valueOf(resultType.toUpperCase());
|
|
241
|
+
return CameraResultType.valueOf(resultType.toUpperCase(Locale.ROOT));
|
|
232
242
|
} catch (IllegalArgumentException ex) {
|
|
233
243
|
Logger.debug(getLogTag(), "Invalid result type \"" + resultType + "\", defaulting to base64");
|
|
234
244
|
return CameraResultType.BASE64;
|
|
@@ -260,16 +270,18 @@ public class CameraPlugin extends Plugin {
|
|
|
260
270
|
}
|
|
261
271
|
|
|
262
272
|
public void openPhotos(final PluginCall call) {
|
|
263
|
-
openPhotos(call, false);
|
|
273
|
+
openPhotos(call, false, false);
|
|
264
274
|
}
|
|
265
275
|
|
|
266
|
-
private void openPhotos(final PluginCall call, boolean multiple) {
|
|
267
|
-
if (
|
|
276
|
+
private void openPhotos(final PluginCall call, boolean multiple, boolean skipPermission) {
|
|
277
|
+
if (skipPermission || checkPhotosPermissions(call)) {
|
|
268
278
|
Intent intent = new Intent(Intent.ACTION_PICK);
|
|
269
279
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
|
|
270
280
|
intent.setType("image/*");
|
|
271
281
|
try {
|
|
272
282
|
if (multiple) {
|
|
283
|
+
intent.putExtra("multi-pick", multiple);
|
|
284
|
+
intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/*" });
|
|
273
285
|
startActivityForResult(call, intent, "processPickedImages");
|
|
274
286
|
} else {
|
|
275
287
|
startActivityForResult(call, intent, "processPickedImage");
|
|
@@ -320,21 +332,55 @@ public class CameraPlugin extends Plugin {
|
|
|
320
332
|
@ActivityCallback
|
|
321
333
|
public void processPickedImages(PluginCall call, ActivityResult result) {
|
|
322
334
|
Intent data = result.getData();
|
|
323
|
-
if (data != null
|
|
335
|
+
if (data != null) {
|
|
324
336
|
Executor executor = Executors.newSingleThreadExecutor();
|
|
325
337
|
executor.execute(
|
|
326
338
|
() -> {
|
|
327
339
|
JSObject ret = new JSObject();
|
|
328
340
|
JSArray photos = new JSArray();
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
341
|
+
if (data.getClipData() != null) {
|
|
342
|
+
int count = data.getClipData().getItemCount();
|
|
343
|
+
for (int i = 0; i < count; i++) {
|
|
344
|
+
Uri imageUri = data.getClipData().getItemAt(i).getUri();
|
|
345
|
+
JSObject processResult = processPickedImages(imageUri);
|
|
346
|
+
if (processResult.getString("error") != null && !processResult.getString("error").isEmpty()) {
|
|
347
|
+
call.reject(processResult.getString("error"));
|
|
348
|
+
return;
|
|
349
|
+
} else {
|
|
350
|
+
photos.put(processResult);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} else if (data.getData() != null) {
|
|
354
|
+
Uri imageUri = data.getData();
|
|
332
355
|
JSObject processResult = processPickedImages(imageUri);
|
|
333
356
|
if (processResult.getString("error") != null && !processResult.getString("error").isEmpty()) {
|
|
334
357
|
call.reject(processResult.getString("error"));
|
|
335
358
|
return;
|
|
336
359
|
} else {
|
|
337
|
-
photos.put(
|
|
360
|
+
photos.put(processResult);
|
|
361
|
+
}
|
|
362
|
+
} else if (data.getExtras() != null) {
|
|
363
|
+
Bundle bundle = data.getExtras();
|
|
364
|
+
if (bundle.keySet().contains("selectedItems")) {
|
|
365
|
+
ArrayList<Parcelable> fileUris = bundle.getParcelableArrayList("selectedItems");
|
|
366
|
+
if (fileUris != null) {
|
|
367
|
+
for (Parcelable fileUri : fileUris) {
|
|
368
|
+
if (fileUri instanceof Uri) {
|
|
369
|
+
Uri imageUri = (Uri) fileUri;
|
|
370
|
+
try {
|
|
371
|
+
JSObject processResult = processPickedImages(imageUri);
|
|
372
|
+
if (processResult.getString("error") != null && !processResult.getString("error").isEmpty()) {
|
|
373
|
+
call.reject(processResult.getString("error"));
|
|
374
|
+
return;
|
|
375
|
+
} else {
|
|
376
|
+
photos.put(processResult);
|
|
377
|
+
}
|
|
378
|
+
} catch (SecurityException ex) {
|
|
379
|
+
call.reject("SecurityException");
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
338
384
|
}
|
|
339
385
|
}
|
|
340
386
|
ret.put("photos", photos);
|
|
@@ -453,15 +499,21 @@ public class CameraPlugin extends Plugin {
|
|
|
453
499
|
private Uri saveImage(Uri uri, InputStream is) throws IOException {
|
|
454
500
|
File outFile = null;
|
|
455
501
|
if (uri.getScheme().equals("content")) {
|
|
456
|
-
|
|
457
|
-
if (!filename.contains(".jpg") && !filename.contains(".jpeg")) {
|
|
458
|
-
filename += "." + (new java.util.Date()).getTime() + ".jpeg";
|
|
459
|
-
}
|
|
460
|
-
File cacheDir = getContext().getCacheDir();
|
|
461
|
-
outFile = new File(cacheDir, filename);
|
|
502
|
+
outFile = getTempFile(uri);
|
|
462
503
|
} else {
|
|
463
504
|
outFile = new File(uri.getPath());
|
|
464
505
|
}
|
|
506
|
+
try {
|
|
507
|
+
writePhoto(outFile, is);
|
|
508
|
+
} catch (FileNotFoundException ex) {
|
|
509
|
+
// Some gallery apps return read only file url, create a temporary file for modifications
|
|
510
|
+
outFile = getTempFile(uri);
|
|
511
|
+
writePhoto(outFile, is);
|
|
512
|
+
}
|
|
513
|
+
return Uri.fromFile(outFile);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
private void writePhoto(File outFile, InputStream is) throws IOException {
|
|
465
517
|
FileOutputStream fos = new FileOutputStream(outFile);
|
|
466
518
|
byte[] buffer = new byte[1024];
|
|
467
519
|
int len;
|
|
@@ -469,7 +521,15 @@ public class CameraPlugin extends Plugin {
|
|
|
469
521
|
fos.write(buffer, 0, len);
|
|
470
522
|
}
|
|
471
523
|
fos.close();
|
|
472
|
-
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
private File getTempFile(Uri uri) {
|
|
527
|
+
String filename = Uri.parse(Uri.decode(uri.toString())).getLastPathSegment();
|
|
528
|
+
if (!filename.contains(".jpg") && !filename.contains(".jpeg")) {
|
|
529
|
+
filename += "." + (new java.util.Date()).getTime() + ".jpeg";
|
|
530
|
+
}
|
|
531
|
+
File cacheDir = getContext().getCacheDir();
|
|
532
|
+
return new File(cacheDir, filename);
|
|
473
533
|
}
|
|
474
534
|
|
|
475
535
|
/**
|
|
@@ -478,6 +538,7 @@ public class CameraPlugin extends Plugin {
|
|
|
478
538
|
* @param bitmap
|
|
479
539
|
* @param u
|
|
480
540
|
*/
|
|
541
|
+
@SuppressWarnings("deprecation")
|
|
481
542
|
private void returnResult(PluginCall call, Bitmap bitmap, Uri u) {
|
|
482
543
|
ExifWrapper exif = ImageUtils.getExifData(getContext(), bitmap, u);
|
|
483
544
|
try {
|
|
@@ -501,18 +562,49 @@ public class CameraPlugin extends Plugin {
|
|
|
501
562
|
try {
|
|
502
563
|
String fileToSavePath = imageEditedFileSavePath != null ? imageEditedFileSavePath : imageFileSavePath;
|
|
503
564
|
File fileToSave = new File(fileToSavePath);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
565
|
+
|
|
566
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
567
|
+
ContentResolver resolver = getContext().getContentResolver();
|
|
568
|
+
ContentValues values = new ContentValues();
|
|
569
|
+
values.put(MediaStore.MediaColumns.DISPLAY_NAME, fileToSave.getName());
|
|
570
|
+
values.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg");
|
|
571
|
+
values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM);
|
|
572
|
+
|
|
573
|
+
final Uri contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
|
574
|
+
Uri uri = resolver.insert(contentUri, values);
|
|
575
|
+
|
|
576
|
+
if (uri == null) {
|
|
577
|
+
throw new IOException("Failed to create new MediaStore record.");
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
OutputStream stream = resolver.openOutputStream(uri);
|
|
581
|
+
if (stream == null) {
|
|
582
|
+
throw new IOException("Failed to open output stream.");
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
Boolean inserted = bitmap.compress(Bitmap.CompressFormat.JPEG, settings.getQuality(), stream);
|
|
586
|
+
|
|
587
|
+
if (!inserted) {
|
|
588
|
+
isSaved = false;
|
|
589
|
+
}
|
|
590
|
+
} else {
|
|
591
|
+
String inserted = MediaStore.Images.Media.insertImage(
|
|
592
|
+
getContext().getContentResolver(),
|
|
593
|
+
fileToSavePath,
|
|
594
|
+
fileToSave.getName(),
|
|
595
|
+
""
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
if (inserted == null) {
|
|
599
|
+
isSaved = false;
|
|
600
|
+
}
|
|
512
601
|
}
|
|
513
602
|
} catch (FileNotFoundException e) {
|
|
514
603
|
isSaved = false;
|
|
515
604
|
Logger.error(getLogTag(), IMAGE_GALLERY_SAVE_ERROR, e);
|
|
605
|
+
} catch (IOException e) {
|
|
606
|
+
isSaved = false;
|
|
607
|
+
Logger.error(getLogTag(), IMAGE_GALLERY_SAVE_ERROR, e);
|
|
516
608
|
}
|
|
517
609
|
}
|
|
518
610
|
|
|
@@ -15,14 +15,15 @@ import java.io.InputStream;
|
|
|
15
15
|
public class ImageUtils {
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Resize an image to the given width and height
|
|
18
|
+
* Resize an image to the given max width and max height. Constraint can be put
|
|
19
|
+
* on one dimension, or both. Resize will always preserve aspect ratio.
|
|
19
20
|
* @param bitmap
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
21
|
+
* @param desiredMaxWidth
|
|
22
|
+
* @param desiredMaxHeight
|
|
22
23
|
* @return a new, scaled Bitmap
|
|
23
24
|
*/
|
|
24
|
-
public static Bitmap resize(Bitmap bitmap, final int
|
|
25
|
-
return ImageUtils.resizePreservingAspectRatio(bitmap,
|
|
25
|
+
public static Bitmap resize(Bitmap bitmap, final int desiredMaxWidth, final int desiredMaxHeight) {
|
|
26
|
+
return ImageUtils.resizePreservingAspectRatio(bitmap, desiredMaxWidth, desiredMaxHeight);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/**
|
package/dist/docs.json
CHANGED
|
@@ -276,22 +276,6 @@
|
|
|
276
276
|
"complexTypes": [],
|
|
277
277
|
"type": "number | undefined"
|
|
278
278
|
},
|
|
279
|
-
{
|
|
280
|
-
"name": "preserveAspectRatio",
|
|
281
|
-
"tags": [
|
|
282
|
-
{
|
|
283
|
-
"text": "will be removed in next major version.",
|
|
284
|
-
"name": "deprecated"
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
"text": "1.0.0",
|
|
288
|
-
"name": "since"
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
"docs": "This setting has no effect.\nPicture resizing always preserve aspect ratio.",
|
|
292
|
-
"complexTypes": [],
|
|
293
|
-
"type": "boolean | undefined"
|
|
294
|
-
},
|
|
295
279
|
{
|
|
296
280
|
"name": "correctOrientation",
|
|
297
281
|
"tags": [
|
|
@@ -76,14 +76,6 @@ export interface ImageOptions {
|
|
|
76
76
|
* @since 1.0.0
|
|
77
77
|
*/
|
|
78
78
|
height?: number;
|
|
79
|
-
/**
|
|
80
|
-
* This setting has no effect.
|
|
81
|
-
* Picture resizing always preserve aspect ratio.
|
|
82
|
-
*
|
|
83
|
-
* @deprecated will be removed in next major version.
|
|
84
|
-
* @since 1.0.0
|
|
85
|
-
*/
|
|
86
|
-
preserveAspectRatio?: boolean;
|
|
87
79
|
/**
|
|
88
80
|
* Whether to automatically rotate the image "up" to correct for orientation
|
|
89
81
|
* in portrait mode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAmTA,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,iCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport type CameraPermissionState = PermissionState | 'limited';\n\nexport type CameraPermissionType = 'camera' | 'photos';\n\nexport interface PermissionStatus {\n camera: CameraPermissionState;\n photos: CameraPermissionState;\n}\n\nexport interface CameraPluginPermissions {\n permissions: CameraPermissionType[];\n}\n\nexport interface CameraPlugin {\n /**\n * Prompt the user to pick a photo from an album, or take a new photo\n * with the camera.\n *\n * @since 1.0.0\n */\n getPhoto(options: ImageOptions): Promise<Photo>;\n\n /**\n * Allows the user to pick multiple pictures from the photo gallery.\n * On iOS 13 and older it only allows to pick one picture.\n *\n * @since 1.2.0\n */\n pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>;\n\n /**\n * Check camera and photo album permissions\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and photo album permissions\n *\n * @since 1.0.0\n */\n requestPermissions(\n permissions?: CameraPluginPermissions,\n ): Promise<PermissionStatus>;\n}\n\nexport interface ImageOptions {\n /**\n * The quality of image to return as JPEG, from 0-100\n *\n * @since 1.0.0\n */\n quality?: number;\n /**\n * Whether to allow the user to crop or make small edits (platform specific).\n * On iOS 14+ it's only supported for CameraSource.Camera, but not for CameraSource.Photos.\n *\n * @since 1.0.0\n */\n allowEditing?: boolean;\n /**\n * How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported\n *\n * @since 1.0.0\n */\n resultType: CameraResultType;\n /**\n * Whether to save the photo to the gallery.\n * If the photo was picked from the gallery, it will only be saved if edited.\n * @default: false\n *\n * @since 1.0.0\n */\n saveToGallery?: boolean;\n /**\n * The width of the saved image\n *\n * @since 1.0.0\n */\n width?: number;\n /**\n * The height of the saved image\n *\n * @since 1.0.0\n */\n height?: number;\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode\n * @default: true\n *\n * @since 1.0.0\n */\n correctOrientation?: boolean;\n /**\n * The source to get the photo from. By default this prompts the user to select\n * either the photo album or take a photo.\n * @default: CameraSource.Prompt\n *\n * @since 1.0.0\n */\n source?: CameraSource;\n /**\n * iOS and Web only: The camera direction.\n * @default: CameraDirection.Rear\n *\n * @since 1.0.0\n */\n direction?: CameraDirection;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default: 'fullscreen'\n *\n * @since 1.0.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/pwa-elements\n *\n * @since 1.0.0\n */\n webUseInput?: boolean;\n\n /**\n * Text value to use when displaying the prompt.\n * @default: 'Photo'\n *\n * @since 1.0.0\n *\n */\n promptLabelHeader?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * iOS only: The label of the 'cancel' button.\n * @default: 'Cancel'\n *\n * @since 1.0.0\n */\n promptLabelCancel?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * The label of the button to select a saved image.\n * @default: 'From Photos'\n *\n * @since 1.0.0\n */\n promptLabelPhoto?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * The label of the button to open the camera.\n * @default: 'Take Picture'\n *\n * @since 1.0.0\n */\n promptLabelPicture?: string;\n}\n\nexport interface Photo {\n /**\n * The base64 encoded string representation of the image, if using CameraResultType.Base64.\n *\n * @since 1.0.0\n */\n base64String?: string;\n /**\n * The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl.\n *\n * @since 1.0.0\n */\n dataUrl?: string;\n /**\n * If using CameraResultType.Uri, the path will contain a full,\n * platform-specific file URL that can be read later using the Filsystem API.\n *\n * @since 1.0.0\n */\n path?: string;\n /**\n * webPath returns a path that can be used to set the src attribute of an image for efficient\n * loading and rendering.\n *\n * @since 1.0.0\n */\n webPath?: string;\n /**\n * Exif data, if any, retrieved from the image\n *\n * @since 1.0.0\n */\n exif?: any;\n /**\n * The format of the image, ex: jpeg, png, gif.\n *\n * iOS and Android only support jpeg.\n * Web supports jpeg and png. gif is only supported if using file input.\n *\n * @since 1.0.0\n */\n format: string;\n /**\n * Whether if the image was saved to the gallery or not.\n *\n * On Android and iOS, saving to the gallery can fail if the user didn't\n * grant the required permissions.\n * On Web there is no gallery, so always returns false.\n *\n * @since 1.1.0\n */\n saved: boolean;\n}\n\nexport interface GalleryPhotos {\n /**\n * Array of all the picked photos.\n *\n * @since 1.2.0\n */\n photos: GalleryPhoto[];\n}\n\nexport interface GalleryPhoto {\n /**\n * Full, platform-specific file URL that can be read later using the Filsystem API.\n *\n * @since 1.2.0\n */\n path?: string;\n /**\n * webPath returns a path that can be used to set the src attribute of an image for efficient\n * loading and rendering.\n *\n * @since 1.2.0\n */\n webPath: string;\n /**\n * Exif data, if any, retrieved from the image\n *\n * @since 1.2.0\n */\n exif?: any;\n /**\n * The format of the image, ex: jpeg, png, gif.\n *\n * iOS and Android only support jpeg.\n * Web supports jpeg, png and gif.\n *\n * @since 1.2.0\n */\n format: string;\n}\nexport interface GalleryImageOptions {\n /**\n * The quality of image to return as JPEG, from 0-100\n *\n * @since 1.2.0\n */\n quality?: number;\n /**\n * The width of the saved image\n *\n * @since 1.2.0\n */\n width?: number;\n /**\n * The height of the saved image\n *\n * @since 1.2.0\n */\n height?: number;\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode\n * @default: true\n *\n * @since 1.2.0\n */\n correctOrientation?: boolean;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default: 'fullscreen'\n *\n * @since 1.2.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * iOS only: Maximum number of pictures the user will be able to choose.\n * @default 0 (unlimited)\n *\n * @since 1.2.0\n */\n limit?: number;\n}\n\nexport enum CameraSource {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n Prompt = 'PROMPT',\n /**\n * Take a new photo using the camera.\n */\n Camera = 'CAMERA',\n /**\n * Pick an existing photo fron the gallery or photo album.\n */\n Photos = 'PHOTOS',\n}\n\nexport enum CameraDirection {\n Rear = 'REAR',\n Front = 'FRONT',\n}\n\nexport enum CameraResultType {\n Uri = 'uri',\n Base64 = 'base64',\n DataUrl = 'dataUrl',\n}\n\n/**\n * @deprecated Use `Photo`.\n * @since 1.0.0\n */\nexport type CameraPhoto = Photo;\n\n/**\n * @deprecated Use `ImageOptions`.\n * @since 1.0.0\n */\nexport type CameraOptions = ImageOptions;\n"]}
|
|
@@ -52,7 +52,7 @@ internal extension PHAsset {
|
|
|
52
52
|
options.version = .current
|
|
53
53
|
|
|
54
54
|
var result: [String: Any] = [:]
|
|
55
|
-
_ = PHCachingImageManager().
|
|
55
|
+
_ = PHCachingImageManager().requestImageDataAndOrientation(for: self, options: options) { (data, _, _, _) in
|
|
56
56
|
if let data = data as NSData? {
|
|
57
57
|
let options = [kCGImageSourceShouldCache as String: kCFBooleanFalse] as CFDictionary
|
|
58
58
|
if let imgSrc = CGImageSourceCreateWithData(data, options),
|
|
@@ -75,7 +75,6 @@ public class CameraPlugin: CAPPlugin {
|
|
|
75
75
|
if let missingUsageDescription = checkUsageDescriptions() {
|
|
76
76
|
CAPLog.print("⚡️ ", self.pluginId, "-", missingUsageDescription)
|
|
77
77
|
call.reject(missingUsageDescription)
|
|
78
|
-
bridge?.alert("Camera Error", "Missing required usage description. See console for more information")
|
|
79
78
|
return
|
|
80
79
|
}
|
|
81
80
|
|
|
@@ -158,11 +157,12 @@ extension CameraPlugin: UIImagePickerControllerDelegate, UINavigationControllerD
|
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
|
|
161
|
-
picker.dismiss(animated: true
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
picker.dismiss(animated: true) {
|
|
161
|
+
if let processedImage = self.processImage(from: info) {
|
|
162
|
+
self.returnProcessedImage(processedImage)
|
|
163
|
+
} else {
|
|
164
|
+
self.call?.reject("Error processing image")
|
|
165
|
+
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -339,7 +339,6 @@ private extension CameraPlugin {
|
|
|
339
339
|
// check if we have a camera
|
|
340
340
|
if (bridge?.isSimEnvironment ?? false) || !UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
|
|
341
341
|
CAPLog.print("⚡️ ", self.pluginId, "-", "Camera not available in simulator")
|
|
342
|
-
bridge?.alert("Camera Error", "Camera not available in Simulator")
|
|
343
342
|
call?.reject("Camera not available while running in Simulator")
|
|
344
343
|
return
|
|
345
344
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/camera",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "The Camera API provides the ability to take a photo with the camera or choose an existing one from the photo album.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
32
|
-
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
|
32
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
33
33
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
34
34
|
"verify:web": "npm run build",
|
|
35
35
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"publish:cocoapod": "pod trunk push ./CapacitorCamera.podspec --allow-warnings"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@capacitor/android": "
|
|
49
|
-
"@capacitor/core": "
|
|
48
|
+
"@capacitor/android": "next",
|
|
49
|
+
"@capacitor/core": "next",
|
|
50
50
|
"@capacitor/docgen": "0.0.18",
|
|
51
|
-
"@capacitor/ios": "
|
|
51
|
+
"@capacitor/ios": "next",
|
|
52
52
|
"@ionic/eslint-config": "^0.3.0",
|
|
53
53
|
"@ionic/prettier-config": "~1.0.1",
|
|
54
54
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"typescript": "~4.1.5"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@capacitor/core": "
|
|
64
|
+
"@capacitor/core": "next"
|
|
65
65
|
},
|
|
66
66
|
"prettier": "@ionic/prettier-config",
|
|
67
67
|
"swiftlint": "@ionic/swiftlint-config",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "fd7db8285f72990522da0adc889514c9804b6dae"
|
|
83
83
|
}
|