anyline-ocr-react-native-module 42.2.0 → 43.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.
Files changed (51) hide show
  1. package/android/build.gradle +7 -3
  2. package/android/src/main/AndroidManifest.xml +9 -8
  3. package/android/src/main/assets/cow_tag_scanner.ale +46 -0
  4. package/android/src/main/java/com/anyline/reactnative/AnylinePackage.java +1 -2
  5. package/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +25 -71
  6. package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +12 -2
  7. package/android/src/main/java/com/anyline/reactnative/ScanActivity.java +206 -0
  8. package/android/src/main/res/drawable/rotate_screen_background.xml +18 -0
  9. package/android/src/main/res/drawable/rotate_screen_white.png +0 -0
  10. package/android/src/main/res/layout/activity_scan.xml +27 -0
  11. package/android/src/main/res/values/anyline_sdk_plugin_strings.xml +2 -28
  12. package/ios/ALJsonUIConfiguration.h +29 -36
  13. package/ios/ALJsonUIConfiguration.m +136 -76
  14. package/ios/ALNFCScanViewController.h +3 -16
  15. package/ios/ALNFCScanViewController.m +361 -232
  16. package/ios/ALPluginHelper.h +19 -62
  17. package/ios/ALPluginHelper.m +208 -529
  18. package/ios/ALPluginScanViewController.h +5 -32
  19. package/ios/ALPluginScanViewController.m +339 -287
  20. package/ios/AnylineReact.podspec +4 -3
  21. package/ios/AnylineSDKPlugin.m +39 -82
  22. package/package.json +8 -8
  23. package/android/.gradle/6.7/executionHistory/executionHistory.lock +0 -0
  24. package/android/.gradle/6.7/fileChanges/last-build.bin +0 -0
  25. package/android/.gradle/6.7/fileHashes/fileHashes.bin +0 -0
  26. package/android/.gradle/6.7/fileHashes/fileHashes.lock +0 -0
  27. package/android/.gradle/6.7/gc.properties +0 -0
  28. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  29. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  30. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  31. package/android/.gradle/checksums/checksums.lock +0 -0
  32. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  33. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  34. package/android/.gradle/configuration-cache/gc.properties +0 -0
  35. package/android/.gradle/vcs-1/gc.properties +0 -0
  36. package/android/.idea/compiler.xml +0 -6
  37. package/android/.idea/gradle.xml +0 -18
  38. package/android/.idea/jarRepositories.xml +0 -35
  39. package/android/.idea/misc.xml +0 -10
  40. package/android/.idea/vcs.xml +0 -6
  41. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  42. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  43. package/android/local.properties +0 -8
  44. package/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java +0 -621
  45. package/android/src/main/java/com/anyline/reactnative/AnylineBaseActivity.java +0 -267
  46. package/android/src/main/java/com/anyline/reactnative/AnylinePluginHelper.java +0 -324
  47. package/android/src/main/java/com/anyline/reactnative/AnylineUIConfig.java +0 -88
  48. package/android/src/main/java/com/anyline/reactnative/Document4Activity.java +0 -595
  49. package/android/src/main/res/layout/activity_scan_document.xml +0 -63
  50. package/android/src/main/res/layout/activity_scan_scanview.xml +0 -52
  51. package/android/src/main/res/values/com_crashlytics_export_strings.xml +0 -10
@@ -3,7 +3,7 @@ apply plugin: "com.android.library"
3
3
  buildscript {
4
4
  repositories {
5
5
  google()
6
- jcenter()
6
+ mavenCentral()
7
7
  }
8
8
  dependencies {
9
9
  classpath 'com.android.tools.build:gradle:4.1.3'
@@ -13,7 +13,7 @@ buildscript {
13
13
  allprojects {
14
14
  repositories {
15
15
  google()
16
- jcenter()
16
+ mavenCentral()
17
17
  }
18
18
  }
19
19
 
@@ -52,6 +52,10 @@ android {
52
52
  targetCompatibility JavaVersion.VERSION_1_8
53
53
  }
54
54
 
55
+ buildFeatures {
56
+ viewBinding true
57
+ dataBinding true
58
+ }
55
59
  }
56
60
 
57
61
  repositories {
@@ -65,7 +69,7 @@ repositories {
65
69
 
66
70
  dependencies {
67
71
  implementation fileTree(dir: "libs", include: ["*.jar"])
68
- implementation 'io.anyline:anylinesdk:42.2.0'
72
+ implementation 'io.anyline:anylinesdk:43.1.0'
69
73
  implementation "com.facebook.react:react-native:+" // from node_modules
70
74
  implementation("com.google.android.material:material:1.4.0-rc01")
71
75
  implementation 'androidx.multidex:multidex:2.0.1'
@@ -1,13 +1,14 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.anyline.reactnative">
3
+ package="com.anyline.reactnative">
4
4
 
5
- <uses-permission android:name="android.permission.INTERNET"/>
6
- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
7
- <uses-permission android:name="android.permission.CAMERA"/>
5
+ <uses-permission android:name="android.permission.INTERNET" />
6
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
7
+ <uses-permission android:name="android.permission.CAMERA" />
8
8
 
9
- <application android:allowBackup="true">
10
- <activity android:name="com.anyline.reactnative.Anyline4Activity" android:screenOrientation="portrait"/>
11
- <activity android:name="com.anyline.reactnative.Document4Activity" android:screenOrientation="portrait"/>
12
- </application>
9
+ <application android:allowBackup="true">
10
+ <activity
11
+ android:name=".ScanActivity"
12
+ android:screenOrientation="portrait" />
13
+ </application>
13
14
  </manifest>
@@ -0,0 +1,46 @@
1
+ {
2
+ "cameraConfig": {
3
+ "captureResolution": "1080p"
4
+ },
5
+ "flashConfig": {
6
+ "mode": "auto",
7
+ "alignment": "bottom_right"
8
+ },
9
+ "viewPluginConfig": {
10
+ "pluginConfig": {
11
+ "id": "Barcode|Barcodes",
12
+ "barcodeConfig": {
13
+ "barcodeFormats": [
14
+ "ALL"
15
+ ],
16
+ "parseAAMVA": true
17
+ },
18
+ "cancelOnResult": false
19
+ },
20
+ "cutoutConfig": {
21
+ "style": "rect",
22
+ "maxWidthPercent": "80%",
23
+ "maxHeightPercent": "80%",
24
+ "alignment": "center",
25
+ "ratioFromSize": {
26
+ "width": 100,
27
+ "height": 80
28
+ },
29
+ "strokeWidth": 1,
30
+ "cornerRadius": 3,
31
+ "strokeColor": "FFFFFF",
32
+ "outerColor": "000000",
33
+ "outerAlpha": 0.3,
34
+ "feedbackStrokeColor": "0099FF"
35
+ },
36
+ "scanFeedbackConfig": {
37
+ "style": "rect",
38
+ "strokeColor": "0099FF",
39
+ "fillColor": "220099FF",
40
+ "animationDuration": 150,
41
+ "blinkAnimationOnResult": true,
42
+ "beepOnResult": true,
43
+ "vibrateOnResult": true
44
+ }
45
+ }
46
+ }
@@ -22,8 +22,7 @@ public class AnylinePackage implements ReactPackage {
22
22
  }
23
23
 
24
24
  @Override
25
- public List<NativeModule> createNativeModules(
26
- ReactApplicationContext reactContext) {
25
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
27
26
  List<NativeModule> modules = new ArrayList<>();
28
27
  modules.add(new AnylineSDKPlugin(reactContext));
29
28
  return modules;
@@ -4,12 +4,10 @@ package com.anyline.reactnative;
4
4
  * Created by jonesBoi on 02.12.16.
5
5
  */
6
6
 
7
- import android.app.Activity;
8
7
  import android.content.Intent;
9
8
 
10
9
  import com.anyline.reactnative.updateAsset.AnylineUpdateDelegateImpl;
11
10
  import com.anyline.reactnative.updateAsset.AssetContextJsonParser;
12
- import com.facebook.react.ReactInstanceManager;
13
11
  import com.facebook.react.bridge.Callback;
14
12
  import com.facebook.react.bridge.Promise;
15
13
  import com.facebook.react.bridge.ReactApplicationContext;
@@ -19,13 +17,12 @@ import com.facebook.react.bridge.ReactMethod;
19
17
  import org.json.JSONException;
20
18
  import org.json.JSONObject;
21
19
 
22
- import at.nineyards.anyline.core.LicenseException;
23
- import io.anyline.AnylineSDK;
24
20
  import io.anyline.plugin.ScanResult;
25
21
  import io.anyline.products.AnylineUpdater;
26
- import io.anyline.products.IAnylineUpdateDelegate;
27
22
  import io.anyline.trainer.AssetContext;
28
23
  import io.anyline.trainer.TrainerUtils;
24
+ import io.anyline2.AnylineSdk;
25
+ import io.anyline2.core.LicenseException;
29
26
 
30
27
  class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultReporter.OnResultListener {
31
28
 
@@ -40,18 +37,6 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
40
37
  public static final int RESULT_CANCELED = 0;
41
38
  public static final int RESULT_OK = 1;
42
39
  public static final int RESULT_ERROR = 2;
43
- public static final int DIGITAL_METER = 3;
44
- public static final int ANALOG_METER = 4;
45
- public static final int AUTO_ANALOG_DIGITAL_METER = 5;
46
- public static final int ANYLINE_OCR = 6;
47
- public static final int BARCODE = 7;
48
- public static final int ANYLINE_MRZ = 8;
49
- public static final int ANYLINE_DOCUMENT = 9;
50
- public static final int DIAL_METER = 10;
51
- public static final int LICENSE_PLATE = 11;
52
- public static final int SERIAL_NUMBER = 12;
53
- public static final int DOT_MATRIX_METER = 13;
54
- public static final int REQUEST_ANYLINE_4 = 14;
55
40
  private static final String E_ERROR = "E_ERROR";
56
41
  private JSONObject configObject;
57
42
  private ReactApplicationContext reactContext;
@@ -60,10 +45,8 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
60
45
  private Callback onResultCallback;
61
46
  private Callback onErrorCallback;
62
47
  private Promise promise;
63
- private ReactInstanceManager mReactInstanceManager;
64
48
  private String returnMethod;
65
49
  private String config;
66
- private IAnylineUpdateDelegate anylineUpdateDelegate;
67
50
  private AssetContextJsonParser assetContextJsonParser;
68
51
 
69
52
  AnylineSDKPlugin(ReactApplicationContext context) {
@@ -117,22 +100,9 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
117
100
  @ReactMethod
118
101
  public void initSdk(String license) {
119
102
  try {
120
- AnylineSDK.init(license, reactContext);
103
+ AnylineSdk.init(license, reactContext);
121
104
  } catch (LicenseException e) {
122
- finishWithError("error_license_init", "string");
123
- }
124
- }
125
-
126
- protected void finishWithError(String identifier, String type) {
127
- Activity activity = getCurrentActivity();
128
-
129
- if (activity != null) {
130
- String errorMessage = activity.getString(activity.getResources().getIdentifier(identifier, type, activity.getPackageName()));
131
- Intent data = new Intent();
132
- data.putExtra(AnylineSDKPlugin.EXTRA_ERROR_MESSAGE, errorMessage);
133
- activity.setResult(AnylineSDKPlugin.RESULT_ERROR, data);
134
- ResultReporter.onError(errorMessage);
135
- activity.finish();
105
+ e.printStackTrace();
136
106
  }
137
107
  }
138
108
 
@@ -190,21 +160,9 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
190
160
  private void scanAnyline4() {
191
161
  try {
192
162
  configObject = new JSONObject(this.config);
193
- JSONObject options = configObject.getJSONObject("options");
194
- if (options.has("viewPlugin")) {
195
- JSONObject viewPlugin = options.getJSONObject("viewPlugin");
196
- if (viewPlugin != null && viewPlugin.has("plugin")) {
197
- JSONObject plugin = viewPlugin.getJSONObject("plugin");
198
- if (plugin != null && plugin.has("documentPlugin")) {
199
- scan(Document4Activity.class, null, REQUEST_ANYLINE_4);
200
- } else {
201
- scan(Anyline4Activity.class, null, REQUEST_ANYLINE_4);
202
- }
203
- } else {
204
- returnError("No Plugin in config. Please check your configuration.");
205
- }
206
- } else if (options.has("serialViewPluginComposite") || options.has("parallelViewPluginComposite")) {
207
- scan(Anyline4Activity.class, null, REQUEST_ANYLINE_4);
163
+ // JSONObject options = configObject;
164
+ if (configObject != null) {
165
+ scan();
208
166
  } else {
209
167
  returnError("No ViewPlugin in config. Please check your configuration.");
210
168
  }
@@ -213,20 +171,21 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
213
171
  }
214
172
  }
215
173
 
216
- private void scan(Class<?> activityToStart, String scanMode, int requestCode) {
174
+ private void scan() {
217
175
 
218
- Intent intent = new Intent(getCurrentActivity(), activityToStart);
176
+ Intent intent = new Intent(getCurrentActivity(), ScanActivity.class);
219
177
 
220
178
  try {
221
179
  configObject = new JSONObject(this.config);
222
180
 
223
- // Hacky -> force cancelOnResult = true
224
- options = configObject.getJSONObject("options");
225
- options.put("cancelOnResult", true);
226
-
227
181
  license = configObject.get("license").toString();
228
- if (configObject.has("nativeBarcodeEnabled")) {
229
- intent.putExtra(EXTRA_ENABLE_BARCODE_SCANNING, configObject.getBoolean("nativeBarcodeEnabled"));
182
+ JSONObject optionsJSONObject = configObject.optJSONObject("options");
183
+
184
+ if (optionsJSONObject != null) {
185
+ intent.putExtra(
186
+ EXTRA_ENABLE_BARCODE_SCANNING,
187
+ optionsJSONObject.optBoolean("nativeBarcodeEnabled", false)
188
+ );
230
189
  }
231
190
 
232
191
  } catch (JSONException e) {
@@ -234,24 +193,19 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
234
193
  }
235
194
 
236
195
  intent.putExtra(EXTRA_LICENSE_KEY, license);
237
- intent.putExtra(EXTRA_CONFIG_JSON, options.toString());
238
-
239
- // Check if OCR
240
- if (configObject.has("ocr")) {
241
- try {
242
- intent.putExtra(EXTRA_OCR_CONFIG_JSON, configObject.get("ocr").toString());
243
- } catch (JSONException e) {
244
- returnError(e.getMessage());
245
- }
246
- }
196
+ intent.putExtra(EXTRA_CONFIG_JSON, configObject.toString());
247
197
 
248
- if (scanMode != null) {
249
- intent.putExtra(EXTRA_SCAN_MODE, scanMode);
250
- }
251
198
  ResultReporter.setListener(this);
252
199
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
253
200
 
254
- reactContext.startActivityForResult(intent, requestCode, intent.getExtras());
201
+ try {
202
+ AnylineSdk.init(configObject.getString("license"), reactContext);
203
+ } catch (LicenseException e) {
204
+ e.printStackTrace();
205
+ } catch (JSONException e) {
206
+ e.printStackTrace();
207
+ }
208
+ reactContext.startActivityForResult(intent, 1111, intent.getExtras());
255
209
  }
256
210
 
257
211
  @Override
@@ -4,14 +4,24 @@ import org.json.JSONException;
4
4
  import org.json.JSONObject;
5
5
 
6
6
  public class RotateButtonConfig {
7
+ private String alignment = "";
7
8
  private Offset offset = null;
8
9
 
9
- public RotateButtonConfig(JSONObject jsonObject) throws JSONException {
10
+ public RotateButtonConfig(JSONObject jsonObject) {
11
+ alignment = jsonObject.optString("alignment", "");
10
12
  if (jsonObject.has("offset")) {
11
- offset = new Offset(jsonObject.getJSONObject("offset"));
13
+ try {
14
+ offset = new Offset(jsonObject.getJSONObject("offset"));
15
+ }
16
+ catch (JSONException e) {
17
+
18
+ }
12
19
  }
13
20
  }
14
21
 
22
+ public String getAlignment() {
23
+ return alignment;
24
+ }
15
25
  public Offset getOffset() {
16
26
  return offset;
17
27
  }
@@ -0,0 +1,206 @@
1
+ package com.anyline.reactnative;
2
+
3
+ import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_CONFIG_JSON;
4
+ import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_ERROR_MESSAGE;
5
+ import static com.anyline.reactnative.AnylineSDKPlugin.RESULT_ERROR;
6
+
7
+ import android.content.Intent;
8
+ import android.content.pm.ActivityInfo;
9
+ import android.os.Bundle;
10
+ import android.view.Gravity;
11
+ import android.view.View;
12
+
13
+ import androidx.annotation.NonNull;
14
+ import androidx.annotation.Nullable;
15
+ import androidx.appcompat.app.AppCompatActivity;
16
+ import androidx.coordinatorlayout.widget.CoordinatorLayout;
17
+
18
+ import com.anyline.reactnative.databinding.ActivityScanBinding;
19
+
20
+ import org.json.JSONArray;
21
+ import org.json.JSONException;
22
+ import org.json.JSONObject;
23
+
24
+ import io.anyline2.ScanResult;
25
+ import io.anyline2.view.ScanView;
26
+ import io.anyline2.viewplugin.ViewPluginBase;
27
+
28
+ public class ScanActivity extends AppCompatActivity {
29
+
30
+ private static final String KEY_DEFAULT_ORIENTATION_APPLIED = "default_orientation_applied";
31
+
32
+ private ActivityScanBinding binding;
33
+ private ScanView scanView;
34
+
35
+ private float dpFactor = 0;
36
+ private boolean defaultOrientationApplied;
37
+ private int orientation;
38
+
39
+ @Override
40
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
41
+ super.onCreate(savedInstanceState);
42
+ binding = ActivityScanBinding.inflate(getLayoutInflater());
43
+ setContentView(binding.getRoot());
44
+
45
+ dpFactor = getResources().getDisplayMetrics().density;
46
+
47
+ orientation = this.getResources().getConfiguration().orientation;
48
+
49
+ scanView = binding.scanView;
50
+
51
+ if (savedInstanceState != null) {
52
+ defaultOrientationApplied = savedInstanceState.getBoolean(KEY_DEFAULT_ORIENTATION_APPLIED);
53
+ }
54
+
55
+ if (getIntent().hasExtra(EXTRA_CONFIG_JSON)) {
56
+ // TODO check for throws clauses
57
+ try {
58
+ JSONObject configJSON = new JSONObject(getIntent().getStringExtra(EXTRA_CONFIG_JSON));
59
+
60
+ applyDefaultOrientation(configJSON);
61
+ setupChangeOrientationButton(configJSON);
62
+
63
+ scanView.init(configJSON);
64
+
65
+ ViewPluginBase viewPluginBase = scanView.getScanViewPlugin();
66
+
67
+ viewPluginBase.resultReceived = scanResult -> {
68
+ setResult(AnylineSDKPlugin.RESULT_OK);
69
+ JSONObject resultObject = getResultWithImagePath(scanResult);
70
+ ResultReporter.onResult(resultObject.toString(), true);
71
+ finish();
72
+ };
73
+
74
+ viewPluginBase.resultsReceived = scanResults -> {
75
+ JSONArray resultJSONArray = new JSONArray();
76
+
77
+ for (ScanResult scanResult : scanResults) {
78
+ JSONObject resultObject = getResultWithImagePath(scanResult);
79
+ resultJSONArray.put(resultObject);
80
+ }
81
+ setResult(AnylineSDKPlugin.RESULT_OK);
82
+ ResultReporter.onResult(resultJSONArray.toString(), true);
83
+ finish();
84
+ };
85
+ } catch (JSONException e) {
86
+ finishWithError("Error parsing view config: " + e.getMessage());
87
+ }
88
+ } else {
89
+ finishWithError("View config not found");
90
+ }
91
+ }
92
+
93
+ private void applyDefaultOrientation(JSONObject configJSON) {
94
+ if (defaultOrientationApplied) return;
95
+
96
+ JSONObject optionsJsonObject = configJSON.optJSONObject("options");
97
+
98
+ if (optionsJsonObject != null) {
99
+ String defaultOrientationJsonString = optionsJsonObject.optString("defaultOrientation", "");
100
+
101
+ if ("portrait".equals(defaultOrientationJsonString)) {
102
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
103
+ } else if ("landscape".equals(defaultOrientationJsonString)) {
104
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
105
+ }
106
+ }
107
+ defaultOrientationApplied = true;
108
+ }
109
+
110
+ private void setupChangeOrientationButton(JSONObject configJSON) {
111
+ binding.layoutChangeOrientation.setVisibility(View.GONE);
112
+ JSONObject optionsJsonObject = configJSON.optJSONObject("options");
113
+
114
+ if (optionsJsonObject != null) {
115
+
116
+ JSONObject rotateButtonJson = optionsJsonObject.optJSONObject("rotateButton");
117
+ if (rotateButtonJson != null) {
118
+ RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(rotateButtonJson);
119
+
120
+ CoordinatorLayout.LayoutParams buttonLayoutParams = new CoordinatorLayout.LayoutParams(
121
+ CoordinatorLayout.LayoutParams.WRAP_CONTENT,
122
+ CoordinatorLayout.LayoutParams.WRAP_CONTENT);
123
+
124
+ buttonLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
125
+ String alignment = rotateButtonConfig.getAlignment();
126
+ if (alignment.length() > 0) {
127
+ if (alignment.equals("top_left")) {
128
+ buttonLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
129
+ }
130
+ if (alignment.equals("top_right")) {
131
+ buttonLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
132
+ }
133
+ if (alignment.equals("bottom_left")) {
134
+ buttonLayoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
135
+ }
136
+ if (alignment.equals("bottom_right")) {
137
+ buttonLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
138
+ }
139
+ }
140
+ if (rotateButtonConfig.hasOffset()) {
141
+ buttonLayoutParams.setMargins(rotateButtonConfig.getOffset().getX(), rotateButtonConfig.getOffset().getY(), 0, 0);
142
+ }
143
+ binding.layoutChangeOrientation.setLayoutParams(buttonLayoutParams);
144
+ binding.layoutChangeOrientation.requestLayout();
145
+
146
+ binding.layoutChangeOrientation.setVisibility(View.VISIBLE);
147
+ binding.imageviewChangeOrientation.setOnClickListener(v -> {
148
+ if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
149
+ orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
150
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
151
+ } else {
152
+ orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
153
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
154
+ }
155
+ });
156
+ }
157
+ }
158
+ }
159
+
160
+ @NonNull
161
+ private JSONObject getResultWithImagePath(ScanResult scanResult) {
162
+ JSONObject resultObject = scanResult.getResult();
163
+
164
+ try {
165
+ String fullImagePath = scanResult.getImage().save();
166
+ String cutoutImagePath = scanResult.getCutoutImage().save();
167
+ resultObject.put("fullImagePath", fullImagePath);
168
+ resultObject.put("imagePath", cutoutImagePath);
169
+ } catch (Exception e) {
170
+ e.printStackTrace();
171
+ }
172
+ return resultObject;
173
+ }
174
+
175
+ private void finishWithError(String errorMessage) {
176
+ Intent intent = new Intent();
177
+ intent.putExtra(EXTRA_ERROR_MESSAGE, errorMessage);
178
+ setResult(RESULT_ERROR, intent);
179
+ finish();
180
+ }
181
+
182
+ @Override
183
+ protected void onSaveInstanceState(Bundle outState) {
184
+ super.onSaveInstanceState(outState);
185
+ outState.putBoolean(KEY_DEFAULT_ORIENTATION_APPLIED, defaultOrientationApplied);
186
+ }
187
+
188
+ @Override
189
+ protected void onResume() {
190
+ super.onResume();
191
+ scanView.start();
192
+ }
193
+
194
+ @Override
195
+ protected void onPause() {
196
+ scanView.stop();
197
+ scanView.getCameraView().releaseCameraInBackground();
198
+ super.onPause();
199
+ }
200
+
201
+ @Override
202
+ public void onBackPressed() {
203
+ ResultReporter.onCancel();
204
+ super.onBackPressed();
205
+ }
206
+ }
@@ -0,0 +1,18 @@
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>
@@ -0,0 +1,27 @@
1
+ <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+ xmlns:app="http://schemas.android.com/apk/res-auto"
3
+ android:layout_width="match_parent"
4
+ android:layout_height="match_parent">
5
+
6
+ <io.anyline2.view.ScanView
7
+ android:id="@+id/scan_view"
8
+ android:layout_width="match_parent"
9
+ android:layout_height="match_parent"
10
+ app:api_2_enabled="false" />
11
+
12
+ <LinearLayout
13
+ android:id="@+id/layout_change_orientation"
14
+ android:layout_width="wrap_content"
15
+ android:layout_height="wrap_content"
16
+ android:layout_gravity="right|top"
17
+ android:gravity="center"
18
+ android:padding="40px">
19
+ <ImageView
20
+ android:id="@+id/imageview_change_orientation"
21
+ android:layout_width="40dp"
22
+ android:layout_height="40dp"
23
+ android:scaleType="fitStart"
24
+ android:background="@drawable/rotate_screen_background"
25
+ android:src="@drawable/rotate_screen_white" />
26
+ </LinearLayout>
27
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -1,34 +1,8 @@
1
1
  <resources>
2
- <string name="error_unkown_scan_mode">Unkown scan mode: </string>
2
+ <string name="error_unknown_scan_mode">Unknown scan mode: </string>
3
3
  <string name="error_invalid_json_data">Config json is invalid.</string>
4
4
  <string name="error_invalid_segment_config">Semgent config not valid. Must have equal amount of titles and modes.</string>
5
5
  <string name="error_accessing_camera">Error while accessing camera.</string>
6
6
  <string name="error_licence_invalid">Error: Anyline license invalid.</string>
7
- <string name="error_occured">An error occured.</string>
8
-
9
- <string name="document_advanced_outline_detection">Advanced Outline Detection</string>
10
- <string name="document_fast_outline_detection">Fast Outline Detection</string>
11
- <string name="document_error_not_sharp">Document is not sharp. Please hold the camera steadily and ensure the document is in focus</string>
12
- <string name="document_error_skew_too_high">Document is skewed. Place the camera directly above the document</string>
13
- <string name="document_error_outline_not_found">Could not detect document outline</string>
14
-
15
- <string name="document_error_glare_detected">Please remove the glare</string>
16
- <string name="document_error_too_dark">The image is too dark. Please ensure there is enough light</string>
17
- <string name="document_error_unknown">Unknown Failure</string>
18
- <string name="document_picture_error">Error scanning full document:\n</string>
19
- <string name="document_preview_success">Scanning full document. Please hold still</string>
20
- <string name="document_picture_success">Document scanned successfully</string>
21
- <string name="document_using_fast_mode">Switched to fast detection mode</string>
22
- <string name="document_using_advanced_mode">Switched to advanced detection mode</string>
23
- <string name="document_processing_picture_header">Processing</string>
24
- <string name="document_processing_picture">Processing the Picture. Please wait</string>
25
- <string name="document_error_shake">Shake detected</string>
26
- <string name="document_error_closer">Come closer</string>
27
- <string name="document_error_format">Unrecognised format</string>
28
- <string name="document_image_saved_to">Image saved to</string>
29
-
30
- <string name="document_processing">Processing</string>
31
- <string name="document_processing_picture_please_wait">Processing the picture. Please wait.</string>
32
-
33
-
7
+ <string name="error_occurred">An error occurred.</string>
34
8
  </resources>