@capgo/capacitor-zebra-datawedge 8.0.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.
@@ -0,0 +1,60 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4
+ androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.16.0'
5
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
6
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
7
+ }
8
+
9
+ buildscript {
10
+ repositories {
11
+ google()
12
+ mavenCentral()
13
+ }
14
+ dependencies {
15
+ classpath 'com.android.tools.build:gradle:8.13.0'
16
+ }
17
+ }
18
+
19
+ apply plugin: 'com.android.library'
20
+
21
+ android {
22
+ namespace = "app.capgo.zebradatawedge"
23
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
24
+ defaultConfig {
25
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
26
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
27
+ versionCode 1
28
+ versionName "1.0"
29
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
30
+ }
31
+ buildTypes {
32
+ release {
33
+ minifyEnabled false
34
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
35
+ }
36
+ }
37
+ lintOptions {
38
+ abortOnError = false
39
+ }
40
+ compileOptions {
41
+ sourceCompatibility JavaVersion.VERSION_21
42
+ targetCompatibility JavaVersion.VERSION_21
43
+ }
44
+ }
45
+
46
+ repositories {
47
+ google()
48
+ mavenCentral()
49
+ }
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ annotationProcessor project(':capacitor-android')
55
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
56
+ implementation "androidx.core:core:$androidxCoreVersion"
57
+ testImplementation "junit:junit:$junitVersion"
58
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
59
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
60
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,310 @@
1
+ package app.capgo.zebradatawedge;
2
+
3
+ import android.content.Intent;
4
+ import android.os.Bundle;
5
+ import com.getcapacitor.JSArray;
6
+ import com.getcapacitor.JSObject;
7
+ import java.util.ArrayList;
8
+ import java.util.List;
9
+ import java.util.Set;
10
+ import java.util.UUID;
11
+ import org.json.JSONArray;
12
+ import org.json.JSONException;
13
+ import org.json.JSONObject;
14
+
15
+ public final class ZebraDataWedge {
16
+
17
+ private ZebraDataWedge() {}
18
+
19
+ public static final String DATAWEDGE_PACKAGE = "com.symbol.datawedge";
20
+
21
+ public static final String ACTION = "com.symbol.datawedge.api.ACTION";
22
+ public static final String RESULT_ACTION = "com.symbol.datawedge.api.RESULT_ACTION";
23
+ public static final String NOTIFICATION_ACTION = "com.symbol.datawedge.api.NOTIFICATION_ACTION";
24
+
25
+ public static final String EXTRA_SCAN_DATA = "com.symbol.datawedge.data_string";
26
+ public static final String EXTRA_SCAN_LABEL_TYPE = "com.symbol.datawedge.label_type";
27
+ public static final String EXTRA_SCAN_SOURCE = "com.symbol.datawedge.source";
28
+ public static final String EXTRA_SCAN_DECODE_MODE = "com.symbol.datawedge.decode_mode";
29
+ public static final String EXTRA_NOTIFICATION = "com.symbol.datawedge.api.NOTIFICATION";
30
+
31
+ public static final String EXTRA_SEND_RESULT = "SEND_RESULT";
32
+ public static final String EXTRA_COMMAND_IDENTIFIER = "COMMAND_IDENTIFIER";
33
+ public static final String EXTRA_COMMAND = "COMMAND";
34
+ public static final String EXTRA_RESULT = "RESULT";
35
+ public static final String EXTRA_RESULT_INFO = "RESULT_INFO";
36
+ public static final String EXTRA_RESULT_LIST = "RESULT_LIST";
37
+
38
+ public static final String CMD_CLONE_PROFILE = "com.symbol.datawedge.api.CLONE_PROFILE";
39
+ public static final String CMD_CREATE_PROFILE = "com.symbol.datawedge.api.CREATE_PROFILE";
40
+ public static final String CMD_DELETE_PROFILE = "com.symbol.datawedge.api.DELETE_PROFILE";
41
+ public static final String CMD_IMPORT_CONFIG = "com.symbol.datawedge.api.IMPORT_CONFIG";
42
+ public static final String CMD_RENAME_PROFILE = "com.symbol.datawedge.api.RENAME_PROFILE";
43
+ public static final String CMD_RESTORE_CONFIG = "com.symbol.datawedge.api.RESTORE_CONFIG";
44
+ public static final String CMD_SET_CONFIG = "com.symbol.datawedge.api.SET_CONFIG";
45
+ public static final String CMD_SET_DISABLED_APP_LIST = "com.symbol.datawedge.api.SET_DISABLED_APP_LIST";
46
+ public static final String CMD_SET_IGNORE_DISABLED_PROFILES = "com.symbol.datawedge.api.SET_IGNORE_DISABLED_PROFILES";
47
+ public static final String CMD_REGISTER_FOR_NOTIFICATION = "com.symbol.datawedge.api.REGISTER_FOR_NOTIFICATION";
48
+ public static final String CMD_UNREGISTER_FOR_NOTIFICATION = "com.symbol.datawedge.api.UNREGISTER_FOR_NOTIFICATION";
49
+ public static final String CMD_ENUMERATE_SCANNERS = "com.symbol.datawedge.api.ENUMERATE_SCANNERS";
50
+ public static final String CMD_GET_ACTIVE_PROFILE = "com.symbol.datawedge.api.GET_ACTIVE_PROFILE";
51
+ public static final String CMD_GET_CONFIG = "com.symbol.datawedge.api.GET_CONFIG";
52
+ public static final String CMD_GET_DATAWEDGE_STATUS = "com.symbol.datawedge.api.GET_DATAWEDGE_STATUS";
53
+ public static final String CMD_GET_DISABLED_APP_LIST = "com.symbol.datawedge.api.GET_DISABLED_APP_LIST";
54
+ public static final String CMD_GET_IGNORE_DISABLED_PROFILES = "com.symbol.datawedge.api.GET_IGNORE_DISABLED_PROFILES";
55
+ public static final String CMD_GET_PROFILES_LIST = "com.symbol.datawedge.api.GET_PROFILES_LIST";
56
+ public static final String CMD_GET_SCANNER_STATUS = "com.symbol.datawedge.api.GET_SCANNER_STATUS";
57
+ public static final String CMD_GET_VERSION_INFO = "com.symbol.datawedge.api.GET_VERSION_INFO";
58
+ public static final String CMD_ENABLE_DATAWEDGE = "com.symbol.datawedge.api.ENABLE_DATAWEDGE";
59
+ public static final String CMD_SCANNER_INPUT_PLUGIN = "com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN";
60
+ public static final String CMD_ENUMERATE_TRIGGERS = "com.symbol.datawedge.api.ENUMERATE_TRIGGERS";
61
+ public static final String CMD_NOTIFY = "com.symbol.datawedge.api.NOTIFY";
62
+ public static final String CMD_RESET_DEFAULT_PROFILE = "com.symbol.datawedge.api.RESET_DEFAULT_PROFILE";
63
+ public static final String CMD_SET_DEFAULT_PROFILE = "com.symbol.datawedge.api.SET_DEFAULT_PROFILE";
64
+ public static final String CMD_SET_REPORTING_OPTIONS = "com.symbol.datawedge.api.SET_REPORTING_OPTIONS";
65
+ public static final String CMD_SOFT_RFID_TRIGGER = "com.symbol.datawedge.api.SOFT_RFID_TRIGGER";
66
+ public static final String CMD_SOFT_SCAN_TRIGGER = "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER";
67
+ public static final String CMD_SWITCH_SCANNER = "com.symbol.datawedge.api.SWITCH_SCANNER";
68
+ public static final String CMD_SWITCH_SCANNER_PARAMS = "com.symbol.datawedge.api.SWITCH_SCANNER_PARAMS";
69
+ public static final String CMD_SWITCH_TO_PROFILE = "com.symbol.datawedge.api.SWITCH_TO_PROFILE";
70
+
71
+ public static final String RESULT_GET_PROFILES_LIST = "com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST";
72
+ public static final String RESULT_GET_ACTIVE_PROFILE = "com.symbol.datawedge.api.RESULT_GET_ACTIVE_PROFILE";
73
+ public static final String RESULT_GET_VERSION_INFO = "com.symbol.datawedge.api.RESULT_GET_VERSION_INFO";
74
+ public static final String RESULT_GET_CONFIG = "com.symbol.datawedge.api.RESULT_GET_CONFIG";
75
+ public static final String RESULT_GET_CONFIG_LEGACY = "GET_CONFIG_RESULT";
76
+ public static final String RESULT_GET_DATAWEDGE_STATUS = "com.symbol.datawedge.api.RESULT_GET_DATAWEDGE_STATUS";
77
+ public static final String RESULT_GET_DISABLED_APP_LIST = "com.symbol.datawedge.api.RESULT_GET_DISABLED_APP_LIST";
78
+ public static final String RESULT_GET_IGNORE_DISABLED_PROFILES = "com.symbol.datawedge.api.RESULT_GET_IGNORE_DISABLED_PROFILES";
79
+ public static final String RESULT_GET_SCANNER_STATUS = "com.symbol.datawedge.api.RESULT_GET_SCANNER_STATUS";
80
+ public static final String RESULT_ENUMERATE_SCANNERS = "com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS";
81
+ public static final String RESULT_ENUMERATED_SCANNER_LIST = "DWAPI_KEY_ENUMERATEDSCANNERLIST";
82
+ public static final String RESULT_ENUMERATE_TRIGGERS = "com.symbol.datawedge.api.RESULT_ENUMERATE_TRIGGERS";
83
+
84
+ public static final String RESULT_SUCCESS = "SUCCESS";
85
+ public static final String RESULT_FAILURE = "FAILURE";
86
+
87
+ public static final String VALUE_LAST_RESULT = "LAST_RESULT";
88
+ public static final String VALUE_ENABLE_PLUGIN = "ENABLE_PLUGIN";
89
+ public static final String VALUE_DISABLE_PLUGIN = "DISABLE_PLUGIN";
90
+ public static final String VALUE_START_SCANNING = "START_SCANNING";
91
+
92
+ public static Intent newIntent() {
93
+ Intent intent = new Intent(ACTION);
94
+ intent.setPackage(DATAWEDGE_PACKAGE);
95
+ return intent;
96
+ }
97
+
98
+ public static String newCommandIdentifier(String prefix) {
99
+ return prefix + "-" + UUID.randomUUID();
100
+ }
101
+
102
+ public static JSObject parseScanIntent(Intent intent) {
103
+ JSObject ret = new JSObject();
104
+ ret.put("data", intent.getStringExtra(EXTRA_SCAN_DATA));
105
+ ret.put("labelType", intent.getStringExtra(EXTRA_SCAN_LABEL_TYPE));
106
+ ret.put("source", intent.getStringExtra(EXTRA_SCAN_SOURCE));
107
+ ret.put("decodedMode", intent.getStringExtra(EXTRA_SCAN_DECODE_MODE));
108
+ ret.put("intentAction", intent.getAction());
109
+ return ret;
110
+ }
111
+
112
+ public static JSObject bundleToJSObject(Bundle bundle) {
113
+ JSObject ret = new JSObject();
114
+ if (bundle == null) {
115
+ return ret;
116
+ }
117
+ Set<String> keys = bundle.keySet();
118
+ for (String key : keys) {
119
+ Object value = bundle.get(key);
120
+ if (
121
+ value instanceof String ||
122
+ value instanceof Integer ||
123
+ value instanceof Long ||
124
+ value instanceof Double ||
125
+ value instanceof Boolean
126
+ ) {
127
+ ret.put(key, value);
128
+ } else if (value instanceof Bundle) {
129
+ ret.put(key, bundleToJSObject((Bundle) value));
130
+ } else if (value instanceof String[]) {
131
+ ret.put(key, stringArrayToJSArray((String[]) value));
132
+ } else if (value instanceof int[]) {
133
+ ret.put(key, intArrayToJSArray((int[]) value));
134
+ } else if (value instanceof ArrayList<?>) {
135
+ ret.put(key, listToJSArray((ArrayList<?>) value));
136
+ } else if (value instanceof Object[]) {
137
+ ret.put(key, objectArrayToJSArray((Object[]) value));
138
+ } else if (value != null) {
139
+ ret.put(key, value.toString());
140
+ }
141
+ }
142
+ return ret;
143
+ }
144
+
145
+ public static JSArray stringArrayToJSArray(String[] values) {
146
+ JSArray array = new JSArray();
147
+ if (values == null) {
148
+ return array;
149
+ }
150
+ for (String value : values) {
151
+ array.put(value);
152
+ }
153
+ return array;
154
+ }
155
+
156
+ public static JSArray intArrayToJSArray(int[] values) {
157
+ JSArray array = new JSArray();
158
+ if (values == null) {
159
+ return array;
160
+ }
161
+ for (int value : values) {
162
+ array.put(value);
163
+ }
164
+ return array;
165
+ }
166
+
167
+ public static JSArray objectArrayToJSArray(Object[] values) {
168
+ JSArray array = new JSArray();
169
+ if (values == null) {
170
+ return array;
171
+ }
172
+ for (Object value : values) {
173
+ array.put(normalizeToJSON(value));
174
+ }
175
+ return array;
176
+ }
177
+
178
+ public static JSArray listToJSArray(List<?> values) {
179
+ JSArray array = new JSArray();
180
+ if (values == null) {
181
+ return array;
182
+ }
183
+ for (Object value : values) {
184
+ array.put(normalizeToJSON(value));
185
+ }
186
+ return array;
187
+ }
188
+
189
+ public static Bundle jsonObjectToBundle(JSObject object) {
190
+ if (object == null) {
191
+ return new Bundle();
192
+ }
193
+ return jsonToBundle(object);
194
+ }
195
+
196
+ public static Bundle jsonToBundle(JSONObject jsonObject) {
197
+ Bundle bundle = new Bundle();
198
+ if (jsonObject == null) {
199
+ return bundle;
200
+ }
201
+ JSONArray names = jsonObject.names();
202
+ if (names == null) {
203
+ return bundle;
204
+ }
205
+ for (int i = 0; i < names.length(); i++) {
206
+ try {
207
+ String key = names.getString(i);
208
+ Object value = jsonObject.get(key);
209
+ putValue(bundle, key, value);
210
+ } catch (JSONException ignored) {}
211
+ }
212
+ return bundle;
213
+ }
214
+
215
+ public static String[] jsonArrayToStringArray(JSONArray array) {
216
+ if (array == null) {
217
+ return new String[0];
218
+ }
219
+ String[] values = new String[array.length()];
220
+ for (int i = 0; i < array.length(); i++) {
221
+ values[i] = array.optString(i);
222
+ }
223
+ return values;
224
+ }
225
+
226
+ public static int[] jsonArrayToIntArray(JSONArray array) {
227
+ if (array == null) {
228
+ return new int[0];
229
+ }
230
+ int[] values = new int[array.length()];
231
+ for (int i = 0; i < array.length(); i++) {
232
+ values[i] = array.optInt(i);
233
+ }
234
+ return values;
235
+ }
236
+
237
+ private static void putValue(Bundle bundle, String key, Object value) {
238
+ if (value == null || value == JSONObject.NULL) {
239
+ return;
240
+ }
241
+ if (value instanceof String) {
242
+ bundle.putString(key, (String) value);
243
+ return;
244
+ }
245
+ if (value instanceof Integer) {
246
+ bundle.putInt(key, (Integer) value);
247
+ return;
248
+ }
249
+ if (value instanceof Long) {
250
+ bundle.putLong(key, (Long) value);
251
+ return;
252
+ }
253
+ if (value instanceof Double) {
254
+ bundle.putDouble(key, (Double) value);
255
+ return;
256
+ }
257
+ if (value instanceof Boolean) {
258
+ bundle.putBoolean(key, (Boolean) value);
259
+ return;
260
+ }
261
+ if (value instanceof JSONObject) {
262
+ bundle.putBundle(key, jsonToBundle((JSONObject) value));
263
+ return;
264
+ }
265
+ if (value instanceof JSONArray) {
266
+ JSONArray array = (JSONArray) value;
267
+ if (array.length() == 0) {
268
+ bundle.putStringArrayList(key, new ArrayList<>());
269
+ return;
270
+ }
271
+ Object first = array.opt(0);
272
+ if (first instanceof JSONObject) {
273
+ ArrayList<Bundle> bundles = new ArrayList<>();
274
+ for (int i = 0; i < array.length(); i++) {
275
+ Object item = array.opt(i);
276
+ if (item instanceof JSONObject) {
277
+ bundles.add(jsonToBundle((JSONObject) item));
278
+ }
279
+ }
280
+ bundle.putParcelableArrayList(key, bundles);
281
+ return;
282
+ }
283
+ if (first instanceof Integer) {
284
+ bundle.putIntArray(key, jsonArrayToIntArray(array));
285
+ return;
286
+ }
287
+ String[] values = jsonArrayToStringArray(array);
288
+ bundle.putStringArray(key, values);
289
+ }
290
+ }
291
+
292
+ private static Object normalizeToJSON(Object value) {
293
+ if (value instanceof Bundle) {
294
+ return bundleToJSObject((Bundle) value);
295
+ }
296
+ if (value instanceof String[]) {
297
+ return stringArrayToJSArray((String[]) value);
298
+ }
299
+ if (value instanceof int[]) {
300
+ return intArrayToJSArray((int[]) value);
301
+ }
302
+ if (value instanceof ArrayList<?>) {
303
+ return listToJSArray((ArrayList<?>) value);
304
+ }
305
+ if (value instanceof Object[]) {
306
+ return objectArrayToJSArray((Object[]) value);
307
+ }
308
+ return value;
309
+ }
310
+ }