@capgo/camera-preview 7.23.9 → 7.23.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.
@@ -10,111 +10,100 @@ import androidx.annotation.NonNull;
10
10
 
11
11
  public class GridOverlayView extends View {
12
12
 
13
- private Paint gridPaint;
14
- private String gridMode = "none";
15
- private Rect cameraBounds = null;
16
-
17
- public GridOverlayView(Context context) {
18
- super(context);
19
- init();
20
- }
21
-
22
- public GridOverlayView(Context context, AttributeSet attrs) {
23
- super(context, attrs);
24
- init();
25
- }
26
-
27
- public GridOverlayView(
28
- Context context,
29
- AttributeSet attrs,
30
- int defStyleAttr
31
- ) {
32
- super(context, attrs, defStyleAttr);
33
- init();
34
- }
35
-
36
- private void init() {
37
- gridPaint = new Paint();
38
- gridPaint.setColor(0x80FFFFFF); // Semi-transparent white
39
- gridPaint.setStrokeWidth(2f);
40
- gridPaint.setStyle(Paint.Style.STROKE);
41
- gridPaint.setAntiAlias(true);
42
- }
43
-
44
- public void setCameraBounds(Rect bounds) {
45
- this.cameraBounds = bounds;
46
- invalidate();
47
- }
48
-
49
- public void setGridMode(String mode) {
50
- String previousMode = this.gridMode;
51
- this.gridMode = mode != null ? mode : "none";
52
- setVisibility("none".equals(this.gridMode) ? View.GONE : View.VISIBLE);
53
- android.util.Log.d(
54
- "GridOverlayView",
55
- "setGridMode: Changed from '" +
56
- previousMode +
57
- "' to '" +
58
- this.gridMode +
59
- "', visibility: " +
60
- ("none".equals(this.gridMode) ? "GONE" : "VISIBLE")
61
- );
62
- invalidate();
63
- }
64
-
65
- @Override
66
- protected void onDraw(@NonNull Canvas canvas) {
67
- super.onDraw(canvas);
68
-
69
- if ("none".equals(gridMode)) {
70
- return;
13
+ private Paint gridPaint;
14
+ private String gridMode = "none";
15
+ private Rect cameraBounds = null;
16
+
17
+ public GridOverlayView(Context context) {
18
+ super(context);
19
+ init();
20
+ }
21
+
22
+ public GridOverlayView(Context context, AttributeSet attrs) {
23
+ super(context, attrs);
24
+ init();
71
25
  }
72
26
 
73
- // Use camera bounds if available, otherwise use full view bounds
74
- int left = 0;
75
- int top = 0;
76
- int width = getWidth();
77
- int height = getHeight();
78
-
79
- if (cameraBounds != null) {
80
- left = cameraBounds.left;
81
- top = cameraBounds.top;
82
- width = cameraBounds.width();
83
- height = cameraBounds.height();
27
+ public GridOverlayView(Context context, AttributeSet attrs, int defStyleAttr) {
28
+ super(context, attrs, defStyleAttr);
29
+ init();
84
30
  }
85
31
 
86
- if (width <= 0 || height <= 0) {
87
- return;
32
+ private void init() {
33
+ gridPaint = new Paint();
34
+ gridPaint.setColor(0x80FFFFFF); // Semi-transparent white
35
+ gridPaint.setStrokeWidth(2f);
36
+ gridPaint.setStyle(Paint.Style.STROKE);
37
+ gridPaint.setAntiAlias(true);
88
38
  }
89
39
 
90
- if ("3x3".equals(gridMode)) {
91
- drawGrid(canvas, left, top, width, height, 3);
92
- } else if ("4x4".equals(gridMode)) {
93
- drawGrid(canvas, left, top, width, height, 4);
40
+ public void setCameraBounds(Rect bounds) {
41
+ this.cameraBounds = bounds;
42
+ invalidate();
94
43
  }
95
- }
96
-
97
- private void drawGrid(
98
- Canvas canvas,
99
- int left,
100
- int top,
101
- int width,
102
- int height,
103
- int divisions
104
- ) {
105
- float stepX = (float) width / divisions;
106
- float stepY = (float) height / divisions;
107
-
108
- // Draw vertical lines
109
- for (int i = 1; i < divisions; i++) {
110
- float x = left + (i * stepX);
111
- canvas.drawLine(x, top, x, top + height, gridPaint);
44
+
45
+ public void setGridMode(String mode) {
46
+ String previousMode = this.gridMode;
47
+ this.gridMode = mode != null ? mode : "none";
48
+ setVisibility("none".equals(this.gridMode) ? View.GONE : View.VISIBLE);
49
+ android.util.Log.d(
50
+ "GridOverlayView",
51
+ "setGridMode: Changed from '" +
52
+ previousMode +
53
+ "' to '" +
54
+ this.gridMode +
55
+ "', visibility: " +
56
+ ("none".equals(this.gridMode) ? "GONE" : "VISIBLE")
57
+ );
58
+ invalidate();
59
+ }
60
+
61
+ @Override
62
+ protected void onDraw(@NonNull Canvas canvas) {
63
+ super.onDraw(canvas);
64
+
65
+ if ("none".equals(gridMode)) {
66
+ return;
67
+ }
68
+
69
+ // Use camera bounds if available, otherwise use full view bounds
70
+ int left = 0;
71
+ int top = 0;
72
+ int width = getWidth();
73
+ int height = getHeight();
74
+
75
+ if (cameraBounds != null) {
76
+ left = cameraBounds.left;
77
+ top = cameraBounds.top;
78
+ width = cameraBounds.width();
79
+ height = cameraBounds.height();
80
+ }
81
+
82
+ if (width <= 0 || height <= 0) {
83
+ return;
84
+ }
85
+
86
+ if ("3x3".equals(gridMode)) {
87
+ drawGrid(canvas, left, top, width, height, 3);
88
+ } else if ("4x4".equals(gridMode)) {
89
+ drawGrid(canvas, left, top, width, height, 4);
90
+ }
112
91
  }
113
92
 
114
- // Draw horizontal lines
115
- for (int i = 1; i < divisions; i++) {
116
- float y = top + (i * stepY);
117
- canvas.drawLine(left, y, left + width, y, gridPaint);
93
+ private void drawGrid(Canvas canvas, int left, int top, int width, int height, int divisions) {
94
+ float stepX = (float) width / divisions;
95
+ float stepY = (float) height / divisions;
96
+
97
+ // Draw vertical lines
98
+ for (int i = 1; i < divisions; i++) {
99
+ float x = left + (i * stepX);
100
+ canvas.drawLine(x, top, x, top + height, gridPaint);
101
+ }
102
+
103
+ // Draw horizontal lines
104
+ for (int i = 1; i < divisions; i++) {
105
+ float y = top + (i * stepY);
106
+ canvas.drawLine(left, y, left + width, y, gridPaint);
107
+ }
118
108
  }
119
- }
120
109
  }
@@ -7,57 +7,57 @@ import java.util.List;
7
7
  */
8
8
  public class CameraDevice {
9
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
- }
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
63
  }
@@ -5,170 +5,170 @@ package app.capgo.capacitor.camera.preview.model;
5
5
  */
6
6
  public class CameraSessionConfiguration {
7
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 disableExifHeaderStripping;
19
- private final boolean disableAudio;
20
- private final float zoomFactor;
21
- private final String aspectRatio;
22
- private final String gridMode;
23
- private final boolean disableFocusIndicator;
24
- private final boolean enableVideoMode;
25
- private float targetZoom = 1.0f;
26
- private boolean isCentered = false;
27
-
28
- public CameraSessionConfiguration(
29
- String deviceId,
30
- String position,
31
- int x,
32
- int y,
33
- int width,
34
- int height,
35
- int paddingBottom,
36
- boolean toBack,
37
- boolean storeToFile,
38
- boolean enableOpacity,
39
- boolean disableExifHeaderStripping,
40
- boolean disableAudio,
41
- float zoomFactor,
42
- String aspectRatio,
43
- String gridMode,
44
- boolean disableFocusIndicator,
45
- boolean enableVideoMode
46
- ) {
47
- this.deviceId = deviceId;
48
- this.position = position;
49
- this.x = x;
50
- this.y = y;
51
- this.width = width;
52
- this.height = height;
53
- this.paddingBottom = paddingBottom;
54
- this.toBack = toBack;
55
- this.storeToFile = storeToFile;
56
- this.enableOpacity = enableOpacity;
57
- this.disableExifHeaderStripping = disableExifHeaderStripping;
58
- this.disableAudio = disableAudio;
59
- this.zoomFactor = zoomFactor;
60
- this.aspectRatio = aspectRatio;
61
- this.gridMode = gridMode != null ? gridMode : "none";
62
- this.disableFocusIndicator = disableFocusIndicator;
63
- this.enableVideoMode = enableVideoMode;
64
- }
65
-
66
- public void setTargetZoom(float zoom) {
67
- this.targetZoom = zoom;
68
- }
69
-
70
- public float getTargetZoom() {
71
- return this.targetZoom;
72
- }
73
-
74
- public String getDeviceId() {
75
- return deviceId;
76
- }
77
-
78
- public String getPosition() {
79
- return position;
80
- }
81
-
82
- public int getX() {
83
- return x;
84
- }
85
-
86
- public int getY() {
87
- return y;
88
- }
89
-
90
- public int getWidth() {
91
- return width;
92
- }
93
-
94
- public int getHeight() {
95
- return height;
96
- }
97
-
98
- public int getPaddingBottom() {
99
- return paddingBottom;
100
- }
101
-
102
- public boolean isToBack() {
103
- return toBack;
104
- }
105
-
106
- public boolean isStoreToFile() {
107
- return storeToFile;
108
- }
109
-
110
- public boolean isEnableOpacity() {
111
- return enableOpacity;
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 getDisableExifHeaderStripping() {
148
- return disableExifHeaderStripping;
149
- }
150
-
151
- public boolean getDisableAudio() {
152
- return disableAudio;
153
- }
154
-
155
- public boolean isCentered() {
156
- return isCentered;
157
- }
158
-
159
- public void setCentered(boolean centered) {
160
- isCentered = centered;
161
- }
162
-
163
- public boolean getDisableFocusIndicator() {
164
- return disableFocusIndicator;
165
- }
166
-
167
- public boolean isVideoModeEnabled() {
168
- return enableVideoMode;
169
- }
170
-
171
- public boolean getEnableVideoMode() {
172
- return enableVideoMode;
173
- }
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 disableExifHeaderStripping;
19
+ private final boolean disableAudio;
20
+ private final float zoomFactor;
21
+ private final String aspectRatio;
22
+ private final String gridMode;
23
+ private final boolean disableFocusIndicator;
24
+ private final boolean enableVideoMode;
25
+ private float targetZoom = 1.0f;
26
+ private boolean isCentered = false;
27
+
28
+ public CameraSessionConfiguration(
29
+ String deviceId,
30
+ String position,
31
+ int x,
32
+ int y,
33
+ int width,
34
+ int height,
35
+ int paddingBottom,
36
+ boolean toBack,
37
+ boolean storeToFile,
38
+ boolean enableOpacity,
39
+ boolean disableExifHeaderStripping,
40
+ boolean disableAudio,
41
+ float zoomFactor,
42
+ String aspectRatio,
43
+ String gridMode,
44
+ boolean disableFocusIndicator,
45
+ boolean enableVideoMode
46
+ ) {
47
+ this.deviceId = deviceId;
48
+ this.position = position;
49
+ this.x = x;
50
+ this.y = y;
51
+ this.width = width;
52
+ this.height = height;
53
+ this.paddingBottom = paddingBottom;
54
+ this.toBack = toBack;
55
+ this.storeToFile = storeToFile;
56
+ this.enableOpacity = enableOpacity;
57
+ this.disableExifHeaderStripping = disableExifHeaderStripping;
58
+ this.disableAudio = disableAudio;
59
+ this.zoomFactor = zoomFactor;
60
+ this.aspectRatio = aspectRatio;
61
+ this.gridMode = gridMode != null ? gridMode : "none";
62
+ this.disableFocusIndicator = disableFocusIndicator;
63
+ this.enableVideoMode = enableVideoMode;
64
+ }
65
+
66
+ public void setTargetZoom(float zoom) {
67
+ this.targetZoom = zoom;
68
+ }
69
+
70
+ public float getTargetZoom() {
71
+ return this.targetZoom;
72
+ }
73
+
74
+ public String getDeviceId() {
75
+ return deviceId;
76
+ }
77
+
78
+ public String getPosition() {
79
+ return position;
80
+ }
81
+
82
+ public int getX() {
83
+ return x;
84
+ }
85
+
86
+ public int getY() {
87
+ return y;
88
+ }
89
+
90
+ public int getWidth() {
91
+ return width;
92
+ }
93
+
94
+ public int getHeight() {
95
+ return height;
96
+ }
97
+
98
+ public int getPaddingBottom() {
99
+ return paddingBottom;
100
+ }
101
+
102
+ public boolean isToBack() {
103
+ return toBack;
104
+ }
105
+
106
+ public boolean isStoreToFile() {
107
+ return storeToFile;
108
+ }
109
+
110
+ public boolean isEnableOpacity() {
111
+ return enableOpacity;
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 getDisableExifHeaderStripping() {
148
+ return disableExifHeaderStripping;
149
+ }
150
+
151
+ public boolean getDisableAudio() {
152
+ return disableAudio;
153
+ }
154
+
155
+ public boolean isCentered() {
156
+ return isCentered;
157
+ }
158
+
159
+ public void setCentered(boolean centered) {
160
+ isCentered = centered;
161
+ }
162
+
163
+ public boolean getDisableFocusIndicator() {
164
+ return disableFocusIndicator;
165
+ }
166
+
167
+ public boolean isVideoModeEnabled() {
168
+ return enableVideoMode;
169
+ }
170
+
171
+ public boolean getEnableVideoMode() {
172
+ return enableVideoMode;
173
+ }
174
174
  }