scandit-capacitor-datacapture-label 8.1.0 → 8.2.0-beta.1

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.
@@ -18,5 +18,5 @@ Pod::Spec.new do |s|
18
18
  s.dependency "Capacitor"
19
19
  s.dependency "ScanditCapacitorDatacaptureCore", "= #{version}"
20
20
  s.dependency "ScanditCapacitorDatacaptureBarcode", "= #{version}"
21
- s.dependency "scandit-datacapture-frameworks-label", '= 8.1.0'
21
+ s.dependency "scandit-datacapture-frameworks-label", '= 8.2.0-beta.1'
22
22
  end
@@ -9,6 +9,41 @@ def safeExtGet(prop, fallback) {
9
9
  }
10
10
 
11
11
  buildscript {
12
+ def getFrameworksFile = { String rootDir ->
13
+ def currentDir = new File(rootDir)
14
+
15
+ while (currentDir != null) {
16
+ def frameworksFile = new File(currentDir, "common/frameworks.gradle")
17
+ if (frameworksFile.exists()) {
18
+ return frameworksFile.absolutePath
19
+ }
20
+ currentDir = currentDir.getParentFile()
21
+ }
22
+
23
+ return null
24
+ }
25
+
26
+
27
+ def getCapacitorMajorVersion = {
28
+ try {
29
+ def capacitorAndroidDir = new File(rootProject.projectDir, "node_modules/@capacitor/android")
30
+ if (capacitorAndroidDir.exists()) {
31
+ def packageJson = new File(capacitorAndroidDir, "package.json")
32
+ if (packageJson.exists()) {
33
+ def json = new groovy.json.JsonSlurper().parseText(packageJson.text)
34
+ def version = json.version
35
+ if (version) {
36
+ def majorVersion = version.tokenize('.')[0] as Integer
37
+ return majorVersion
38
+ }
39
+ }
40
+ }
41
+ } catch (Exception e) {
42
+ // Fallback if detection fails
43
+ }
44
+ return 7 // Default to Capacitor 7 if detection fails
45
+ }
46
+
12
47
  def retrieveCapacitorCompatibility = {
13
48
  def appModule = rootProject.findProject(":app")
14
49
  if (appModule == null) {
@@ -33,45 +68,54 @@ buildscript {
33
68
  } else {
34
69
  ext.rootTargetCompatibility = JavaVersion.VERSION_17
35
70
  }
36
-
37
- if (ext.rootTargetCompatibility == JavaVersion.VERSION_21) {
38
- ext.kotlin_version = "1.9.25"
39
- ext.agp_version = "8.7.2"
40
- }
41
71
  }
42
72
  }
43
73
 
44
74
  ext {
45
- kotlin_version = "1.9.25"
46
- agp_version = "8.5.2"
47
75
  rootSourceCompatibility = JavaVersion.VERSION_17
48
76
  rootTargetCompatibility = JavaVersion.VERSION_17
49
77
  }
50
78
 
51
- repositories {
52
- google()
53
- mavenCentral()
79
+ // Check for monorepo frameworks.gradle
80
+ def common_gradle_script = getFrameworksFile(rootProject.projectDir.path)
81
+ if (common_gradle_script != null) {
82
+ apply from: common_gradle_script
54
83
  }
55
84
 
56
- dependencies {
57
- classpath "com.android.tools.build:gradle:$agp_version"
58
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
85
+ retrieveCapacitorCompatibility()
86
+
87
+ // Set AGP version if not already defined by frameworks.gradle or root project
88
+ if (!ext.has('agpVersion') && !rootProject.ext.has('agpVersion')) {
89
+ def capacitorMajorVersion = getCapacitorMajorVersion()
90
+ ext.agpVersion = capacitorMajorVersion >= 8 ? '8.13.0' : '8.7.2'
59
91
  }
60
92
 
61
- retrieveCapacitorCompatibility()
93
+ // Use repos from frameworks.gradle if available, otherwise explicit repos
94
+ if (ext.has('repos')) {
95
+ repositories ext.repos
96
+ } else {
97
+ repositories {
98
+ google()
99
+ mavenCentral()
100
+ }
101
+ }
102
+
103
+ dependencies {
104
+ classpath "com.android.tools.build:gradle:$agpVersion"
105
+ }
62
106
  }
63
107
 
64
108
  apply plugin: 'com.android.library'
65
- apply plugin: 'kotlin-android'
66
109
 
67
110
  android {
68
111
  namespace "com.scandit.capacitor.datacapture.label"
69
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
112
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
70
113
  defaultConfig {
71
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
72
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
114
+ minSdk project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
115
+ targetSdk project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
73
116
  versionCode 1
74
117
  versionName "1.0"
118
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
75
119
  }
76
120
  buildTypes {
77
121
  release {
@@ -88,13 +132,18 @@ android {
88
132
  }
89
133
  }
90
134
 
91
- repositories {
92
- google()
93
- mavenCentral()
135
+ // Use repos from frameworks.gradle if available, otherwise explicit repos
136
+ if (ext.has('repos')) {
137
+ repositories ext.repos
138
+ } else {
139
+ repositories {
140
+ google()
141
+ mavenCentral()
142
+ }
94
143
  }
95
144
 
96
145
  dependencies {
97
- def sdk_version = "8.1.0"
146
+ def sdk_version = "8.2.0-beta.1"
98
147
 
99
148
  implementation fileTree(dir: 'libs', include: ['*.jar'])
100
149
  implementation fileTree(dir: 'library', include: ['*.aar'])
@@ -102,7 +151,6 @@ dependencies {
102
151
 
103
152
  implementation project(':scandit-capacitor-datacapture-core')
104
153
  implementation project(':scandit-capacitor-datacapture-barcode')
105
- println("Version of the native sdk used in this build: ${safeExtGet('global_sdk_version', sdk_version)}")
106
154
  if (findProject(':scandit-datacapture-frameworks-label') != null) {
107
155
  api project(":scandit-datacapture-frameworks-label")
108
156
  } else {
@@ -0,0 +1,148 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2025- Scandit AG. All rights reserved.
5
+ */
6
+ package com.scandit.capacitor.datacapture.label;
7
+
8
+ import android.Manifest;
9
+ import androidx.annotation.NonNull;
10
+ import com.getcapacitor.JSObject;
11
+ import com.getcapacitor.PermissionState;
12
+ import com.getcapacitor.Plugin;
13
+ import com.getcapacitor.PluginCall;
14
+ import com.getcapacitor.PluginHandle;
15
+ import com.getcapacitor.PluginMethod;
16
+ import com.getcapacitor.annotation.CapacitorPlugin;
17
+ import com.getcapacitor.annotation.Permission;
18
+ import com.getcapacitor.annotation.PermissionCallback;
19
+ import com.scandit.capacitor.datacapture.core.ScanditCaptureCoreNative;
20
+ import com.scandit.capacitor.datacapture.core.utils.CapacitorMethodCall;
21
+ import com.scandit.capacitor.datacapture.core.utils.CapacitorResult;
22
+ import com.scandit.datacapture.frameworks.core.CoreModule;
23
+ import com.scandit.datacapture.frameworks.core.events.Emitter;
24
+ import com.scandit.datacapture.frameworks.core.locator.DefaultServiceLocator;
25
+ import com.scandit.datacapture.frameworks.core.utils.DefaultFrameworksLog;
26
+ import com.scandit.datacapture.frameworks.core.utils.FrameworksLog;
27
+ import com.scandit.datacapture.frameworks.label.LabelCaptureModule;
28
+ import java.util.HashMap;
29
+ import java.util.Map;
30
+ import org.json.JSONException;
31
+ import org.json.JSONObject;
32
+
33
+ @CapacitorPlugin(
34
+ name = "ScanditLabelNative",
35
+ permissions = {
36
+ @Permission(
37
+ strings = {Manifest.permission.CAMERA},
38
+ alias = "camera")
39
+ })
40
+ public class ScanditLabelNative extends Plugin implements Emitter {
41
+
42
+ private static final String CORE_PLUGIN_NAME = "ScanditCaptureCoreNative";
43
+
44
+ private final LabelCaptureModule labelModule;
45
+ private final FrameworksLog logger;
46
+ private final DefaultServiceLocator serviceLocator;
47
+
48
+ public ScanditLabelNative() {
49
+ this.labelModule = LabelCaptureModule.create(this);
50
+ this.logger = DefaultFrameworksLog.getInstance();
51
+ this.serviceLocator = DefaultServiceLocator.getInstance();
52
+ }
53
+
54
+ @Override
55
+ public void load() {
56
+ super.load();
57
+
58
+ // We need to register the plugin with its Core dependency for serializers to load.
59
+ PluginHandle corePlugin = getBridge().getPlugin(CORE_PLUGIN_NAME);
60
+ if (corePlugin != null) {
61
+ ((ScanditCaptureCoreNative) corePlugin.getInstance())
62
+ .registerPluginInstance(getPluginHandle().getInstance());
63
+ } else {
64
+ logger.error("Core not found");
65
+ }
66
+
67
+ labelModule.onCreate(getContext());
68
+ }
69
+
70
+ @Override
71
+ protected void handleOnDestroy() {
72
+ labelModule.onDestroy();
73
+ }
74
+
75
+ private boolean checkCameraPermission() {
76
+ return getPermissionState("camera") == PermissionState.GRANTED;
77
+ }
78
+
79
+ @SuppressWarnings("unused")
80
+ @PermissionCallback
81
+ private void onCameraPermissionResult(PluginCall call) {
82
+ if (checkCameraPermission()) {
83
+ call.resolve();
84
+ return;
85
+ }
86
+
87
+ call.reject("Camera permissions not granted.");
88
+ }
89
+
90
+ @PluginMethod
91
+ public void getDefaults(PluginCall call) {
92
+ Map<String, Object> defaultsMap = new HashMap<>();
93
+ defaultsMap.put("LabelCapture", labelModule.getDefaults());
94
+
95
+ JSObject defaults = null;
96
+ try {
97
+ defaults = JSObject.fromJSONObject(new JSONObject(defaultsMap));
98
+ } catch (JSONException e) {
99
+ call.reject("Unable to get the label capture defaults.", e);
100
+ }
101
+ call.resolve(defaults);
102
+ }
103
+
104
+ @PluginMethod
105
+ public void executeLabel(PluginCall call) {
106
+ CoreModule coreModule = (CoreModule) serviceLocator.resolve(CoreModule.class.getSimpleName());
107
+
108
+ if (coreModule == null) {
109
+ call.reject("Unable to retrieve the CoreModule from the locator.");
110
+ return;
111
+ }
112
+
113
+ boolean result =
114
+ coreModule.execute(new CapacitorMethodCall(call), new CapacitorResult(call), labelModule);
115
+
116
+ if (!result) {
117
+ String methodName = call.getData().getString("methodName");
118
+ if (methodName == null) {
119
+ methodName = "unknown";
120
+ }
121
+ call.reject("Unknown method: " + methodName);
122
+ }
123
+ }
124
+
125
+ @Override
126
+ public void emit(@NonNull String eventName, @NonNull Map<String, Object> payload) {
127
+ JSObject capacitorPayload = new JSObject();
128
+ capacitorPayload.put("name", eventName);
129
+ capacitorPayload.put("data", new JSONObject(payload).toString());
130
+
131
+ notifyListeners(eventName, capacitorPayload);
132
+ }
133
+
134
+ @Override
135
+ public boolean hasListenersForEvent(@NonNull String eventName) {
136
+ return this.hasListeners(eventName);
137
+ }
138
+
139
+ @Override
140
+ public boolean hasViewSpecificListenersForEvent(int viewId, @NonNull String eventName) {
141
+ return this.hasListenersForEvent(eventName);
142
+ }
143
+
144
+ @Override
145
+ public boolean hasModeSpecificListenersForEvent(int modeId, @NonNull String eventName) {
146
+ return this.hasListenersForEvent(eventName);
147
+ }
148
+ }
@@ -1,3 +1,5 @@
1
+ export { AdaptiveRecognitionResult } from 'scandit-datacapture-frameworks-label';
2
+ export { AdaptiveRecognitionResultType } from 'scandit-datacapture-frameworks-label';
1
3
  export { BarcodeField } from 'scandit-datacapture-frameworks-label';
2
4
  export { CapturedLabel } from 'scandit-datacapture-frameworks-label';
3
5
  export { CustomBarcode } from 'scandit-datacapture-frameworks-label';
@@ -6,6 +8,9 @@ export { ExpiryDateText } from 'scandit-datacapture-frameworks-label';
6
8
  export { ImeiOneBarcode } from 'scandit-datacapture-frameworks-label';
7
9
  export { ImeiTwoBarcode } from 'scandit-datacapture-frameworks-label';
8
10
  export { LabelCapture } from 'scandit-datacapture-frameworks-label';
11
+ export { LabelCaptureAdaptiveRecognitionOverlay } from 'scandit-datacapture-frameworks-label';
12
+ export { LabelCaptureAdaptiveRecognitionListener } from 'scandit-datacapture-frameworks-label';
13
+ export { LabelCaptureAdaptiveRecognitionSettings } from 'scandit-datacapture-frameworks-label';
9
14
  export { LabelCaptureAdvancedOverlay } from 'scandit-datacapture-frameworks-label';
10
15
  export { LabelCaptureAdvancedOverlayListener } from 'scandit-datacapture-frameworks-label';
11
16
  export { LabelCaptureAdvancedOverlayView } from './ts/LabelCaptureAdvancedOverlayView';
@@ -30,6 +35,8 @@ export { LabelFieldState } from 'scandit-datacapture-frameworks-label';
30
35
  export { LabelFieldType } from 'scandit-datacapture-frameworks-label';
31
36
  export { PackingDateText } from 'scandit-datacapture-frameworks-label';
32
37
  export { PartNumberBarcode } from 'scandit-datacapture-frameworks-label';
38
+ export { ReceiptScanningResult } from 'scandit-datacapture-frameworks-label';
39
+ export { ReceiptScanningLineItem } from 'scandit-datacapture-frameworks-label';
33
40
  export { SerialNumberBarcode } from 'scandit-datacapture-frameworks-label';
34
41
  export { TextField } from 'scandit-datacapture-frameworks-label';
35
42
  export { TotalPriceText } from 'scandit-datacapture-frameworks-label';