@capgo/camera-preview 7.4.0-beta.2 → 7.4.0-beta.20

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 +212 -35
  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 +1 -4
  14. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +731 -83
  15. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +2813 -805
  16. package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +112 -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 +161 -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 +292 -29
  23. package/dist/esm/definitions.d.ts +148 -13
  24. package/dist/esm/definitions.js.map +1 -1
  25. package/dist/esm/web.d.ts +52 -3
  26. package/dist/esm/web.js +555 -97
  27. package/dist/esm/web.js.map +1 -1
  28. package/dist/plugin.cjs.js +553 -97
  29. package/dist/plugin.cjs.js.map +1 -1
  30. package/dist/plugin.js +553 -97
  31. package/dist/plugin.js.map +1 -1
  32. package/ios/Sources/CapgoCameraPreview/CameraController.swift +888 -214
  33. package/ios/Sources/CapgoCameraPreview/GridOverlayView.swift +65 -0
  34. package/ios/Sources/CapgoCameraPreview/Plugin.swift +967 -250
  35. package/package.json +2 -2
@@ -0,0 +1,112 @@
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.graphics.Rect;
7
+ import android.util.AttributeSet;
8
+ import android.view.View;
9
+
10
+ public class GridOverlayView extends View {
11
+
12
+ private Paint gridPaint;
13
+ private String gridMode = "none";
14
+ private Rect cameraBounds = null;
15
+
16
+ public GridOverlayView(Context context) {
17
+ super(context);
18
+ init();
19
+ }
20
+
21
+ public GridOverlayView(Context context, AttributeSet attrs) {
22
+ super(context, attrs);
23
+ init();
24
+ }
25
+
26
+ public GridOverlayView(
27
+ Context context,
28
+ AttributeSet attrs,
29
+ int defStyleAttr
30
+ ) {
31
+ super(context, attrs, defStyleAttr);
32
+ init();
33
+ }
34
+
35
+ private void init() {
36
+ gridPaint = new Paint();
37
+ gridPaint.setColor(0x80FFFFFF); // Semi-transparent white
38
+ gridPaint.setStrokeWidth(2f);
39
+ gridPaint.setStyle(Paint.Style.STROKE);
40
+ gridPaint.setAntiAlias(true);
41
+ }
42
+
43
+ public void setCameraBounds(Rect bounds) {
44
+ this.cameraBounds = bounds;
45
+ invalidate();
46
+ }
47
+
48
+ public void setGridMode(String mode) {
49
+ String previousMode = this.gridMode;
50
+ this.gridMode = mode != null ? mode : "none";
51
+ setVisibility("none".equals(this.gridMode) ? View.GONE : View.VISIBLE);
52
+ android.util.Log.d(
53
+ "GridOverlayView",
54
+ "setGridMode: Changed from '" +
55
+ previousMode +
56
+ "' to '" +
57
+ this.gridMode +
58
+ "', visibility: " +
59
+ ("none".equals(this.gridMode) ? "GONE" : "VISIBLE")
60
+ );
61
+ invalidate();
62
+ }
63
+
64
+ @Override
65
+ protected void onDraw(Canvas canvas) {
66
+ super.onDraw(canvas);
67
+
68
+ if ("none".equals(gridMode)) {
69
+ return;
70
+ }
71
+
72
+ // Use camera bounds if available, otherwise use full view bounds
73
+ int left = 0;
74
+ int top = 0;
75
+ int width = getWidth();
76
+ int height = getHeight();
77
+
78
+ if (cameraBounds != null) {
79
+ left = cameraBounds.left;
80
+ top = cameraBounds.top;
81
+ width = cameraBounds.width();
82
+ height = cameraBounds.height();
83
+ }
84
+
85
+ if (width <= 0 || height <= 0) {
86
+ return;
87
+ }
88
+
89
+ if ("3x3".equals(gridMode)) {
90
+ drawGrid(canvas, left, top, width, height, 3);
91
+ } else if ("4x4".equals(gridMode)) {
92
+ drawGrid(canvas, left, top, width, height, 4);
93
+ }
94
+ }
95
+
96
+ private void drawGrid(Canvas canvas, int left, int top, int width, int height, int divisions) {
97
+ float stepX = (float) width / divisions;
98
+ float stepY = (float) height / divisions;
99
+
100
+ // Draw vertical lines
101
+ for (int i = 1; i < divisions; i++) {
102
+ float x = left + (i * stepX);
103
+ canvas.drawLine(x, top, x, top + height, gridPaint);
104
+ }
105
+
106
+ // Draw horizontal lines
107
+ for (int i = 1; i < divisions; i++) {
108
+ float y = top + (i * stepY);
109
+ canvas.drawLine(left, y, left + width, y, gridPaint);
110
+ }
111
+ }
112
+ }
@@ -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,164 @@ 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
+ private boolean isCentered = false;
26
+
27
+ public CameraSessionConfiguration(
28
+ String deviceId,
29
+ String position,
30
+ int x,
31
+ int y,
32
+ int width,
33
+ int height,
34
+ int paddingBottom,
35
+ boolean toBack,
36
+ boolean storeToFile,
37
+ boolean enableOpacity,
38
+ boolean enableZoom,
39
+ boolean disableExifHeaderStripping,
40
+ boolean disableAudio,
41
+ float zoomFactor,
42
+ String aspectRatio,
43
+ String gridMode
44
+ ) {
45
+ this.deviceId = deviceId;
46
+ this.position = position;
47
+ this.x = x;
48
+ this.y = y;
49
+ this.width = width;
50
+ this.height = height;
51
+ this.paddingBottom = paddingBottom;
52
+ this.toBack = toBack;
53
+ this.storeToFile = storeToFile;
54
+ this.enableOpacity = enableOpacity;
55
+ this.enableZoom = enableZoom;
56
+ this.disableExifHeaderStripping = disableExifHeaderStripping;
57
+ this.disableAudio = disableAudio;
58
+ this.zoomFactor = zoomFactor;
59
+ this.aspectRatio = aspectRatio;
60
+ this.gridMode = gridMode != null ? gridMode : "none";
61
+ }
62
+
63
+ public void setTargetZoom(float zoom) {
64
+ this.targetZoom = zoom;
65
+ }
66
+
67
+ public float getTargetZoom() {
68
+ return this.targetZoom;
69
+ }
70
+
71
+ public String getDeviceId() {
72
+ return deviceId;
73
+ }
74
+
75
+ public String getPosition() {
76
+ return position;
77
+ }
78
+
79
+ public int getX() {
80
+ return x;
81
+ }
82
+
83
+ public int getY() {
84
+ return y;
85
+ }
86
+
87
+ public int getWidth() {
88
+ return width;
89
+ }
90
+
91
+ public int getHeight() {
92
+ return height;
93
+ }
94
+
95
+ public int getPaddingBottom() {
96
+ return paddingBottom;
97
+ }
98
+
99
+ public boolean isToBack() {
100
+ return toBack;
101
+ }
102
+
103
+ public boolean isStoreToFile() {
104
+ return storeToFile;
105
+ }
106
+
107
+ public boolean isEnableOpacity() {
108
+ return enableOpacity;
109
+ }
110
+
111
+ public boolean isEnableZoom() {
112
+ return enableZoom;
113
+ }
114
+
115
+ public boolean isDisableExifHeaderStripping() {
116
+ return disableExifHeaderStripping;
117
+ }
118
+
119
+ public boolean isDisableAudio() {
120
+ return disableAudio;
121
+ }
122
+
123
+ public float getZoomFactor() {
124
+ return zoomFactor;
125
+ }
126
+
127
+ public String getAspectRatio() {
128
+ return aspectRatio;
129
+ }
130
+
131
+ public String getGridMode() {
132
+ return gridMode;
133
+ }
134
+
135
+ // Additional getters with "get" prefix for compatibility
136
+ public boolean getToBack() {
137
+ return toBack;
138
+ }
139
+
140
+ public boolean getStoreToFile() {
141
+ return storeToFile;
142
+ }
143
+
144
+ public boolean getEnableOpacity() {
145
+ return enableOpacity;
146
+ }
147
+
148
+ public boolean getEnableZoom() {
149
+ return enableZoom;
150
+ }
151
+
152
+ public boolean getDisableExifHeaderStripping() {
153
+ return disableExifHeaderStripping;
154
+ }
155
+
156
+ public boolean getDisableAudio() {
157
+ return disableAudio;
158
+ }
159
+
160
+ public boolean isCentered() {
161
+ return isCentered;
162
+ }
163
+
164
+ public void setCentered(boolean centered) {
165
+ isCentered = centered;
166
+ }
167
+ }
@@ -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
+ }