@capacitor-community/camera-preview 2.0.0 → 3.1.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/README.md +27 -8
- package/android/build.gradle +2 -4
- 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/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +24 -23
- package/dist/esm/web.js.map +1 -1
- package/ios/Plugin/CameraController.swift +173 -114
- package/ios/Plugin/Plugin.swift +79 -88
- 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,7 +54,7 @@ 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
|
|
@@ -77,10 +79,11 @@ Starts the camera preview instance.
|
|
|
77
79
|
| rotateWhenOrientationChanged | boolean | (optional) Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
|
|
78
80
|
| storeToFile | boolean | (optional) Capture images to a file and return back the file path instead of returning base64 encoded data, default false. |
|
|
79
81
|
| 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
|
-
|
|
|
82
|
+
| 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 |
|
|
83
|
+
| disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web and iOS only) |
|
|
81
84
|
| lockAndroidOrientation | boolean | (optional) Locks device orientation when camera is showing, default false. (applicable to Android only) |
|
|
82
85
|
| enableOpacity | boolean | (optional) Make the camera preview see-through. Ideal for augmented reality uses. Default false (applicable to Android and web only)
|
|
83
|
-
| enableZoom | boolean | (optional) Set if you can pinch to zoom. Default false (applicable to
|
|
86
|
+
| enableZoom | boolean | (optional) Set if you can pinch to zoom. Default false (applicable to the android and ios platforms only)
|
|
84
87
|
|
|
85
88
|
<!-- <strong>Options:</strong>
|
|
86
89
|
All options stated are optional and will default to values here
|
|
@@ -98,9 +101,7 @@ All options stated are optional and will default to values here
|
|
|
98
101
|
* `disableExifHeaderStripping` - Defaults to false - **Android Only** - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) -->
|
|
99
102
|
|
|
100
103
|
```javascript
|
|
101
|
-
import {
|
|
102
|
-
const { CameraPreview } = Plugins;
|
|
103
|
-
import { CameraPreviewOptions } from '@capacitor-community/camera-preview';
|
|
104
|
+
import { CameraPreview, CameraPreviewOptions } from '@capacitor-community/camera-preview';
|
|
104
105
|
|
|
105
106
|
const cameraPreviewOptions: CameraPreviewOptions = {
|
|
106
107
|
position: 'rear',
|
|
@@ -117,6 +118,7 @@ ion-content {
|
|
|
117
118
|
--background: transparent;
|
|
118
119
|
}
|
|
119
120
|
```
|
|
121
|
+
|
|
120
122
|
Take into account that this will make transparent all ion-content on application, if you want to show camera preview only in one page, just add a custom class to your ion-content and make it transparent:
|
|
121
123
|
|
|
122
124
|
```css
|
|
@@ -125,6 +127,23 @@ Take into account that this will make transparent all ion-content on application
|
|
|
125
127
|
}
|
|
126
128
|
```
|
|
127
129
|
|
|
130
|
+
If the camera preview is not displaying after applying the above styles, apply transparent background color to the root div element of the parent component
|
|
131
|
+
Ex: VueJS >> App.vue component
|
|
132
|
+
```html
|
|
133
|
+
<template>
|
|
134
|
+
<ion-app id="app">
|
|
135
|
+
<ion-router-outlet />
|
|
136
|
+
</ion-app>
|
|
137
|
+
</template>
|
|
138
|
+
|
|
139
|
+
<style>
|
|
140
|
+
#app {
|
|
141
|
+
background-color: transparent !important;
|
|
142
|
+
}
|
|
143
|
+
<style>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
|
|
128
147
|
### stop()
|
|
129
148
|
|
|
130
149
|
<info>Stops the camera preview instance.</info><br/>
|
|
@@ -174,7 +193,7 @@ CameraPreview.hide();
|
|
|
174
193
|
<!-- <info>Take the picture. If width and height are not specified or are 0 it will use the defaults. If width and height are specified, it will choose a supported photo size that is closest to width and height specified and has closest aspect ratio to the preview. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/> -->
|
|
175
194
|
|
|
176
195
|
```javascript
|
|
177
|
-
import {
|
|
196
|
+
import { CameraPreviewPictureOptions } from '@capacitor-community/camera-preview';
|
|
178
197
|
|
|
179
198
|
const cameraPreviewPictureOptions: CameraPreviewPictureOptions = {
|
|
180
199
|
quality: 50
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
repositories {
|
|
3
|
-
|
|
3
|
+
mavenCentral()
|
|
4
4
|
google()
|
|
5
5
|
}
|
|
6
6
|
dependencies {
|
|
@@ -32,7 +32,6 @@ android {
|
|
|
32
32
|
|
|
33
33
|
repositories {
|
|
34
34
|
google()
|
|
35
|
-
jcenter()
|
|
36
35
|
mavenCentral()
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -40,11 +39,10 @@ repositories {
|
|
|
40
39
|
dependencies {
|
|
41
40
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
42
41
|
implementation project(':capacitor-android')
|
|
43
|
-
implementation '
|
|
42
|
+
implementation 'com.android.support:appcompat-v7:28.0.0'
|
|
44
43
|
implementation 'androidx.exifinterface:exifinterface:1.3.2'
|
|
45
44
|
testImplementation 'junit:junit:4.12'
|
|
46
45
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
|
47
46
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
|
48
|
-
compile 'com.android.support:appcompat-v7:+'
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -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.
|