anyline-ocr-react-native-module 55.2.0 → 55.5.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.
Files changed (69) hide show
  1. package/{ios/AnylineReact.podspec → AnylineReact.podspec} +3 -3
  2. package/android/build.gradle +1 -3
  3. package/android/src/main/AndroidManifest.xml +1 -3
  4. package/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +251 -252
  5. package/index.js +3 -16
  6. package/ios/AnylineSDKPlugin.h +4 -4
  7. package/ios/AnylineSDKPlugin.m +285 -207
  8. package/package.json +12 -2
  9. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  10. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  11. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  12. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  13. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  14. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  15. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  16. package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
  17. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  18. package/android/.gradle/7.6/gc.properties +0 -0
  19. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  20. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  21. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  22. package/android/.gradle/config.properties +0 -2
  23. package/android/.gradle/vcs-1/gc.properties +0 -0
  24. package/android/.idea/PipelineViewerConfig.xml +0 -6
  25. package/android/.idea/appInsightsSettings.xml +0 -28
  26. package/android/.idea/caches/deviceStreaming.xml +0 -486
  27. package/android/.idea/compiler.xml +0 -6
  28. package/android/.idea/gradle.xml +0 -19
  29. package/android/.idea/jarRepositories.xml +0 -30
  30. package/android/.idea/material_theme_project_new.xml +0 -13
  31. package/android/.idea/migrations.xml +0 -10
  32. package/android/.idea/misc.xml +0 -9
  33. package/android/.idea/runConfigurations.xml +0 -17
  34. package/android/.idea/vcs.xml +0 -6
  35. package/android/local.properties +0 -8
  36. package/android/src/main/java/com/anyline/reactnative/FeedbackConfig.java +0 -59
  37. package/android/src/main/java/com/anyline/reactnative/ImageTextConfig.java +0 -49
  38. package/android/src/main/java/com/anyline/reactnative/InstructionConfig.java +0 -20
  39. package/android/src/main/java/com/anyline/reactnative/Offset.java +0 -21
  40. package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +0 -32
  41. package/android/src/main/java/com/anyline/reactnative/ScanActivity.java +0 -426
  42. package/android/src/main/java/com/anyline/reactnative/updateAsset/AnylineUpdateDelegateImpl.java +0 -50
  43. package/android/src/main/java/com/anyline/reactnative/updateAsset/AssetContextJsonParser.java +0 -28
  44. package/android/src/main/res/drawable/rotate_screen_background.xml +0 -18
  45. package/android/src/main/res/drawable/rotate_screen_white.png +0 -0
  46. package/android/src/main/res/drawable-hdpi/ic_flash_auto.png +0 -0
  47. package/android/src/main/res/drawable-hdpi/ic_flash_off.png +0 -0
  48. package/android/src/main/res/drawable-hdpi/ic_flash_on.png +0 -0
  49. package/android/src/main/res/drawable-mdpi/ic_flash_auto.png +0 -0
  50. package/android/src/main/res/drawable-mdpi/ic_flash_off.png +0 -0
  51. package/android/src/main/res/drawable-mdpi/ic_flash_on.png +0 -0
  52. package/android/src/main/res/drawable-xhdpi/ic_flash_auto.png +0 -0
  53. package/android/src/main/res/drawable-xhdpi/ic_flash_off.png +0 -0
  54. package/android/src/main/res/drawable-xhdpi/ic_flash_on.png +0 -0
  55. package/android/src/main/res/drawable-xxhdpi/ic_flash_auto.png +0 -0
  56. package/android/src/main/res/drawable-xxhdpi/ic_flash_off.png +0 -0
  57. package/android/src/main/res/drawable-xxhdpi/ic_flash_on.png +0 -0
  58. package/android/src/main/res/drawable-xxxhdpi/ic_flash_auto.png +0 -0
  59. package/android/src/main/res/drawable-xxxhdpi/ic_flash_off.png +0 -0
  60. package/android/src/main/res/drawable-xxxhdpi/ic_flash_on.png +0 -0
  61. package/android/src/main/res/layout/activity_scan.xml +0 -93
  62. package/ios/ALJsonUIConfiguration.h +0 -54
  63. package/ios/ALJsonUIConfiguration.m +0 -251
  64. package/ios/ALPluginHelper.h +0 -48
  65. package/ios/ALPluginHelper.m +0 -332
  66. package/ios/ALPluginScanViewController.h +0 -18
  67. package/ios/ALPluginScanViewController.m +0 -476
  68. package/ios/ALRoundedView.h +0 -25
  69. package/ios/ALRoundedView.m +0 -107
@@ -1,426 +0,0 @@
1
- package com.anyline.reactnative;
2
-
3
- import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_CONFIG_JSON;
4
- import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS;
5
- import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_ERROR_MESSAGE;
6
- import static com.anyline.reactnative.AnylineSDKPlugin.RESULT_ERROR;
7
- import static io.anyline2.sdk.extension.ScanViewInitializationParametersExtensionKt.getScanViewInitializationParametersFromJsonObject;
8
-
9
- import android.content.Intent;
10
- import android.content.pm.ActivityInfo;
11
- import android.graphics.Color;
12
- import android.graphics.Rect;
13
- import android.os.Bundle;
14
- import android.os.Handler;
15
- import android.os.Looper;
16
- import android.util.Pair;
17
- import android.view.View;
18
- import android.view.Gravity;
19
-
20
- import androidx.annotation.NonNull;
21
- import androidx.annotation.Nullable;
22
- import androidx.appcompat.app.AppCompatActivity;
23
- import androidx.coordinatorlayout.widget.CoordinatorLayout;
24
-
25
- import com.anyline.reactnative.databinding.ActivityScanBinding;
26
-
27
- import org.json.JSONArray;
28
- import org.json.JSONException;
29
- import org.json.JSONObject;
30
-
31
- import java.util.Timer;
32
- import java.util.TimerTask;
33
-
34
- import io.anyline.plugin.config.ScanViewInitializationParameters;
35
- import io.anyline2.ScanResult;
36
- import io.anyline2.view.ScanView;
37
- import io.anyline2.view.ScanViewLoadResult;
38
- import io.anyline2.viewplugin.ScanViewPlugin;
39
- import io.anyline2.viewplugin.ViewPluginBase;
40
-
41
- public class ScanActivity extends AppCompatActivity {
42
-
43
- private static final String KEY_DEFAULT_ORIENTATION_APPLIED = "default_orientation_applied";
44
-
45
- private Handler handler = new Handler(Looper.getMainLooper());
46
- private ActivityScanBinding binding;
47
- private ScanView scanView;
48
-
49
- private float dpFactor = 0;
50
- private boolean defaultOrientationApplied;
51
- private int orientation;
52
-
53
- @Deprecated
54
- private InstructionConfig instructionConfig = null;
55
- @Deprecated
56
- private ImageTextConfig imageCutoutConfig = null;
57
- @Deprecated
58
- private FeedbackConfig feedbackConfig = null;
59
-
60
- @Deprecated
61
- private long cleanUIFeedbackIntervalMills = 2000L;
62
- @Deprecated
63
- private Timer cleanUIFeedbackTimer = null;
64
-
65
- @Deprecated
66
- private static final String FEEDBACK_SCANINFO_LIGHTINGCONDITION = "$lightingCondition";
67
- @Deprecated
68
- private static final String FEEDBACK_SCANINFO_LIGHTINGCONDITION_TOODARK = "TOODARK";
69
- @Deprecated
70
- private static final String FEEDBACK_SCANINFO_LIGHTINGCONDITION_TOOBRIGHT = "TOOBRIGHT";
71
- @Deprecated
72
- private static final int FEEDBACK_RUNSKIPPED_WRONGFORMAT = 5006;
73
- @Deprecated
74
- private static final int FEEDBACK_RUNSKIPPED_WRONGDATE = 5027;
75
- @Deprecated
76
- private static final int FEEDBACK_RUNSKIPPED_TOOCLOSE = 5023;
77
- @Deprecated
78
- private static final int FEEDBACK_RUNSKIPPED_TOOFAR = 5024;
79
-
80
- @Override
81
- protected void onCreate(@Nullable Bundle savedInstanceState) {
82
- super.onCreate(savedInstanceState);
83
- binding = ActivityScanBinding.inflate(getLayoutInflater());
84
- setContentView(binding.getRoot());
85
-
86
- dpFactor = getResources().getDisplayMetrics().density;
87
-
88
- orientation = this.getResources().getConfiguration().orientation;
89
-
90
- scanView = binding.scanView;
91
- scanView.setOnScanViewLoaded(scanViewLoadResult -> {
92
- if (scanViewLoadResult instanceof ScanViewLoadResult.Succeeded) {
93
- if (getIntent().hasExtra(EXTRA_CONFIG_JSON)) {
94
- try {
95
- JSONObject configJSON = new JSONObject(getIntent().getStringExtra(EXTRA_CONFIG_JSON));
96
-
97
- applyDefaultOrientation(configJSON);
98
- setupChangeOrientationButton(configJSON);
99
- setupCustomUIFeedback(configJSON);
100
-
101
- String initializationParametersString = getIntent().getStringExtra(EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS);
102
- if (initializationParametersString != null) {
103
- ScanViewInitializationParameters scanViewInitializationParameters =
104
- getScanViewInitializationParametersFromJsonObject(
105
- this,
106
- new JSONObject(initializationParametersString));
107
- scanView.init(configJSON, scanViewInitializationParameters);
108
- } else {
109
- scanView.init(configJSON);
110
- }
111
- scanView.start();
112
-
113
- ViewPluginBase viewPluginBase = scanView.getScanViewPlugin();
114
-
115
- observeUIFeedbackEvents(viewPluginBase);
116
-
117
- viewPluginBase.resultReceived = scanResult -> {
118
- setResult(AnylineSDKPlugin.RESULT_OK);
119
- JSONObject resultObject = getResultWithImagePath(scanResult);
120
- ResultReporter.onResult(resultObject.toString(), true);
121
- finish();
122
- };
123
-
124
- viewPluginBase.resultsReceived = scanResults -> {
125
- JSONArray resultJSONArray = new JSONArray();
126
-
127
- for (ScanResult scanResult : scanResults) {
128
- JSONObject resultObject = getResultWithImagePath(scanResult);
129
- resultJSONArray.put(resultObject);
130
- }
131
- setResult(AnylineSDKPlugin.RESULT_OK);
132
- ResultReporter.onResult(resultJSONArray.toString(), true);
133
- finish();
134
- };
135
- } catch (JSONException e) {
136
- finishWithError("Error parsing view config: " + e.getMessage());
137
- } catch (Exception e) {
138
- finishWithError(getString(getResources().getIdentifier("error_invalid_json_data", "string", getPackageName()))
139
- + "\n" + e.getLocalizedMessage());
140
- }
141
- } else {
142
- finishWithError("View config not found");
143
- }
144
- } else {
145
- ScanViewLoadResult.Failed scanViewLoadFailed = (ScanViewLoadResult.Failed) scanViewLoadResult;
146
- finishWithError(scanViewLoadFailed.getErrorMessage());
147
- }
148
- });
149
-
150
- if (savedInstanceState != null) {
151
- defaultOrientationApplied = savedInstanceState.getBoolean(KEY_DEFAULT_ORIENTATION_APPLIED);
152
- }
153
- }
154
-
155
- private void applyDefaultOrientation(JSONObject configJSON) {
156
- if (defaultOrientationApplied) return;
157
-
158
- JSONObject optionsJsonObject = configJSON.optJSONObject("options");
159
-
160
- if (optionsJsonObject != null) {
161
- String defaultOrientationJsonString = optionsJsonObject.optString("defaultOrientation", "");
162
-
163
- if ("portrait".equals(defaultOrientationJsonString)) {
164
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
165
- } else if ("landscape".equals(defaultOrientationJsonString)) {
166
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
167
- }
168
- }
169
- defaultOrientationApplied = true;
170
- }
171
-
172
- private void setupChangeOrientationButton(JSONObject configJSON) {
173
- binding.layoutChangeOrientation.setVisibility(View.GONE);
174
- JSONObject optionsJsonObject = configJSON.optJSONObject("options");
175
-
176
- if (optionsJsonObject != null) {
177
-
178
- JSONObject rotateButtonJson = optionsJsonObject.optJSONObject("rotateButton");
179
- if (rotateButtonJson != null) {
180
- RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(rotateButtonJson);
181
-
182
- CoordinatorLayout.LayoutParams buttonLayoutParams = new CoordinatorLayout.LayoutParams(
183
- CoordinatorLayout.LayoutParams.WRAP_CONTENT,
184
- CoordinatorLayout.LayoutParams.WRAP_CONTENT);
185
-
186
- buttonLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
187
- String alignment = rotateButtonConfig.getAlignment();
188
- if (alignment.length() > 0) {
189
- if (alignment.equals("top_left")) {
190
- buttonLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
191
- }
192
- if (alignment.equals("top_right")) {
193
- buttonLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
194
- }
195
- if (alignment.equals("bottom_left")) {
196
- buttonLayoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
197
- }
198
- if (alignment.equals("bottom_right")) {
199
- buttonLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
200
- }
201
- }
202
- if (rotateButtonConfig.hasOffset()) {
203
- buttonLayoutParams.setMargins(rotateButtonConfig.getOffset().getX(), rotateButtonConfig.getOffset().getY(), 0, 0);
204
- }
205
- binding.layoutChangeOrientation.setLayoutParams(buttonLayoutParams);
206
- binding.layoutChangeOrientation.requestLayout();
207
-
208
- binding.layoutChangeOrientation.setVisibility(View.VISIBLE);
209
- binding.imageviewChangeOrientation.setOnClickListener(v -> {
210
- if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
211
- orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
212
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
213
- } else {
214
- orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
215
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
216
- }
217
- });
218
- }
219
- }
220
- }
221
-
222
- @Deprecated
223
- private void observeUIFeedbackEvents(ViewPluginBase viewPluginBase) {
224
- viewPluginBase.scanInfoReceived = jsonObject -> {
225
- if (jsonObject.optString("name", "").equals(FEEDBACK_SCANINFO_LIGHTINGCONDITION)) {
226
- String lightingConditionValue = jsonObject.optString("value", "");
227
- if (feedbackConfig != null) {
228
- if (lightingConditionValue.equalsIgnoreCase(FEEDBACK_SCANINFO_LIGHTINGCONDITION_TOODARK)) {
229
- if (feedbackConfig.brightnessTooLow != null) {
230
- updateUIFeedback(feedbackConfig.brightnessTooLow);
231
- }
232
- }
233
- else if (lightingConditionValue.equalsIgnoreCase(FEEDBACK_SCANINFO_LIGHTINGCONDITION_TOOBRIGHT)) {
234
- if (feedbackConfig.brightnessTooHigh != null) {
235
- updateUIFeedback(feedbackConfig.brightnessTooHigh);
236
- }
237
- }
238
- }
239
- }
240
- };
241
-
242
- viewPluginBase.runSkippedReceived = jsonObject -> {
243
- if (feedbackConfig != null) {
244
- if (jsonObject.optInt("code", 0) == FEEDBACK_RUNSKIPPED_WRONGFORMAT
245
- || jsonObject.optInt("code", 0) == FEEDBACK_RUNSKIPPED_WRONGDATE) {
246
- if (feedbackConfig.wrongFormat != null) {
247
- updateUIFeedback(feedbackConfig.wrongFormat);
248
- }
249
- }
250
- if (jsonObject.optInt("code", 0) == FEEDBACK_RUNSKIPPED_TOOCLOSE
251
- || jsonObject.optInt("code", 0) == FEEDBACK_RUNSKIPPED_TOOFAR) {
252
- if (feedbackConfig.distance != null) {
253
- updateUIFeedback(feedbackConfig.distance);
254
- }
255
- }
256
- }
257
- };
258
- }
259
-
260
- @Deprecated
261
- private void setupCustomUIFeedback(JSONObject configJSON) {
262
- JSONObject optionsJsonObject = configJSON.optJSONObject("options");
263
- if (optionsJsonObject != null) {
264
- try {
265
- if (optionsJsonObject.has("instruction")) {
266
- instructionConfig = new InstructionConfig(optionsJsonObject.getJSONObject("instruction"));
267
- }
268
- if (optionsJsonObject.has("imageCutout")) {
269
- imageCutoutConfig = new ImageTextConfig(this, optionsJsonObject.getJSONObject("imageCutout"));
270
- }
271
- if (optionsJsonObject.has("feedback")) {
272
- feedbackConfig = new FeedbackConfig(this, optionsJsonObject.getJSONObject("feedback"));
273
- }
274
- }
275
- catch (JSONException e) {
276
- finishWithError("Error setting up UI Feedback: " + e.getMessage());
277
- return;
278
- }
279
-
280
- if (instructionConfig != null) {
281
- if (instructionConfig.text != null) {
282
- binding.textviewInstruction.setText(instructionConfig.text);
283
- }
284
- if (instructionConfig.textColor != null) {
285
- binding.textviewInstruction.setTextColor(Color.parseColor("#" + instructionConfig.textColor));
286
- }
287
- if (instructionConfig.backgroundColor != null) {
288
- binding.textviewInstruction.setBackgroundColor(Color.parseColor("#" + instructionConfig.backgroundColor));
289
- }
290
- }
291
-
292
- if (imageCutoutConfig != null) {
293
- if (imageCutoutConfig.hasImage) {
294
- binding.imageviewCutoutOverlay.setImageResource(imageCutoutConfig.imageResId);
295
- }
296
- }
297
-
298
- }
299
-
300
- scanView.onCutoutChanged = cutouts -> {
301
- Pair<ScanViewPlugin, android.graphics.Rect> firstCutout = cutouts.get(0);
302
-
303
- ScanViewPlugin scanViewPlugin = firstCutout.first;
304
- if (scanViewPlugin != null) {
305
- Rect rect = firstCutout.second;
306
- if (rect != null) {
307
- if (instructionConfig != null) {
308
- CoordinatorLayout.LayoutParams instructionLayoutParams =
309
- new CoordinatorLayout.LayoutParams(rect.width(), rect.top);
310
- instructionLayoutParams.setMargins(rect.left, 0, rect.right, rect.top);
311
- binding.layoutInstruction.setVisibility(View.VISIBLE);
312
- binding.layoutInstruction.setLayoutParams(instructionLayoutParams);
313
- binding.layoutInstruction.requestLayout();
314
- }
315
-
316
- if (imageCutoutConfig != null) {
317
- CoordinatorLayout.LayoutParams imageCutoutLayoutParams =
318
- new CoordinatorLayout.LayoutParams(rect.width(), rect.height());
319
- imageCutoutLayoutParams.setMargins(rect.left, rect.top, rect.right, rect.bottom);
320
- binding.imageviewCutoutOverlay.setVisibility(View.VISIBLE);
321
- binding.imageviewCutoutOverlay.setLayoutParams(imageCutoutLayoutParams);
322
- binding.imageviewCutoutOverlay.requestLayout();
323
- }
324
-
325
- if (feedbackConfig != null) {
326
- CoordinatorLayout.LayoutParams feedbackLayoutParams =
327
- new CoordinatorLayout.LayoutParams(rect.width(), scanView.getHeight() - rect.bottom);
328
- feedbackLayoutParams.setMargins(rect.left, rect.bottom, rect.right, scanView.getBottom());
329
- binding.layoutBrightDistanceFeedback.setVisibility(View.VISIBLE);
330
- binding.layoutBrightDistanceFeedback.setLayoutParams(feedbackLayoutParams);
331
- binding.layoutBrightDistanceFeedback.requestLayout();
332
- }
333
- }
334
- }
335
- };
336
- }
337
-
338
- @Deprecated
339
- private void updateUIFeedback(ImageTextConfig imageTextFeedback) {
340
- if (imageTextFeedback.text != null) {
341
- if (binding.textviewBrightDistanceFeedback.getText().equals(imageTextFeedback.text)) {
342
- return;
343
- }
344
- }
345
-
346
- handler.post(() -> {
347
- if (imageTextFeedback.text != null) {
348
- binding.textviewBrightDistanceFeedback.setText(imageTextFeedback.text);
349
- }
350
- if (imageTextFeedback.hasImage) {
351
- binding.imageviewBrightDistanceFeedback.setImageResource(imageTextFeedback.imageResId);
352
- }
353
-
354
- if (feedbackConfig != null) {
355
- if (feedbackConfig.sound != null) {
356
- feedbackConfig.playBeepSound();
357
- }
358
- }
359
-
360
- if (cleanUIFeedbackTimer != null) {
361
- cleanUIFeedbackTimer.cancel();
362
- }
363
- cleanUIFeedbackTimer = new Timer();
364
- cleanUIFeedbackTimer.schedule(new TimerTask() {
365
- @Override
366
- public void run() {
367
- handler.post(() -> {
368
- binding.textviewBrightDistanceFeedback.setText("");
369
- binding.imageviewBrightDistanceFeedback.setImageBitmap(null);
370
- });
371
- }
372
- }, cleanUIFeedbackIntervalMills);
373
- });
374
- }
375
-
376
- @NonNull
377
- private JSONObject getResultWithImagePath(ScanResult scanResult) {
378
- JSONObject resultObject = scanResult.getResult();
379
-
380
- try {
381
- String fullImagePath = scanResult.getImage().save();
382
- String cutoutImagePath = scanResult.getCutoutImage().save();
383
- resultObject.put("fullImagePath", fullImagePath);
384
- resultObject.put("imagePath", cutoutImagePath);
385
- } catch (Exception e) {
386
- finishWithError("Error save scan image: " + e.getMessage());
387
- }
388
- return resultObject;
389
- }
390
-
391
- private void finishWithError(String errorMessage) {
392
- Intent intent = new Intent();
393
- intent.putExtra(EXTRA_ERROR_MESSAGE, errorMessage);
394
- setResult(RESULT_ERROR, intent);
395
- ResultReporter.onError(errorMessage);
396
- finish();
397
- }
398
-
399
- @Override
400
- protected void onSaveInstanceState(Bundle outState) {
401
- super.onSaveInstanceState(outState);
402
- outState.putBoolean(KEY_DEFAULT_ORIENTATION_APPLIED, defaultOrientationApplied);
403
- }
404
-
405
- @Override
406
- protected void onResume() {
407
- super.onResume();
408
- if (scanView.isInitialized()) {
409
- scanView.start();
410
- }
411
- }
412
-
413
- @Override
414
- protected void onPause() {
415
- if (scanView.isInitialized()) {
416
- scanView.stop();
417
- }
418
- super.onPause();
419
- }
420
-
421
- @Override
422
- public void onBackPressed() {
423
- ResultReporter.onCancel();
424
- super.onBackPressed();
425
- }
426
- }
@@ -1,50 +0,0 @@
1
- package com.anyline.reactnative.updateAsset;
2
-
3
- import com.facebook.react.bridge.Arguments;
4
- import com.facebook.react.bridge.Callback;
5
- import com.facebook.react.bridge.ReactContext;
6
- import com.facebook.react.bridge.WritableMap;
7
- import com.facebook.react.modules.core.DeviceEventManagerModule;
8
-
9
- import io.anyline2.legacy.products.IAnylineUpdateDelegate;
10
-
11
- public class AnylineUpdateDelegateImpl implements IAnylineUpdateDelegate {
12
-
13
- private ReactContext reactContext;
14
- private Callback onUpdateError;
15
- private Callback onUpdateFinished;
16
-
17
- public AnylineUpdateDelegateImpl(
18
- ReactContext reactContext,
19
- Callback onUpdateError,
20
- Callback onUpdateFinished
21
- ) {
22
- this.reactContext = reactContext;
23
- this.onUpdateError = onUpdateError;
24
- this.onUpdateFinished = onUpdateFinished;
25
- }
26
-
27
- @Override
28
- public void onUpdateProgress(String s, float v) {
29
- sendUpdateEvent(v);
30
- }
31
-
32
- @Override
33
- public void onUpdateError(String s) {
34
- onUpdateError.invoke(s);
35
- }
36
-
37
- @Override
38
- public void onUpdateFinished() {
39
- onUpdateFinished.invoke();
40
- }
41
-
42
- private void sendUpdateEvent(float progress) {
43
- WritableMap params = Arguments.createMap();
44
- params.putDouble("progress", progress);
45
-
46
- reactContext
47
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
48
- .emit("ota_progress_update_event", params);
49
- }
50
- }
@@ -1,28 +0,0 @@
1
- package com.anyline.reactnative.updateAsset;
2
-
3
- import android.content.Context;
4
-
5
- import org.json.JSONException;
6
- import org.json.JSONObject;
7
-
8
- import javax.annotation.Nullable;
9
-
10
- import io.anyline2.legacy.products.ProductContext;
11
- import io.anyline2.legacy.trainer.AssetContext;
12
- import io.anyline2.legacy.trainer.ProjectContext;
13
-
14
- public class AssetContextJsonParser {
15
-
16
- @Nullable
17
- public AssetContext parseJson(Context context, String json) throws JSONException {
18
- JSONObject jsonObject = new JSONObject(json);
19
-
20
- if (jsonObject.has("projectID")) {
21
- return new ProjectContext(context, jsonObject);
22
- }
23
- if (jsonObject.has("product")) {
24
- return new ProductContext(context, jsonObject);
25
- }
26
- throw new IllegalStateException("Neither 'projectID' nor 'product' was provided in the configuration JSON!");
27
- }
28
- }
@@ -1,18 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
-
3
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
4
- <solid
5
- android:color="#A5000000"/>
6
- <stroke
7
- android:color="@android:color/white"
8
- android:width="1dp"/>
9
- <corners
10
- android:radius="30dp" />
11
-
12
- <padding
13
- android:left="4dp"
14
- android:top="4dp"
15
- android:right="4dp"
16
- android:bottom="4dp" />
17
-
18
- </shape>
@@ -1,93 +0,0 @@
1
- <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
- android:layout_width="match_parent"
3
- android:layout_height="match_parent">
4
-
5
- <io.anyline2.view.ScanView
6
- android:id="@+id/scan_view"
7
- android:layout_width="match_parent"
8
- android:layout_height="match_parent" />
9
-
10
- <LinearLayout
11
- android:id="@+id/layout_change_orientation"
12
- android:layout_width="wrap_content"
13
- android:layout_height="wrap_content"
14
- android:layout_gravity="right|top"
15
- android:gravity="center"
16
- android:padding="40px">
17
-
18
- <ImageView
19
- android:id="@+id/imageview_change_orientation"
20
- android:layout_width="56dp"
21
- android:layout_height="56dp"
22
- android:background="@drawable/rotate_screen_background"
23
- android:scaleType="fitStart"
24
- android:src="@drawable/rotate_screen_white" />
25
- </LinearLayout>
26
-
27
- <LinearLayout
28
- android:id="@+id/layout_instruction"
29
- android:layout_width="match_parent"
30
- android:layout_height="wrap_content"
31
- android:layout_gravity="bottom"
32
- android:layout_marginVertical="30dp"
33
- android:gravity="bottom"
34
- android:orientation="vertical"
35
- android:paddingBottom="30dp"
36
- android:visibility="gone">
37
-
38
- <TextView
39
- android:id="@+id/textview_instruction"
40
- android:layout_width="match_parent"
41
- android:layout_height="wrap_content"
42
- android:gravity="bottom|center_horizontal"
43
- android:padding="10dp"
44
- android:text=""
45
- android:textColor="@color/white"
46
- android:textSize="14sp" />
47
- </LinearLayout>
48
-
49
- <LinearLayout
50
- android:id="@+id/layout_bright_distance_feedback"
51
- android:layout_width="match_parent"
52
- android:layout_height="wrap_content"
53
- android:layout_centerHorizontal="true"
54
- android:layout_gravity="top"
55
- android:gravity="top|center_horizontal"
56
- android:orientation="vertical"
57
- android:paddingTop="20dp"
58
- android:paddingBottom="5dp"
59
- android:visibility="gone">
60
-
61
- <ImageView
62
- android:id="@+id/imageview_bright_distance_feedback"
63
- android:layout_width="wrap_content"
64
- android:layout_height="wrap_content"
65
- android:layout_marginVertical="5dp"
66
- android:layout_weight="2"
67
- android:gravity="top|center_horizontal"
68
- android:scaleType="centerInside" />
69
-
70
- <TextView
71
- android:id="@+id/textview_bright_distance_feedback"
72
- android:layout_width="wrap_content"
73
- android:layout_height="wrap_content"
74
- android:layout_weight="0"
75
- android:gravity="top|center_horizontal"
76
- android:text=""
77
- android:textColor="@color/white"
78
- android:textSize="14sp" />
79
-
80
- <LinearLayout
81
- android:layout_width="match_parent"
82
- android:layout_height="wrap_content"
83
- android:layout_weight="3"
84
- android:orientation="vertical" />
85
- </LinearLayout>
86
-
87
- <ImageView
88
- android:id="@+id/imageview_cutout_overlay"
89
- android:layout_width="wrap_content"
90
- android:layout_height="wrap_content"
91
- android:scaleType="fitStart"
92
- android:visibility="gone" />
93
- </androidx.coordinatorlayout.widget.CoordinatorLayout>