anyline-ocr-react-native-module 55.2.1 → 55.6.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.
- package/AnylineReact.podspec +1 -1
- package/android/build.gradle +1 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +248 -254
- package/index.js +1 -15
- package/ios/AnylineSDKPlugin.h +4 -4
- package/ios/AnylineSDKPlugin.m +278 -211
- package/package.json +1 -1
- package/android/.gradle/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/anyline/reactnative/FeedbackConfig.java +0 -59
- package/android/src/main/java/com/anyline/reactnative/ImageTextConfig.java +0 -49
- package/android/src/main/java/com/anyline/reactnative/InstructionConfig.java +0 -20
- package/android/src/main/java/com/anyline/reactnative/Offset.java +0 -21
- package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +0 -32
- package/android/src/main/java/com/anyline/reactnative/ScanActivity.java +0 -426
- package/android/src/main/java/com/anyline/reactnative/updateAsset/AnylineUpdateDelegateImpl.java +0 -50
- package/android/src/main/java/com/anyline/reactnative/updateAsset/AssetContextJsonParser.java +0 -28
- package/android/src/main/res/drawable/rotate_screen_background.xml +0 -18
- package/android/src/main/res/drawable/rotate_screen_white.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/layout/activity_scan.xml +0 -93
- package/ios/ALJsonUIConfiguration.h +0 -54
- package/ios/ALJsonUIConfiguration.m +0 -251
- package/ios/ALPluginHelper.h +0 -48
- package/ios/ALPluginHelper.m +0 -332
- package/ios/ALPluginScanViewController.h +0 -18
- package/ios/ALPluginScanViewController.m +0 -476
- package/ios/ALRoundedView.h +0 -25
- package/ios/ALRoundedView.m +0 -107
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
package com.anyline.reactnative;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
|
|
5
|
-
import org.json.JSONObject;
|
|
6
|
-
|
|
7
|
-
import java.io.IOException;
|
|
8
|
-
|
|
9
|
-
import io.anyline2.util.SoundUtil;
|
|
10
|
-
|
|
11
|
-
@Deprecated
|
|
12
|
-
public class FeedbackConfig {
|
|
13
|
-
private SoundUtil soundUtil;
|
|
14
|
-
public ImageTextConfig wrongFormat = null;
|
|
15
|
-
public ImageTextConfig brightnessTooHigh = null;
|
|
16
|
-
public ImageTextConfig brightnessTooLow = null;
|
|
17
|
-
public ImageTextConfig distance = null;
|
|
18
|
-
public String sound = null;
|
|
19
|
-
|
|
20
|
-
public FeedbackConfig(Context context, JSONObject jsonObject) {
|
|
21
|
-
if (jsonObject.has("format")) {
|
|
22
|
-
wrongFormat = new ImageTextConfig(context, jsonObject.optJSONObject("format"));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (jsonObject.has("distance")) {
|
|
26
|
-
distance = new ImageTextConfig(context, jsonObject.optJSONObject("distance"));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (jsonObject.has("brightness")) {
|
|
30
|
-
JSONObject jsonBrightness = jsonObject.optJSONObject("brightness");
|
|
31
|
-
if (jsonBrightness.has("too_high")) {
|
|
32
|
-
brightnessTooHigh = new ImageTextConfig(context, jsonBrightness.optJSONObject("too_high"));
|
|
33
|
-
}
|
|
34
|
-
if (jsonBrightness.has("too_low")) {
|
|
35
|
-
brightnessTooLow = new ImageTextConfig(context, jsonBrightness.optJSONObject("too_low"));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (jsonObject.has("sound")) {
|
|
40
|
-
sound = jsonObject.optString("sound", "");
|
|
41
|
-
soundUtil = new SoundUtil(context);
|
|
42
|
-
try {
|
|
43
|
-
soundUtil.loadSoundFromAssets(sound);
|
|
44
|
-
} catch (IOException e) {
|
|
45
|
-
soundUtil = null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public void playBeepSound() {
|
|
52
|
-
if (sound != null) {
|
|
53
|
-
if (soundUtil != null) {
|
|
54
|
-
soundUtil.playSound(sound);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
package com.anyline.reactnative;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.content.res.AssetManager;
|
|
5
|
-
import android.graphics.Bitmap;
|
|
6
|
-
import android.graphics.BitmapFactory;
|
|
7
|
-
import android.util.Log;
|
|
8
|
-
|
|
9
|
-
import org.json.JSONObject;
|
|
10
|
-
|
|
11
|
-
import java.io.IOException;
|
|
12
|
-
import java.io.InputStream;
|
|
13
|
-
|
|
14
|
-
@Deprecated
|
|
15
|
-
public class ImageTextConfig {
|
|
16
|
-
public String text = null;
|
|
17
|
-
public boolean hasImage = false;
|
|
18
|
-
public int imageResId = 0;
|
|
19
|
-
|
|
20
|
-
public ImageTextConfig(Context context, JSONObject jsonObject) {
|
|
21
|
-
if (jsonObject.has("text")) {
|
|
22
|
-
text = jsonObject.optString("text", "");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (jsonObject.has("image")) {
|
|
26
|
-
imageResId = context.getResources().getIdentifier(jsonObject.optString("image", ""),
|
|
27
|
-
"drawable",
|
|
28
|
-
context.getPackageName());
|
|
29
|
-
hasImage = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected Bitmap getBitmapFromAsset(Context context, String filePath) {
|
|
34
|
-
AssetManager assetManager = context.getAssets();
|
|
35
|
-
|
|
36
|
-
InputStream inputStream;
|
|
37
|
-
Bitmap bitmap = null;
|
|
38
|
-
try {
|
|
39
|
-
inputStream = assetManager.open(filePath);
|
|
40
|
-
bitmap = BitmapFactory.decodeStream(inputStream);
|
|
41
|
-
inputStream.close();
|
|
42
|
-
} catch (IOException e) {
|
|
43
|
-
Log.e("ImageTextConfig", e.getMessage());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return bitmap;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
package com.anyline.reactnative;
|
|
2
|
-
|
|
3
|
-
import org.json.JSONObject;
|
|
4
|
-
|
|
5
|
-
@Deprecated
|
|
6
|
-
public class InstructionConfig {
|
|
7
|
-
public String text = null;
|
|
8
|
-
public String textColor = null;
|
|
9
|
-
public String backgroundColor = null;
|
|
10
|
-
|
|
11
|
-
public InstructionConfig(JSONObject jsonObject) {
|
|
12
|
-
text = jsonObject.optString("text", "");
|
|
13
|
-
if (jsonObject.has("textColor")) {
|
|
14
|
-
textColor = jsonObject.optString("textColor", "");
|
|
15
|
-
}
|
|
16
|
-
if (jsonObject.has("backgroundColor")) {
|
|
17
|
-
backgroundColor = jsonObject.optString("backgroundColor", "");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
package com.anyline.reactnative;
|
|
2
|
-
|
|
3
|
-
import org.json.JSONObject;
|
|
4
|
-
|
|
5
|
-
public class Offset {
|
|
6
|
-
private int x;
|
|
7
|
-
private int y;
|
|
8
|
-
|
|
9
|
-
public Offset(JSONObject jsonObject) {
|
|
10
|
-
this.x = jsonObject.optInt("x", 0);
|
|
11
|
-
this.y = jsonObject.optInt("y", 0);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public int getX() {
|
|
15
|
-
return x;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public int getY() {
|
|
19
|
-
return y;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
package com.anyline.reactnative;
|
|
2
|
-
|
|
3
|
-
import org.json.JSONException;
|
|
4
|
-
import org.json.JSONObject;
|
|
5
|
-
|
|
6
|
-
public class RotateButtonConfig {
|
|
7
|
-
private String alignment = "";
|
|
8
|
-
private Offset offset = null;
|
|
9
|
-
|
|
10
|
-
public RotateButtonConfig(JSONObject jsonObject) {
|
|
11
|
-
alignment = jsonObject.optString("alignment", "");
|
|
12
|
-
if (jsonObject.has("offset")) {
|
|
13
|
-
try {
|
|
14
|
-
offset = new Offset(jsonObject.getJSONObject("offset"));
|
|
15
|
-
}
|
|
16
|
-
catch (JSONException e) {
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public String getAlignment() {
|
|
23
|
-
return alignment;
|
|
24
|
-
}
|
|
25
|
-
public Offset getOffset() {
|
|
26
|
-
return offset;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public boolean hasOffset() {
|
|
30
|
-
return offset != null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -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
|
-
}
|
package/android/src/main/java/com/anyline/reactnative/updateAsset/AnylineUpdateDelegateImpl.java
DELETED
|
@@ -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
|
-
}
|