@capacitor-community/camera-preview 4.0.0-0 → 5.0.0-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.
Files changed (29) hide show
  1. package/README.md +11 -2
  2. package/android/.gradle/8.0.2/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.0.2/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/8.0.2/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/8.0.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  6. package/android/.gradle/8.0.2/dependencies-accessors/gc.properties +0 -0
  7. package/android/.gradle/8.0.2/executionHistory/executionHistory.bin +0 -0
  8. package/android/.gradle/8.0.2/executionHistory/executionHistory.lock +0 -0
  9. package/android/.gradle/8.0.2/fileChanges/last-build.bin +0 -0
  10. package/android/.gradle/8.0.2/fileHashes/fileHashes.bin +0 -0
  11. package/android/.gradle/8.0.2/fileHashes/fileHashes.lock +0 -0
  12. package/android/.gradle/8.0.2/gc.properties +0 -0
  13. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  14. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  15. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  16. package/android/.gradle/file-system.probe +0 -0
  17. package/android/.gradle/vcs-1/gc.properties +0 -0
  18. package/android/build.gradle +7 -6
  19. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  20. package/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  21. package/android/gradle.properties +1 -1
  22. package/android/gradlew +14 -4
  23. package/android/gradlew.bat +34 -32
  24. package/android/src/main/AndroidManifest.xml +1 -1
  25. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +35 -0
  26. package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +1 -1
  27. package/dist/esm/definitions.d.ts +2 -2
  28. package/ios/Plugin/CameraController.swift +1 -0
  29. package/package.json +7 -7
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
  <h3 align="center">Capacitor Camera Preview</h3>
3
3
  <p align="center"><strong><code>@capacitor-community/camera-preview</code></strong></p>
4
4
  <br>
5
- <p align="center"><strong>CAPACITOR 3</strong></p><br>
5
+ <p align="center"><strong>CAPACITOR 4</strong></p><br>
6
6
 
7
7
  <p align="center">
8
8
  Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
9
9
  </p>
10
10
  <br>
11
-
11
+ Version 4 of this plugin requires Capacitor 4. If you are using Capacitor 3, use [version 3](https://github.com/capacitor-community/camera-preview/releases/tag/v3.1.2)
12
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.**
@@ -59,6 +59,15 @@ You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs
59
59
  ## Extra Web installation steps
60
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
61
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
+
62
71
 
63
72
  # Methods
64
73
 
File without changes
@@ -0,0 +1,2 @@
1
+ #Fri May 19 14:57:02 CEST 2023
2
+ gradle.version=8.0.2
File without changes
@@ -1,8 +1,8 @@
1
1
  ext {
2
2
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
6
  }
7
7
 
8
8
  buildscript {
@@ -11,17 +11,18 @@ buildscript {
11
11
  google()
12
12
  }
13
13
  dependencies {
14
- classpath 'com.android.tools.build:gradle:7.2.1'
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
15
  }
16
16
  }
17
17
 
18
18
  apply plugin: 'com.android.library'
19
19
 
20
20
  android {
21
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
21
+ namespace "com.ahm.capacitor.camera.preview.capacitorcamerapreview"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
22
23
  defaultConfig {
23
24
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
25
26
  versionCode 1
26
27
  versionName "1.0"
27
28
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -1,6 +1,6 @@
1
- #Fri Dec 01 12:41:00 CST 2017
2
1
  distributionBase=GRADLE_USER_HOME
3
2
  distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
4
+ networkTimeout=10000
4
5
  zipStoreBase=GRADLE_USER_HOME
5
6
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
@@ -11,8 +11,8 @@
11
11
  # The setting is particularly useful for tweaking memory settings.
12
12
  org.gradle.jvmargs=-Xmx1536m
13
13
  android.useAndroidX=true
14
- android.enableJetifier=true
15
14
  # When configured, Gradle will run in incubating parallel mode.
16
15
  # This option should only be used with decoupled projects. More details, visit
17
16
  # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18
17
  # org.gradle.parallel=true
18
+
package/android/gradlew CHANGED
@@ -55,7 +55,7 @@
55
55
  # Darwin, MinGW, and NonStop.
56
56
  #
57
57
  # (3) This script is generated from the Groovy template
58
- # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58
+ # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
59
  # within the Gradle project.
60
60
  #
61
61
  # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,10 +80,10 @@ do
80
80
  esac
81
81
  done
82
82
 
83
- APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84
-
85
- APP_NAME="Gradle"
83
+ # This is normally unused
84
+ # shellcheck disable=SC2034
86
85
  APP_BASE_NAME=${0##*/}
86
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87
87
 
88
88
  # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
89
  DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@@ -143,12 +143,16 @@ fi
143
143
  if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
144
  case $MAX_FD in #(
145
145
  max*)
146
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147
+ # shellcheck disable=SC3045
146
148
  MAX_FD=$( ulimit -H -n ) ||
147
149
  warn "Could not query maximum file descriptor limit"
148
150
  esac
149
151
  case $MAX_FD in #(
150
152
  '' | soft) :;; #(
151
153
  *)
154
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155
+ # shellcheck disable=SC3045
152
156
  ulimit -n "$MAX_FD" ||
153
157
  warn "Could not set maximum file descriptor limit to $MAX_FD"
154
158
  esac
@@ -205,6 +209,12 @@ set -- \
205
209
  org.gradle.wrapper.GradleWrapperMain \
206
210
  "$@"
207
211
 
212
+ # Stop when "xargs" is not available.
213
+ if ! command -v xargs >/dev/null 2>&1
214
+ then
215
+ die "xargs is not available"
216
+ fi
217
+
208
218
  # Use "xargs" to parse quoted args.
209
219
  #
210
220
  # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
@@ -1,4 +1,20 @@
1
- @if "%DEBUG%" == "" @echo off
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
17
+ @if "%DEBUG%"=="" @echo off
2
18
  @rem ##########################################################################
3
19
  @rem
4
20
  @rem Gradle startup script for Windows
@@ -8,20 +24,24 @@
8
24
  @rem Set local scope for the variables with windows NT shell
9
25
  if "%OS%"=="Windows_NT" setlocal
10
26
 
11
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
- set DEFAULT_JVM_OPTS=
13
-
14
27
  set DIRNAME=%~dp0
15
- if "%DIRNAME%" == "" set DIRNAME=.
28
+ if "%DIRNAME%"=="" set DIRNAME=.
29
+ @rem This is normally unused
16
30
  set APP_BASE_NAME=%~n0
17
31
  set APP_HOME=%DIRNAME%
18
32
 
33
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35
+
36
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38
+
19
39
  @rem Find java.exe
20
40
  if defined JAVA_HOME goto findJavaFromJavaHome
21
41
 
22
42
  set JAVA_EXE=java.exe
23
43
  %JAVA_EXE% -version >NUL 2>&1
24
- if "%ERRORLEVEL%" == "0" goto init
44
+ if %ERRORLEVEL% equ 0 goto execute
25
45
 
26
46
  echo.
27
47
  echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +55,7 @@ goto fail
35
55
  set JAVA_HOME=%JAVA_HOME:"=%
36
56
  set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
57
 
38
- if exist "%JAVA_EXE%" goto init
58
+ if exist "%JAVA_EXE%" goto execute
39
59
 
40
60
  echo.
41
61
  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,44 +65,26 @@ echo location of your Java installation.
45
65
 
46
66
  goto fail
47
67
 
48
- :init
49
- @rem Get command-line arguments, handling Windowz variants
50
-
51
- if not "%OS%" == "Windows_NT" goto win9xME_args
52
- if "%@eval[2+2]" == "4" goto 4NT_args
53
-
54
- :win9xME_args
55
- @rem Slurp the command line arguments.
56
- set CMD_LINE_ARGS=
57
- set _SKIP=2
58
-
59
- :win9xME_args_slurp
60
- if "x%~1" == "x" goto execute
61
-
62
- set CMD_LINE_ARGS=%*
63
- goto execute
64
-
65
- :4NT_args
66
- @rem Get arguments from the 4NT Shell from JP Software
67
- set CMD_LINE_ARGS=%$
68
-
69
68
  :execute
70
69
  @rem Setup the command line
71
70
 
72
71
  set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
72
 
73
+
74
74
  @rem Execute Gradle
75
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
75
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76
76
 
77
77
  :end
78
78
  @rem End local scope for the variables with windows NT shell
79
- if "%ERRORLEVEL%"=="0" goto mainEnd
79
+ if %ERRORLEVEL% equ 0 goto mainEnd
80
80
 
81
81
  :fail
82
82
  rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
83
  rem the _cmd.exe /c_ return code!
84
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
- exit /b 1
84
+ set EXIT_CODE=%ERRORLEVEL%
85
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
86
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87
+ exit /b %EXIT_CODE%
86
88
 
87
89
  :mainEnd
88
90
  if "%OS%"=="Windows_NT" endlocal
@@ -1,5 +1,5 @@
1
1
 
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.ahm.capacitor.camera.preview.capacitorcamerapreview">
3
+ >
4
4
  </manifest>
5
5
 
@@ -4,6 +4,7 @@ import android.app.Activity;
4
4
  import android.app.Fragment;
5
5
  import android.content.Context;
6
6
  import android.content.pm.PackageManager;
7
+ import android.content.res.Configuration;
7
8
  import android.graphics.Bitmap;
8
9
  import android.graphics.Bitmap.CompressFormat;
9
10
  import android.graphics.BitmapFactory;
@@ -390,6 +391,40 @@ public class CameraActivity extends Fragment {
390
391
  }
391
392
  }
392
393
 
394
+ @Override
395
+ public void onConfigurationChanged(Configuration newConfig) {
396
+ super.onConfigurationChanged(newConfig);
397
+
398
+ final FrameLayout frameContainerLayout = (FrameLayout) view.findViewById(
399
+ getResources().getIdentifier("frame_container", "id", appResourcesPackage)
400
+ );
401
+
402
+ final int previousOrientation = frameContainerLayout.getHeight() > frameContainerLayout.getWidth() ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
403
+ // Checks if the orientation of the screen has changed
404
+ if (newConfig.orientation != previousOrientation) {
405
+
406
+ final RelativeLayout frameCamContainerLayout = (RelativeLayout) view.findViewById(
407
+ getResources().getIdentifier("frame_camera_cont", "id", appResourcesPackage)
408
+ );
409
+
410
+ frameContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
411
+ frameContainerLayout.getLayoutParams().height = frameCamContainerLayout.getWidth();
412
+
413
+ frameCamContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
414
+ frameCamContainerLayout.getLayoutParams().height = frameCamContainerLayout.getWidth();
415
+
416
+ frameContainerLayout.invalidate();
417
+ frameContainerLayout.requestLayout();
418
+
419
+ frameCamContainerLayout.forceLayout();
420
+
421
+ mPreview.setCameraDisplayOrientation();
422
+
423
+ }
424
+
425
+ }
426
+
427
+
393
428
  public Camera getCamera() {
394
429
  return mCamera;
395
430
  }
@@ -102,7 +102,7 @@ class Preview extends RelativeLayout implements SurfaceHolder.Callback, TextureV
102
102
  }
103
103
  }
104
104
 
105
- private void setCameraDisplayOrientation() {
105
+ public void setCameraDisplayOrientation() {
106
106
  Camera.CameraInfo info = new Camera.CameraInfo();
107
107
  int rotation = ((Activity) getContext()).getWindowManager().getDefaultDisplay().getRotation();
108
108
  int degrees = 0;
@@ -1,4 +1,4 @@
1
- export declare type CameraPosition = 'rear' | 'front';
1
+ export type CameraPosition = 'rear' | 'front';
2
2
  export interface CameraPreviewOptions {
3
3
  /** Parent element to attach the video preview element to (applicable to the web platform only) */
4
4
  parent?: string;
@@ -49,7 +49,7 @@ export interface CameraSampleOptions {
49
49
  /** The picture quality, 0 - 100, default 85 */
50
50
  quality?: number;
51
51
  }
52
- export declare type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'red-eye' | 'torch';
52
+ export type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'red-eye' | 'torch';
53
53
  export interface CameraOpacityOptions {
54
54
  /** The percent opacity to set for camera view, default 1 */
55
55
  opacity?: number;
@@ -205,6 +205,7 @@ extension CameraController {
205
205
 
206
206
  previewLayer?.connection?.videoOrientation = videoOrientation
207
207
  dataOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
208
+ photoOutput?.connections.forEach { $0.videoOrientation = videoOrientation }
208
209
  }
209
210
 
210
211
  func switchCameras() throws {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/camera-preview",
3
- "version": "4.0.0-0",
3
+ "version": "5.0.0-0",
4
4
  "description": "Camera preview",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -19,23 +19,23 @@
19
19
  "author": "Ariel Hernandez Musa",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@capacitor/core": "^4.0.0"
22
+ "@capacitor/core": "^5.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@capacitor/android": "^4.0.0",
26
- "@capacitor/ios": "^4.0.0",
25
+ "@capacitor/android": "^5.0.0",
26
+ "@capacitor/ios": "^5.0.0",
27
27
  "@ionic/eslint-config": "^0.3.0",
28
28
  "@ionic/prettier-config": "^2.0.0",
29
29
  "@ionic/swiftlint-config": "^1.1.2",
30
30
  "concurrently": "^7.0.0",
31
31
  "eslint": "^7.32.0",
32
32
  "husky": "^7.0.4",
33
- "prettier": "^2.3.0",
34
- "prettier-plugin-java": "^1.0.2",
33
+ "prettier": "^2.5.1",
34
+ "prettier-plugin-java": "^1.6.1",
35
35
  "pretty-quick": "^3.1.3",
36
36
  "rimraf": "^3.0.2",
37
37
  "swiftlint": "^1.0.1",
38
- "typescript": "^4.1.5"
38
+ "typescript": "^4.3.2"
39
39
  },
40
40
  "husky": {
41
41
  "hooks": {