@capgo/camera-preview 7.4.0-beta.1 → 7.4.0-beta.11

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 (35) hide show
  1. package/README.md +195 -31
  2. package/android/.gradle/8.14.2/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.14.2/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/8.14.2/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
  8. package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
  10. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  11. package/android/.gradle/file-system.probe +0 -0
  12. package/android/build.gradle +3 -1
  13. package/android/src/main/AndroidManifest.xml +5 -3
  14. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +473 -88
  15. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +2065 -704
  16. package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +95 -0
  17. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +55 -46
  18. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +61 -52
  19. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +152 -59
  20. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +29 -23
  21. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +24 -23
  22. package/dist/docs.json +235 -6
  23. package/dist/esm/definitions.d.ts +119 -3
  24. package/dist/esm/definitions.js.map +1 -1
  25. package/dist/esm/web.d.ts +47 -3
  26. package/dist/esm/web.js +297 -96
  27. package/dist/esm/web.js.map +1 -1
  28. package/dist/plugin.cjs.js +293 -96
  29. package/dist/plugin.cjs.js.map +1 -1
  30. package/dist/plugin.js +293 -96
  31. package/dist/plugin.js.map +1 -1
  32. package/ios/Sources/CapgoCameraPreview/CameraController.swift +364 -218
  33. package/ios/Sources/CapgoCameraPreview/GridOverlayView.swift +65 -0
  34. package/ios/Sources/CapgoCameraPreview/Plugin.swift +886 -242
  35. package/package.json +1 -1
@@ -0,0 +1,95 @@
1
+ package com.ahm.capacitor.camera.preview;
2
+
3
+ import android.content.Context;
4
+ import android.graphics.Canvas;
5
+ import android.graphics.Paint;
6
+ import android.util.AttributeSet;
7
+ import android.view.View;
8
+
9
+ public class GridOverlayView extends View {
10
+
11
+ private Paint gridPaint;
12
+ private String gridMode = "none";
13
+
14
+ public GridOverlayView(Context context) {
15
+ super(context);
16
+ init();
17
+ }
18
+
19
+ public GridOverlayView(Context context, AttributeSet attrs) {
20
+ super(context, attrs);
21
+ init();
22
+ }
23
+
24
+ public GridOverlayView(
25
+ Context context,
26
+ AttributeSet attrs,
27
+ int defStyleAttr
28
+ ) {
29
+ super(context, attrs, defStyleAttr);
30
+ init();
31
+ }
32
+
33
+ private void init() {
34
+ gridPaint = new Paint();
35
+ gridPaint.setColor(0x80FFFFFF); // Semi-transparent white
36
+ gridPaint.setStrokeWidth(2f);
37
+ gridPaint.setStyle(Paint.Style.STROKE);
38
+ gridPaint.setAntiAlias(true);
39
+ }
40
+
41
+ public void setGridMode(String mode) {
42
+ String previousMode = this.gridMode;
43
+ this.gridMode = mode != null ? mode : "none";
44
+ setVisibility("none".equals(this.gridMode) ? View.GONE : View.VISIBLE);
45
+ android.util.Log.d(
46
+ "GridOverlayView",
47
+ "setGridMode: Changed from '" +
48
+ previousMode +
49
+ "' to '" +
50
+ this.gridMode +
51
+ "', visibility: " +
52
+ ("none".equals(this.gridMode) ? "GONE" : "VISIBLE")
53
+ );
54
+ invalidate();
55
+ }
56
+
57
+ @Override
58
+ protected void onDraw(Canvas canvas) {
59
+ super.onDraw(canvas);
60
+
61
+ if ("none".equals(gridMode)) {
62
+ return;
63
+ }
64
+
65
+ int width = getWidth();
66
+ int height = getHeight();
67
+
68
+ if (width <= 0 || height <= 0) {
69
+ return;
70
+ }
71
+
72
+ if ("3x3".equals(gridMode)) {
73
+ drawGrid(canvas, width, height, 3);
74
+ } else if ("4x4".equals(gridMode)) {
75
+ drawGrid(canvas, width, height, 4);
76
+ }
77
+ }
78
+
79
+ private void drawGrid(Canvas canvas, int width, int height, int divisions) {
80
+ float stepX = (float) width / divisions;
81
+ float stepY = (float) height / divisions;
82
+
83
+ // Draw vertical lines
84
+ for (int i = 1; i < divisions; i++) {
85
+ float x = i * stepX;
86
+ canvas.drawLine(x, 0, x, height, gridPaint);
87
+ }
88
+
89
+ // Draw horizontal lines
90
+ for (int i = 1; i < divisions; i++) {
91
+ float y = i * stepY;
92
+ canvas.drawLine(0, y, width, y, gridPaint);
93
+ }
94
+ }
95
+ }
@@ -6,49 +6,58 @@ import java.util.List;
6
6
  * Represents a camera device available on the Android device.
7
7
  */
8
8
  public class CameraDevice {
9
- private final String deviceId;
10
- private final String label;
11
- private final String position;
12
- private final List<LensInfo> lenses;
13
- private final float minZoom;
14
- private final float maxZoom;
15
- private final boolean isLogical;
16
-
17
- public CameraDevice(String deviceId, String label, String position, List<LensInfo> lenses, float minZoom, float maxZoom, boolean isLogical) {
18
- this.deviceId = deviceId;
19
- this.label = label;
20
- this.position = position;
21
- this.lenses = lenses;
22
- this.minZoom = minZoom;
23
- this.maxZoom = maxZoom;
24
- this.isLogical = isLogical;
25
- }
26
-
27
- public String getDeviceId() {
28
- return deviceId;
29
- }
30
-
31
- public String getLabel() {
32
- return label;
33
- }
34
-
35
- public String getPosition() {
36
- return position;
37
- }
38
-
39
- public List<LensInfo> getLenses() {
40
- return lenses;
41
- }
42
-
43
- public float getMinZoom() {
44
- return minZoom;
45
- }
46
-
47
- public float getMaxZoom() {
48
- return maxZoom;
49
- }
50
-
51
- public boolean isLogical() {
52
- return isLogical;
53
- }
54
- }
9
+
10
+ private final String deviceId;
11
+ private final String label;
12
+ private final String position;
13
+ private final List<LensInfo> lenses;
14
+ private final float minZoom;
15
+ private final float maxZoom;
16
+ private final boolean isLogical;
17
+
18
+ public CameraDevice(
19
+ String deviceId,
20
+ String label,
21
+ String position,
22
+ List<LensInfo> lenses,
23
+ float minZoom,
24
+ float maxZoom,
25
+ boolean isLogical
26
+ ) {
27
+ this.deviceId = deviceId;
28
+ this.label = label;
29
+ this.position = position;
30
+ this.lenses = lenses;
31
+ this.minZoom = minZoom;
32
+ this.maxZoom = maxZoom;
33
+ this.isLogical = isLogical;
34
+ }
35
+
36
+ public String getDeviceId() {
37
+ return deviceId;
38
+ }
39
+
40
+ public String getLabel() {
41
+ return label;
42
+ }
43
+
44
+ public String getPosition() {
45
+ return position;
46
+ }
47
+
48
+ public List<LensInfo> getLenses() {
49
+ return lenses;
50
+ }
51
+
52
+ public float getMinZoom() {
53
+ return minZoom;
54
+ }
55
+
56
+ public float getMaxZoom() {
57
+ return maxZoom;
58
+ }
59
+
60
+ public boolean isLogical() {
61
+ return isLogical;
62
+ }
63
+ }
@@ -4,67 +4,76 @@ package com.ahm.capacitor.camera.preview.model;
4
4
  * Represents a camera lens available on the Android device.
5
5
  */
6
6
  public class CameraLens {
7
- private final String id;
8
- private final String label;
9
- private final String position;
10
- private final String deviceType;
11
- private final float focalLength;
12
- private final float minZoom;
13
- private final float maxZoom;
14
- private final float baseZoomRatio;
15
- public boolean isActive;
16
7
 
17
- public CameraLens(String id, String label, String position, String deviceType,
18
- float focalLength, float minZoom, float maxZoom,
19
- float baseZoomRatio, boolean isActive) {
20
- this.id = id;
21
- this.label = label;
22
- this.position = position;
23
- this.deviceType = deviceType;
24
- this.focalLength = Math.round(focalLength * 100.0f) / 100.0f;
25
- this.minZoom = minZoom;
26
- this.maxZoom = maxZoom;
27
- this.baseZoomRatio = Math.round(baseZoomRatio);
28
- this.isActive = isActive;
29
- }
8
+ private final String id;
9
+ private final String label;
10
+ private final String position;
11
+ private final String deviceType;
12
+ private final float focalLength;
13
+ private final float minZoom;
14
+ private final float maxZoom;
15
+ private final float baseZoomRatio;
16
+ public boolean isActive;
30
17
 
31
- public String getId() {
32
- return id;
33
- }
18
+ public CameraLens(
19
+ String id,
20
+ String label,
21
+ String position,
22
+ String deviceType,
23
+ float focalLength,
24
+ float minZoom,
25
+ float maxZoom,
26
+ float baseZoomRatio,
27
+ boolean isActive
28
+ ) {
29
+ this.id = id;
30
+ this.label = label;
31
+ this.position = position;
32
+ this.deviceType = deviceType;
33
+ this.focalLength = Math.round(focalLength * 100.0f) / 100.0f;
34
+ this.minZoom = minZoom;
35
+ this.maxZoom = maxZoom;
36
+ this.baseZoomRatio = Math.round(baseZoomRatio);
37
+ this.isActive = isActive;
38
+ }
34
39
 
35
- public String getLabel() {
36
- return label;
37
- }
40
+ public String getId() {
41
+ return id;
42
+ }
38
43
 
39
- public String getPosition() {
40
- return position;
41
- }
44
+ public String getLabel() {
45
+ return label;
46
+ }
42
47
 
43
- public String getDeviceType() {
44
- return deviceType;
45
- }
48
+ public String getPosition() {
49
+ return position;
50
+ }
46
51
 
47
- public float getFocalLength() {
48
- return focalLength;
49
- }
52
+ public String getDeviceType() {
53
+ return deviceType;
54
+ }
50
55
 
51
- public float getMinZoom() {
52
- return minZoom;
53
- }
56
+ public float getFocalLength() {
57
+ return focalLength;
58
+ }
54
59
 
55
- public float getMaxZoom() {
56
- return maxZoom;
57
- }
60
+ public float getMinZoom() {
61
+ return minZoom;
62
+ }
58
63
 
59
- public float getBaseZoomRatio() {
60
- return baseZoomRatio;
61
- }
64
+ public float getMaxZoom() {
65
+ return maxZoom;
66
+ }
62
67
 
63
- public boolean isActive() {
64
- return isActive;
65
- }
68
+ public float getBaseZoomRatio() {
69
+ return baseZoomRatio;
70
+ }
66
71
 
67
- public void setIsActive(boolean isActive) {
68
- this.isActive = isActive;
69
- }
72
+ public boolean isActive() {
73
+ return isActive;
74
+ }
75
+
76
+ public void setIsActive(boolean isActive) {
77
+ this.isActive = isActive;
78
+ }
70
79
  }
@@ -4,62 +4,155 @@ package com.ahm.capacitor.camera.preview.model;
4
4
  * Configuration for a camera session.
5
5
  */
6
6
  public class CameraSessionConfiguration {
7
- private final String deviceId;
8
- private final String position;
9
- private final int x;
10
- private final int y;
11
- private final int width;
12
- private final int height;
13
- private final int paddingBottom;
14
- private final boolean toBack;
15
- private final boolean storeToFile;
16
- private final boolean enableOpacity;
17
- private final boolean enableZoom;
18
- private final boolean disableExifHeaderStripping;
19
- private final boolean disableAudio;
20
- private final float zoomFactor;
21
- private float targetZoom = 1.0f;
22
-
23
- public CameraSessionConfiguration(String deviceId, String position, int x, int y, int width, int height,
24
- int paddingBottom, boolean toBack, boolean storeToFile, boolean enableOpacity,
25
- boolean enableZoom, boolean disableExifHeaderStripping, boolean disableAudio,
26
- float zoomFactor) {
27
- this.deviceId = deviceId;
28
- this.position = position;
29
- this.x = x;
30
- this.y = y;
31
- this.width = width;
32
- this.height = height;
33
- this.paddingBottom = paddingBottom;
34
- this.toBack = toBack;
35
- this.storeToFile = storeToFile;
36
- this.enableOpacity = enableOpacity;
37
- this.enableZoom = enableZoom;
38
- this.disableExifHeaderStripping = disableExifHeaderStripping;
39
- this.disableAudio = disableAudio;
40
- this.zoomFactor = zoomFactor;
41
- }
42
-
43
- public void setTargetZoom(float zoom) {
44
- this.targetZoom = zoom;
45
- }
46
-
47
- public float getTargetZoom() {
48
- return this.targetZoom;
49
- }
50
-
51
- public String getDeviceId() { return deviceId; }
52
- public String getPosition() { return position; }
53
- public int getX() { return x; }
54
- public int getY() { return y; }
55
- public int getWidth() { return width; }
56
- public int getHeight() { return height; }
57
- public int getPaddingBottom() { return paddingBottom; }
58
- public boolean isToBack() { return toBack; }
59
- public boolean isStoreToFile() { return storeToFile; }
60
- public boolean isEnableOpacity() { return enableOpacity; }
61
- public boolean isEnableZoom() { return enableZoom; }
62
- public boolean isDisableExifHeaderStripping() { return disableExifHeaderStripping; }
63
- public boolean isDisableAudio() { return disableAudio; }
64
- public float getZoomFactor() { return zoomFactor; }
65
- }
7
+
8
+ private final String deviceId;
9
+ private final String position;
10
+ private final int x;
11
+ private final int y;
12
+ private final int width;
13
+ private final int height;
14
+ private final int paddingBottom;
15
+ private final boolean toBack;
16
+ private final boolean storeToFile;
17
+ private final boolean enableOpacity;
18
+ private final boolean enableZoom;
19
+ private final boolean disableExifHeaderStripping;
20
+ private final boolean disableAudio;
21
+ private final float zoomFactor;
22
+ private final String aspectRatio;
23
+ private final String gridMode;
24
+ private float targetZoom = 1.0f;
25
+
26
+ public CameraSessionConfiguration(
27
+ String deviceId,
28
+ String position,
29
+ int x,
30
+ int y,
31
+ int width,
32
+ int height,
33
+ int paddingBottom,
34
+ boolean toBack,
35
+ boolean storeToFile,
36
+ boolean enableOpacity,
37
+ boolean enableZoom,
38
+ boolean disableExifHeaderStripping,
39
+ boolean disableAudio,
40
+ float zoomFactor,
41
+ String aspectRatio,
42
+ String gridMode
43
+ ) {
44
+ this.deviceId = deviceId;
45
+ this.position = position;
46
+ this.x = x;
47
+ this.y = y;
48
+ this.width = width;
49
+ this.height = height;
50
+ this.paddingBottom = paddingBottom;
51
+ this.toBack = toBack;
52
+ this.storeToFile = storeToFile;
53
+ this.enableOpacity = enableOpacity;
54
+ this.enableZoom = enableZoom;
55
+ this.disableExifHeaderStripping = disableExifHeaderStripping;
56
+ this.disableAudio = disableAudio;
57
+ this.zoomFactor = zoomFactor;
58
+ this.aspectRatio = aspectRatio;
59
+ this.gridMode = gridMode != null ? gridMode : "none";
60
+ }
61
+
62
+ public void setTargetZoom(float zoom) {
63
+ this.targetZoom = zoom;
64
+ }
65
+
66
+ public float getTargetZoom() {
67
+ return this.targetZoom;
68
+ }
69
+
70
+ public String getDeviceId() {
71
+ return deviceId;
72
+ }
73
+
74
+ public String getPosition() {
75
+ return position;
76
+ }
77
+
78
+ public int getX() {
79
+ return x;
80
+ }
81
+
82
+ public int getY() {
83
+ return y;
84
+ }
85
+
86
+ public int getWidth() {
87
+ return width;
88
+ }
89
+
90
+ public int getHeight() {
91
+ return height;
92
+ }
93
+
94
+ public int getPaddingBottom() {
95
+ return paddingBottom;
96
+ }
97
+
98
+ public boolean isToBack() {
99
+ return toBack;
100
+ }
101
+
102
+ public boolean isStoreToFile() {
103
+ return storeToFile;
104
+ }
105
+
106
+ public boolean isEnableOpacity() {
107
+ return enableOpacity;
108
+ }
109
+
110
+ public boolean isEnableZoom() {
111
+ return enableZoom;
112
+ }
113
+
114
+ public boolean isDisableExifHeaderStripping() {
115
+ return disableExifHeaderStripping;
116
+ }
117
+
118
+ public boolean isDisableAudio() {
119
+ return disableAudio;
120
+ }
121
+
122
+ public float getZoomFactor() {
123
+ return zoomFactor;
124
+ }
125
+
126
+ public String getAspectRatio() {
127
+ return aspectRatio;
128
+ }
129
+
130
+ public String getGridMode() {
131
+ return gridMode;
132
+ }
133
+
134
+ // Additional getters with "get" prefix for compatibility
135
+ public boolean getToBack() {
136
+ return toBack;
137
+ }
138
+
139
+ public boolean getStoreToFile() {
140
+ return storeToFile;
141
+ }
142
+
143
+ public boolean getEnableOpacity() {
144
+ return enableOpacity;
145
+ }
146
+
147
+ public boolean getEnableZoom() {
148
+ return enableZoom;
149
+ }
150
+
151
+ public boolean getDisableExifHeaderStripping() {
152
+ return disableExifHeaderStripping;
153
+ }
154
+
155
+ public boolean getDisableAudio() {
156
+ return disableAudio;
157
+ }
158
+ }
@@ -4,31 +4,37 @@ package com.ahm.capacitor.camera.preview.model;
4
4
  * Represents lens information for a camera device.
5
5
  */
6
6
  public class LensInfo {
7
- private final float focalLength;
8
- private final String deviceType;
9
- private final float baseZoomRatio;
10
- private final float digitalZoom;
11
7
 
12
- public LensInfo(float focalLength, String deviceType, float baseZoomRatio, float digitalZoom) {
13
- this.focalLength = Math.round(focalLength * 100.0f) / 100.0f;
14
- this.deviceType = deviceType;
15
- this.baseZoomRatio = baseZoomRatio;
16
- this.digitalZoom = digitalZoom;
17
- }
8
+ private final float focalLength;
9
+ private final String deviceType;
10
+ private final float baseZoomRatio;
11
+ private final float digitalZoom;
18
12
 
19
- public float getFocalLength() {
20
- return focalLength;
21
- }
13
+ public LensInfo(
14
+ float focalLength,
15
+ String deviceType,
16
+ float baseZoomRatio,
17
+ float digitalZoom
18
+ ) {
19
+ this.focalLength = Math.round(focalLength * 100.0f) / 100.0f;
20
+ this.deviceType = deviceType;
21
+ this.baseZoomRatio = baseZoomRatio;
22
+ this.digitalZoom = digitalZoom;
23
+ }
22
24
 
23
- public String getDeviceType() {
24
- return deviceType;
25
- }
25
+ public float getFocalLength() {
26
+ return focalLength;
27
+ }
26
28
 
27
- public float getBaseZoomRatio() {
28
- return baseZoomRatio;
29
- }
29
+ public String getDeviceType() {
30
+ return deviceType;
31
+ }
30
32
 
31
- public float getDigitalZoom() {
32
- return digitalZoom;
33
- }
34
- }
33
+ public float getBaseZoomRatio() {
34
+ return baseZoomRatio;
35
+ }
36
+
37
+ public float getDigitalZoom() {
38
+ return digitalZoom;
39
+ }
40
+ }
@@ -4,31 +4,32 @@ package com.ahm.capacitor.camera.preview.model;
4
4
  * Represents zoom factor information for a camera with current lens details.
5
5
  */
6
6
  public class ZoomFactors {
7
- private final float min;
8
- private final float max;
9
- private final float current;
10
- private final LensInfo lens;
11
7
 
12
- public ZoomFactors(float min, float max, float current, LensInfo lens) {
13
- this.min = min;
14
- this.max = max;
15
- this.current = current;
16
- this.lens = lens;
17
- }
8
+ private final float min;
9
+ private final float max;
10
+ private final float current;
11
+ private final LensInfo lens;
18
12
 
19
- public float getMin() {
20
- return min;
21
- }
13
+ public ZoomFactors(float min, float max, float current, LensInfo lens) {
14
+ this.min = min;
15
+ this.max = max;
16
+ this.current = current;
17
+ this.lens = lens;
18
+ }
22
19
 
23
- public float getMax() {
24
- return max;
25
- }
20
+ public float getMin() {
21
+ return min;
22
+ }
26
23
 
27
- public float getCurrent() {
28
- return current;
29
- }
24
+ public float getMax() {
25
+ return max;
26
+ }
30
27
 
31
- public LensInfo getLens() {
32
- return lens;
33
- }
34
- }
28
+ public float getCurrent() {
29
+ return current;
30
+ }
31
+
32
+ public LensInfo getLens() {
33
+ return lens;
34
+ }
35
+ }