@capacitor-community/camera-preview 2.1.0 → 3.1.1
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/README.md +14 -3
- package/android/build.gradle +15 -10
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +3 -3
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +835 -799
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +184 -173
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +12 -14
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +16 -18
- package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +327 -323
- package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +15 -14
- package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +4 -3
- package/dist/esm/definitions.d.ts +10 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +3 -3
- package/dist/esm/web.js +36 -25
- package/dist/esm/web.js.map +1 -1
- package/ios/Plugin/CameraController.swift +107 -129
- package/ios/Plugin/Plugin.swift +76 -90
- package/ios/PluginTests/PluginTests.swift +8 -8
- package/package.json +27 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
<br>
|
|
11
11
|
|
|
12
|
-
Version 2 of this plugin is compatible with Ionic 5+ and Capacitor 3. If your project uses Capacitor 2, please make sure you install [version 1](https://github.com/capacitor-community/camera-preview/releases/tag/v1.2.1) of this plugin.
|
|
12
|
+
Version 2+ of this plugin is compatible with Ionic 5+ and Capacitor 3. If your project uses Capacitor 2, please make sure you install [version 1](https://github.com/capacitor-community/camera-preview/releases/tag/v1.2.1) of this plugin.
|
|
13
13
|
|
|
14
14
|
**PR's are greatly appreciated.**
|
|
15
15
|
|
|
@@ -45,6 +45,8 @@ npx cap sync
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
## Extra Android installation steps
|
|
48
|
+
**Important** `camera-preview` 3+ requires Gradle 7. If you are using Gradle 4, please use [version 2](https://github.com/capacitor-community/camera-preview/tree/v2.1.0) of this plugin.
|
|
49
|
+
|
|
48
50
|
Open `android/app/src/main/AndroidManifest.xml` and above the closing `</manifest>` tag add this line to request the CAMERA permission:
|
|
49
51
|
```xml
|
|
50
52
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
@@ -52,11 +54,20 @@ Open `android/app/src/main/AndroidManifest.xml` and above the closing `</manifes
|
|
|
52
54
|
For more help consult the [Capacitor docs](https://capacitorjs.com/docs/android/configuration#configuring-androidmanifestxml).
|
|
53
55
|
|
|
54
56
|
## Extra iOS installation steps
|
|
55
|
-
You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs](https://capacitorjs.com/docs/ios/configuration#configuring-infoplist) and add permissions with the raw keys `NSCameraUsageDescription` and `NSMicrophoneUsageDescription`.
|
|
57
|
+
You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs](https://capacitorjs.com/docs/ios/configuration#configuring-infoplist) and add permissions with the raw keys `NSCameraUsageDescription` and `NSMicrophoneUsageDescription`. `NSMicrophoneUsageDescription` is only required, if audio will be used. Otherwise set the `disableAudio` option to `true`, which also disables the microphone permission request.
|
|
56
58
|
|
|
57
59
|
## Extra Web installation steps
|
|
58
60
|
Add `import '@capacitor-community/camera-preview'` to you entry script in ionic on `app.module.ts`, so capacitor can register the web platform from the plugin
|
|
59
61
|
|
|
62
|
+
then in html add
|
|
63
|
+
|
|
64
|
+
<div id="cameraPreview"></div>
|
|
65
|
+
|
|
66
|
+
and
|
|
67
|
+
ngOnInit() { const { CameraPreview } = Plugins; CameraPreview.start({ parent: "cameraPreview"}); }
|
|
68
|
+
|
|
69
|
+
it will work
|
|
70
|
+
|
|
60
71
|
|
|
61
72
|
# Methods
|
|
62
73
|
|
|
@@ -78,7 +89,7 @@ Starts the camera preview instance.
|
|
|
78
89
|
| storeToFile | boolean | (optional) Capture images to a file and return back the file path instead of returning base64 encoded data, default false. |
|
|
79
90
|
| disableExifHeaderStripping | boolean | (optional) Disable automatic rotation of the image, and let the browser deal with it, default true (applicable to the android and ios platforms only) |
|
|
80
91
|
| enableHighResolution | boolean | (optional) Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device |
|
|
81
|
-
| disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web only) |
|
|
92
|
+
| disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web and iOS only) |
|
|
82
93
|
| lockAndroidOrientation | boolean | (optional) Locks device orientation when camera is showing, default false. (applicable to Android only) |
|
|
83
94
|
| enableOpacity | boolean | (optional) Make the camera preview see-through. Ideal for augmented reality uses. Default false (applicable to Android and web only)
|
|
84
95
|
| enableZoom | boolean | (optional) Set if you can pinch to zoom. Default false (applicable to the android and ios platforms only)
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
buildscript {
|
|
2
9
|
repositories {
|
|
3
|
-
|
|
10
|
+
mavenCentral()
|
|
4
11
|
google()
|
|
5
12
|
}
|
|
6
13
|
dependencies {
|
|
@@ -11,10 +18,10 @@ buildscript {
|
|
|
11
18
|
apply plugin: 'com.android.library'
|
|
12
19
|
|
|
13
20
|
android {
|
|
14
|
-
compileSdkVersion 30
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
|
|
15
22
|
defaultConfig {
|
|
16
|
-
minSdkVersion 21
|
|
17
|
-
targetSdkVersion 30
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
|
|
18
25
|
versionCode 1
|
|
19
26
|
versionName "1.0"
|
|
20
27
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
@@ -32,7 +39,6 @@ android {
|
|
|
32
39
|
|
|
33
40
|
repositories {
|
|
34
41
|
google()
|
|
35
|
-
jcenter()
|
|
36
42
|
mavenCentral()
|
|
37
43
|
}
|
|
38
44
|
|
|
@@ -40,11 +46,10 @@ repositories {
|
|
|
40
46
|
dependencies {
|
|
41
47
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
42
48
|
implementation project(':capacitor-android')
|
|
43
|
-
implementation
|
|
49
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
44
50
|
implementation 'androidx.exifinterface:exifinterface:1.3.2'
|
|
45
|
-
testImplementation
|
|
46
|
-
androidTestImplementation
|
|
47
|
-
androidTestImplementation
|
|
48
|
-
compile 'com.android.support:appcompat-v7:+'
|
|
51
|
+
testImplementation "junit:junit:$junitVersion"
|
|
52
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
53
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
package com.getcapacitor.android;
|
|
2
2
|
|
|
3
|
+
import static org.junit.Assert.*;
|
|
4
|
+
|
|
3
5
|
import android.content.Context;
|
|
4
6
|
import android.support.test.InstrumentationRegistry;
|
|
5
7
|
import android.support.test.runner.AndroidJUnit4;
|
|
6
|
-
|
|
7
8
|
import org.junit.Test;
|
|
8
9
|
import org.junit.runner.RunWith;
|
|
9
10
|
|
|
10
|
-
import static org.junit.Assert.*;
|
|
11
|
-
|
|
12
11
|
/**
|
|
13
12
|
* Instrumented test, which will execute on an Android device.
|
|
14
13
|
*
|
|
@@ -16,6 +15,7 @@ import static org.junit.Assert.*;
|
|
|
16
15
|
*/
|
|
17
16
|
@RunWith(AndroidJUnit4.class)
|
|
18
17
|
public class ExampleInstrumentedTest {
|
|
18
|
+
|
|
19
19
|
@Test
|
|
20
20
|
public void useAppContext() throws Exception {
|
|
21
21
|
// Context of the app under test.
|