scandit-capacitor-datacapture-barcode 8.2.0-beta.1 → 8.2.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.
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
17
17
 
18
18
  s.dependency "Capacitor"
19
19
  s.dependency "ScanditCapacitorDatacaptureCore", "= #{version}"
20
- s.dependency "scandit-datacapture-frameworks-barcode", '= 8.2.0-beta.1'
20
+ s.dependency "scandit-datacapture-frameworks-barcode", '= 8.2.0'
21
21
  end
@@ -143,7 +143,7 @@ if (ext.has('repos')) {
143
143
  }
144
144
 
145
145
  dependencies {
146
- def sdk_version = "8.2.0-beta.1"
146
+ def sdk_version = "8.2.0"
147
147
 
148
148
  implementation fileTree(dir: 'libs', include: ['*.jar'])
149
149
  implementation fileTree(dir: 'library', include: ['*.aar'])
@@ -326,6 +326,47 @@ public class ScanditBarcodeNative extends Plugin implements Emitter {
326
326
  call.resolve();
327
327
  }
328
328
 
329
+ @PluginMethod
330
+ public void setFindViewPositionAndSize(PluginCall call) {
331
+ Double top = call.getDouble("top");
332
+ if (top == null) {
333
+ call.reject("Missing top position");
334
+ return;
335
+ }
336
+
337
+ Double left = call.getDouble("left");
338
+ if (left == null) {
339
+ call.reject("Missing left position");
340
+ return;
341
+ }
342
+
343
+ Double width = call.getDouble("width");
344
+ if (width == null) {
345
+ call.reject("Missing width");
346
+ return;
347
+ }
348
+
349
+ Double height = call.getDouble("height");
350
+ if (height == null) {
351
+ call.reject("Missing height");
352
+ return;
353
+ }
354
+
355
+ Boolean shouldBeUnderWebView = call.getBoolean("shouldBeUnderWebView");
356
+ if (shouldBeUnderWebView == null) {
357
+ shouldBeUnderWebView = false;
358
+ }
359
+
360
+ barcodeFindViewHandler.setResizeAndMoveInfo(
361
+ new ResizeAndMoveInfo(
362
+ top.floatValue(),
363
+ left.floatValue(),
364
+ width.floatValue(),
365
+ height.floatValue(),
366
+ shouldBeUnderWebView));
367
+ call.resolve();
368
+ }
369
+
329
370
  // endregion
330
371
 
331
372
  // region BarcodePick
@@ -122,8 +122,8 @@ public class BarcodeCountViewHandler {
122
122
  barcodeCountView.setX(pxFromDp(latestInfo.getLeft()));
123
123
  barcodeCountView.setY(pxFromDp(latestInfo.getTop()));
124
124
  ViewGroup.LayoutParams params = barcodeCountView.getLayoutParams();
125
- params.width = ViewGroup.LayoutParams.MATCH_PARENT;
126
- params.height = ViewGroup.LayoutParams.MATCH_PARENT;
125
+ params.width = (int) pxFromDp(latestInfo.getWidth());
126
+ params.height = (int) pxFromDp(latestInfo.getHeight());
127
127
 
128
128
  View webView = getWebView();
129
129
  if (latestInfo.getShouldBeUnderWebView()) {
@@ -14,6 +14,7 @@ import android.view.View;
14
14
  import android.view.ViewGroup;
15
15
  import android.widget.FrameLayout;
16
16
  import androidx.appcompat.app.AppCompatActivity;
17
+ import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo;
17
18
  import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread;
18
19
  import com.scandit.datacapture.frameworks.core.utils.MainThread;
19
20
  import java.lang.ref.WeakReference;
@@ -26,6 +27,7 @@ public class BarcodeFindViewHandler {
26
27
  private final Map<Integer, WeakReference<FrameLayout>> containers;
27
28
  private final Map<Integer, Boolean> containerVisibility;
28
29
  private WeakReference<View> webViewReference;
30
+ private ResizeAndMoveInfo latestInfo;
29
31
 
30
32
  public BarcodeFindViewHandler() {
31
33
  this(DefaultMainThread.getInstance());
@@ -36,6 +38,28 @@ public class BarcodeFindViewHandler {
36
38
  this.containers = new ConcurrentHashMap<>();
37
39
  this.containerVisibility = new ConcurrentHashMap<>();
38
40
  this.webViewReference = null;
41
+ this.latestInfo = new ResizeAndMoveInfo(0f, 0f, 600f, 600f, false);
42
+ }
43
+
44
+ public void setResizeAndMoveInfo(ResizeAndMoveInfo info) {
45
+ latestInfo = info;
46
+ render();
47
+ }
48
+
49
+ private void render() {
50
+ for (WeakReference<FrameLayout> containerRef : containers.values()) {
51
+ FrameLayout container = containerRef.get();
52
+ if (container != null) {
53
+ Boolean visibility = true;
54
+ for (Map.Entry<Integer, WeakReference<FrameLayout>> entry : containers.entrySet()) {
55
+ if (entry.getValue().get() == container) {
56
+ visibility = containerVisibility.get(entry.getKey());
57
+ break;
58
+ }
59
+ }
60
+ renderNoAnimate(container, visibility != null && visibility);
61
+ }
62
+ }
39
63
  }
40
64
 
41
65
  private View getWebView() {
@@ -111,18 +135,33 @@ public class BarcodeFindViewHandler {
111
135
  }
112
136
 
113
137
  private void renderNoAnimate(FrameLayout container, boolean isVisible) {
114
- container.setVisibility(isVisible ? View.VISIBLE : View.GONE);
115
- ViewGroup.LayoutParams params = container.getLayoutParams();
116
- params.width = ViewGroup.LayoutParams.MATCH_PARENT;
117
- params.height = ViewGroup.LayoutParams.MATCH_PARENT;
118
-
119
- if (isVisible) {
120
- container.bringToFront();
121
- setWebViewInvisible();
122
- } else {
123
- setWebViewVisible();
124
- }
125
- container.requestLayout();
138
+ container.post(
139
+ () -> {
140
+ container.setVisibility(isVisible ? View.VISIBLE : View.GONE);
141
+ container.setX(pxFromDp(latestInfo.getLeft()));
142
+ container.setY(pxFromDp(latestInfo.getTop()));
143
+ ViewGroup.LayoutParams params = container.getLayoutParams();
144
+ params.width = (int) pxFromDp(latestInfo.getWidth());
145
+ params.height = (int) pxFromDp(latestInfo.getHeight());
146
+
147
+ View webView = getWebView();
148
+ if (latestInfo.getShouldBeUnderWebView()) {
149
+ if (webView != null) {
150
+ webView.bringToFront();
151
+ ((View) webView.getParent()).setTranslationZ(1F);
152
+ }
153
+ } else {
154
+ if (isVisible) {
155
+ container.bringToFront();
156
+ if (webView != null) {
157
+ ((View) webView.getParent()).setTranslationZ(-1F);
158
+ }
159
+ } else {
160
+ setWebViewVisible();
161
+ }
162
+ }
163
+ container.requestLayout();
164
+ });
126
165
  }
127
166
 
128
167
  private void setWebViewVisible() {
@@ -131,8 +131,8 @@ public class BarcodePickViewHandler {
131
131
  barcodePickViewContainer.setX(pxFromDp(latestInfo.getLeft()));
132
132
  barcodePickViewContainer.setY(pxFromDp(latestInfo.getTop()));
133
133
  ViewGroup.LayoutParams params = barcodePickViewContainer.getLayoutParams();
134
- params.width = ViewGroup.LayoutParams.MATCH_PARENT;
135
- params.height = ViewGroup.LayoutParams.MATCH_PARENT;
134
+ params.width = (int) pxFromDp(latestInfo.getWidth());
135
+ params.height = (int) pxFromDp(latestInfo.getHeight());
136
136
 
137
137
  View webView = getWebView();
138
138
  if (latestInfo.getShouldBeUnderWebView()) {
package/dist/barcode.js CHANGED
@@ -15371,6 +15371,9 @@ class BarcodeFindViewController extends BaseController {
15371
15371
  return Promise.resolve(); // view not created yet
15372
15372
  return this.adapter.hideFindView({ viewId: this.baseView.viewId });
15373
15373
  }
15374
+ setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
15375
+ return this._proxy.$setFindViewPositionAndSize({ top, left, width, height, shouldBeUnderWebView });
15376
+ }
15374
15377
  createNativeView() {
15375
15378
  return this.create();
15376
15379
  }
@@ -15627,6 +15630,9 @@ class BaseBarcodeFindView {
15627
15630
  hide() {
15628
15631
  return this.controller.hideView();
15629
15632
  }
15633
+ setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
15634
+ return this.controller.setPositionAndSize(top, left, width, height, shouldBeUnderWebView);
15635
+ }
15630
15636
  static get hardwareTriggerSupported() {
15631
15637
  return BaseBarcodeFindView.barcodeFindViewDefaults.hardwareTriggerSupported;
15632
15638
  }