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.
Files changed (51) hide show
  1. package/AnylineReact.podspec +1 -1
  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 +248 -254
  5. package/index.js +1 -15
  6. package/ios/AnylineSDKPlugin.h +4 -4
  7. package/ios/AnylineSDKPlugin.m +278 -211
  8. package/package.json +1 -1
  9. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  10. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  11. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  12. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  13. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  14. package/android/.gradle/7.6/gc.properties +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  17. package/android/.gradle/vcs-1/gc.properties +0 -0
  18. package/android/src/main/java/com/anyline/reactnative/FeedbackConfig.java +0 -59
  19. package/android/src/main/java/com/anyline/reactnative/ImageTextConfig.java +0 -49
  20. package/android/src/main/java/com/anyline/reactnative/InstructionConfig.java +0 -20
  21. package/android/src/main/java/com/anyline/reactnative/Offset.java +0 -21
  22. package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +0 -32
  23. package/android/src/main/java/com/anyline/reactnative/ScanActivity.java +0 -426
  24. package/android/src/main/java/com/anyline/reactnative/updateAsset/AnylineUpdateDelegateImpl.java +0 -50
  25. package/android/src/main/java/com/anyline/reactnative/updateAsset/AssetContextJsonParser.java +0 -28
  26. package/android/src/main/res/drawable/rotate_screen_background.xml +0 -18
  27. package/android/src/main/res/drawable/rotate_screen_white.png +0 -0
  28. package/android/src/main/res/drawable-hdpi/ic_flash_auto.png +0 -0
  29. package/android/src/main/res/drawable-hdpi/ic_flash_off.png +0 -0
  30. package/android/src/main/res/drawable-hdpi/ic_flash_on.png +0 -0
  31. package/android/src/main/res/drawable-mdpi/ic_flash_auto.png +0 -0
  32. package/android/src/main/res/drawable-mdpi/ic_flash_off.png +0 -0
  33. package/android/src/main/res/drawable-mdpi/ic_flash_on.png +0 -0
  34. package/android/src/main/res/drawable-xhdpi/ic_flash_auto.png +0 -0
  35. package/android/src/main/res/drawable-xhdpi/ic_flash_off.png +0 -0
  36. package/android/src/main/res/drawable-xhdpi/ic_flash_on.png +0 -0
  37. package/android/src/main/res/drawable-xxhdpi/ic_flash_auto.png +0 -0
  38. package/android/src/main/res/drawable-xxhdpi/ic_flash_off.png +0 -0
  39. package/android/src/main/res/drawable-xxhdpi/ic_flash_on.png +0 -0
  40. package/android/src/main/res/drawable-xxxhdpi/ic_flash_auto.png +0 -0
  41. package/android/src/main/res/drawable-xxxhdpi/ic_flash_off.png +0 -0
  42. package/android/src/main/res/drawable-xxxhdpi/ic_flash_on.png +0 -0
  43. package/android/src/main/res/layout/activity_scan.xml +0 -93
  44. package/ios/ALJsonUIConfiguration.h +0 -54
  45. package/ios/ALJsonUIConfiguration.m +0 -251
  46. package/ios/ALPluginHelper.h +0 -48
  47. package/ios/ALPluginHelper.m +0 -332
  48. package/ios/ALPluginScanViewController.h +0 -18
  49. package/ios/ALPluginScanViewController.m +0 -476
  50. package/ios/ALRoundedView.h +0 -25
  51. package/ios/ALRoundedView.m +0 -107
@@ -1,332 +0,0 @@
1
- #import "ALPluginHelper.h"
2
- #import "ALPluginScanViewController.h"
3
- #import <Anyline/Anyline.h>
4
- #import <objc/runtime.h>
5
-
6
- // Predefined domain for errors from most AppKit and Foundation APIs.
7
- NSErrorDomain const ALDefaultDomain = @"ALDefaultErrorDomain";
8
-
9
- @implementation ALPluginHelper
10
-
11
- #pragma mark - Launch Anyline
12
-
13
- + (void)startScan:(NSDictionary *)config initializationParamsStr:(NSString *)initializationParamsStr finished:(ALPluginCallback)callback {
14
-
15
- NSDictionary *pluginConf = config;
16
-
17
- NSString *licenseKey = [config objectForKey:@"licenseKey"];
18
-
19
- [[UIApplication sharedApplication] keyWindow].rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
20
-
21
- NSDictionary *optionsDict = [config objectForKey:@"options"];
22
- ALJSONUIConfiguration *jsonUIConf = [[ALJSONUIConfiguration alloc] initWithDictionary:optionsDict];
23
-
24
- ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:licenseKey
25
- configuration:pluginConf
26
- uiConfiguration:jsonUIConf
27
- initializationParamsStr:initializationParamsStr
28
- finished:callback];
29
-
30
- if ([pluginConf valueForKey:@"quality"]){
31
- pluginScanViewController.quality = [[pluginConf valueForKey:@"quality"] integerValue];
32
- }
33
-
34
- if (pluginScanViewController) {
35
- [pluginScanViewController setModalPresentationStyle:UIModalPresentationFullScreen];
36
- [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController
37
- animated:YES
38
- completion:nil];
39
- }
40
-
41
- }
42
-
43
- #pragma mark - Filesystem handling
44
-
45
- + (NSString *)saveImageToFileSystem:(UIImage *)image {
46
- return [self saveImageToFileSystem:image compressionQuality:0.9];
47
- }
48
-
49
- + (NSString *)saveImageToFileSystem:(UIImage *)image compressionQuality:(CGFloat)compressionQuality {
50
- NSString *basePath = [self applicationCachePath];
51
- NSData *binaryImageData = UIImageJPEGRepresentation(image, compressionQuality);
52
- NSString *uuid = [NSUUID UUID].UUIDString;
53
- NSString *imagePath = [NSString stringWithFormat:@"%@.jpg",uuid];
54
- NSString *fullPath = [basePath stringByAppendingPathComponent:imagePath];
55
- [binaryImageData writeToFile:fullPath atomically:YES];
56
- return fullPath;
57
- }
58
-
59
- + (NSString *)applicationCachePath {
60
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
61
- return ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
62
- }
63
-
64
- #pragma mark - UI helpers
65
-
66
- + (UILabel *)createLabelForView:(UIView *)view {
67
-
68
- UILabel *scannedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, 44)];
69
- scannedLabel.center = CGPointMake(view.center.x, view.center.y + 166);
70
- scannedLabel.alpha = 0.0;
71
- scannedLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:32];
72
- scannedLabel.textColor = [UIColor whiteColor];
73
- scannedLabel.numberOfLines = 0;
74
- scannedLabel.textAlignment = NSTextAlignmentCenter;
75
-
76
- [view addSubview:scannedLabel];
77
-
78
- return scannedLabel;
79
- }
80
-
81
- + (UISegmentedControl *)createSegmentForViewController:(UIViewController *)viewController
82
- config:(ALJSONUIConfiguration *)config
83
- initialScanMode:(NSString *)initialScanMode {
84
- UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:config.segmentTitles];
85
-
86
- // This doesn't appear to be changing the color
87
- // segment.tintColor = ...
88
-
89
- segment.backgroundColor = [UIColor colorWithWhite:1 alpha:0.6];
90
- if (@available(iOS 13.0, *)) {
91
- segment.selectedSegmentTintColor = config.segmentTintColor;
92
- }
93
-
94
- segment.hidden = YES;
95
-
96
- NSUInteger index = [config.segmentModes indexOfObject:initialScanMode];
97
- if (index == NSNotFound) {
98
- return nil;
99
- }
100
-
101
- [segment setSelectedSegmentIndex:index];
102
-
103
- // has a warning here but is okay as long as the target implements this selector.
104
- [segment addTarget:viewController action:@selector(segmentChange:) forControlEvents:UIControlEventValueChanged];
105
-
106
- [viewController.view addSubview:segment];
107
-
108
- return segment;
109
- }
110
-
111
- + (UIButton *)createButtonForViewController:(UIViewController *)viewController
112
- config:(ALJSONUIConfiguration *)config {
113
-
114
- UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
115
- [doneButton setTitle:config.buttonDoneTitle forState:UIControlStateNormal];
116
-
117
- // NOTE: there'll be a warning here from Xcode but just have to make sure
118
- // doneButtonPressed: is a valid selector in the target
119
- [doneButton addTarget:viewController action:@selector(doneButtonPressed:)
120
- forControlEvents:UIControlEventTouchUpInside];
121
-
122
- [viewController.view addSubview:doneButton];
123
-
124
- [ALPluginHelper updateButtonPosition:doneButton
125
- withConfiguration:config
126
- onView:viewController.view];
127
-
128
- return doneButton;
129
- }
130
-
131
- + (ALRoundedView *)createRoundedViewForViewController:(UIViewController *)viewController {
132
- ALRoundedView *roundedView = [[ALRoundedView alloc] initWithFrame:CGRectMake(20, 115, viewController.view.bounds.size.width - 40, 30)];
133
- roundedView.fillColor = [UIColor colorWithRed:98.0/255.0 green:39.0/255.0 blue:232.0/255.0 alpha:0.6];
134
- roundedView.textLabel.text = @"";
135
- roundedView.alpha = 0;
136
- [viewController.view addSubview:roundedView];
137
- return roundedView;
138
- }
139
-
140
- + (void)updateButtonPosition:(UIButton *)button withConfiguration:(ALJSONUIConfiguration *)config
141
- onView:(UIView *)view {
142
-
143
- button.titleLabel.font = [UIFont fontWithName:config.buttonDoneFontName size:config.buttonDoneFontSize];
144
- [button setTitleColor:config.buttonDoneTextColor forState:UIControlStateNormal];
145
- [button setTitleColor:config.buttonDoneTextColorHighlighted forState:UIControlStateHighlighted];
146
- button.contentEdgeInsets = UIEdgeInsetsMake(6, 10, 6, 10);
147
-
148
-
149
- button.backgroundColor = config.buttonDoneBackgroundColor;
150
- button.translatesAutoresizingMaskIntoConstraints = NO;
151
-
152
- // corner radius is overridden to 0 when "full-width" type is used
153
- button.layer.cornerRadius = config.buttonDoneCornerRadius;
154
-
155
- switch (config.buttonType) {
156
- case ALButtonTypeFullWidth: // "FULLWIDTH"
157
- [view addConstraint:[button.leftAnchor constraintEqualToAnchor:view.leftAnchor constant:0]];
158
- [view addConstraint:[button.rightAnchor constraintEqualToAnchor:view.rightAnchor constant:0]];
159
- button.layer.cornerRadius = 0;
160
- break;
161
- case ALButtonTypeRect: // "RECT"
162
- [button sizeToFit];
163
- break;
164
-
165
- default:
166
- break;
167
- }
168
-
169
- switch (config.buttonDoneXAlignment) {
170
- case ALButtonXAlignmentCenter:
171
- [view addConstraint:[NSLayoutConstraint constraintWithItem:button
172
- attribute:NSLayoutAttributeCenterX
173
- relatedBy:NSLayoutRelationEqual
174
- toItem:view
175
- attribute:NSLayoutAttributeCenterX
176
- multiplier:1.0
177
- constant:config.buttonDoneXPositionOffset]];
178
- break;
179
- case ALButtonXAlignmentLeft:
180
- [view addConstraint:[NSLayoutConstraint constraintWithItem:button
181
- attribute:NSLayoutAttributeLeft
182
- relatedBy:NSLayoutRelationEqual
183
- toItem:view
184
- attribute:NSLayoutAttributeLeft
185
- multiplier:1.0
186
- constant:MAX(config.buttonDoneXPositionOffset, 0)]];
187
- break;
188
- case ALButtonXAlignmentRight:
189
- [view addConstraint:[NSLayoutConstraint constraintWithItem:button
190
- attribute:NSLayoutAttributeRight
191
- relatedBy:NSLayoutRelationEqual
192
- toItem:view
193
- attribute:NSLayoutAttributeRight
194
- multiplier:1.0
195
- constant:MIN(config.buttonDoneXPositionOffset, 0)]];
196
- break;
197
-
198
- default:
199
- break;
200
- }
201
-
202
- switch (config.buttonDoneYAlignment) {
203
- case ALButtonYAlignmentTop:
204
- // Align Top
205
- [view addConstraint:[NSLayoutConstraint constraintWithItem:button
206
- attribute:NSLayoutAttributeTop
207
- relatedBy:NSLayoutRelationEqual
208
- toItem:view
209
- attribute:NSLayoutAttributeTop
210
- multiplier:1.0
211
- constant:MAX(config.buttonDoneYPositionOffset, 0)]];
212
- break;
213
- case ALButtonYAlignmentBottom:
214
- // Align Bottom
215
- [view addConstraint:[NSLayoutConstraint constraintWithItem:button
216
- attribute:NSLayoutAttributeBottom
217
- relatedBy:NSLayoutRelationEqual
218
- toItem:view
219
- attribute:NSLayoutAttributeBottom
220
- multiplier:1.0
221
- constant:MIN(config.buttonDoneYPositionOffset, 0)]];
222
-
223
- break;
224
- case ALButtonYAlignmentCenter:
225
- // Center vertically
226
- [view addConstraint:
227
- [button.centerYAnchor constraintEqualToAnchor:view.centerYAnchor constant:config.buttonDoneYPositionOffset]
228
- ];
229
- break;
230
-
231
- default:
232
- break;
233
- }
234
- }
235
-
236
- #pragma mark - Date Parsing Utils
237
-
238
- // MARK: Utilities
239
-
240
- + (void)showErrorAlertWithTitle:(NSString *)title
241
- message:(NSString *)message
242
- presentingViewController:(UIViewController *)presentingViewController {
243
-
244
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
245
- message:message
246
- preferredStyle:UIAlertControllerStyleAlert];
247
- UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil];
248
- [alertController addAction:dismissAction];
249
- [presentingViewController presentViewController:alertController animated:YES completion:nil];
250
- }
251
-
252
- + (BOOL)showErrorAlertIfNeeded:(NSError *)error pluginCallback:(ALPluginCallback)callback {
253
- if (!error) {
254
- return NO;
255
- }
256
-
257
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Could not start scanning"
258
- message:error.localizedDescription
259
- preferredStyle:UIAlertControllerStyleAlert];
260
-
261
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok"
262
- style:UIAlertActionStyleDefault
263
- handler:^(UIAlertAction * _Nonnull action) {
264
-
265
- [[UIApplication sharedApplication].keyWindow.rootViewController
266
- dismissViewControllerAnimated:YES completion:^{
267
- callback(nil, [NSError errorWithDomain:@"" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Canceled"}]);
268
- }];
269
- }];
270
-
271
- [alert addAction:action];
272
- [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert
273
- animated:YES
274
- completion:NULL];
275
- return YES;
276
- }
277
-
278
- + (NSError *)errorWithMessage:(NSString *)message {
279
- return [NSError errorWithDomain:ALDefaultDomain code:1000 userInfo:@{ NSLocalizedDescriptionKey: message }];
280
- }
281
-
282
- // MARK: - Date Utils
283
- + (NSString *)stringForDate:(NSDate *)date {
284
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
285
- [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0:00"]];
286
- dateFormatter.dateStyle = NSDateFormatterMediumStyle;
287
- dateFormatter.timeStyle = NSDateFormatterNoStyle;
288
- return [dateFormatter stringFromDate:date];
289
- }
290
-
291
- // MARK: - Plugin Reflection
292
-
293
- // return the ALPluginConfig property whose name ends with 'Config', is nonnull, AND which has a `scanMode` property
294
- + (NSString * _Nullable)confPropKeyWithScanModeForPluginConfig:(ALPluginConfig *)pluginConfig {
295
- unsigned int count;
296
- Ivar *ivars = class_copyIvarList(ALPluginConfig.class, &count);
297
- if (!ivars) {
298
- return nil;
299
- }
300
- for (int i = 0; i < count; i++) {
301
- const char *ivarName = ivar_getName(ivars[i]);
302
- NSString *key = [NSString stringWithCString:(const char * _Nonnull)ivarName encoding:NSUTF8StringEncoding];
303
- key = [key stringByTrimmingCharactersInSet:NSCharacterSet.punctuationCharacterSet];
304
-
305
- // Looking for "Config" at the end of the property name.
306
- NSRange range = [key rangeOfString:@"Config"];
307
- if (range.location == NSNotFound) { continue; }
308
- if (range.location + @"Config".length == key.length) {
309
- id obj;
310
- if ((obj = [pluginConfig valueForKey:key])) { // config property is non-null
311
- // one last check: does the value associated with this key have a scanMode property (that is a string type)?
312
- if ([obj respondsToSelector:NSSelectorFromString(@"scanMode")]) {
313
- return key; // this key is valid for self.pluginConfig, obj is the object tied to this key
314
- }
315
- // the rest wouldn't meet the requirements, so don't bother with them.
316
- return nil;
317
- }
318
- }
319
- }
320
- free(ivars);
321
- return nil;
322
- }
323
-
324
- // MARK: - Miscellaneous
325
-
326
- // actual implementation are in the view controllers
327
- - (void)segmentChange:(id)segment {}
328
-
329
- - (void)doneButtonPressed:(id)doneButton {}
330
-
331
-
332
- @end
@@ -1,18 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
- #import "ALPluginHelper.h"
3
-
4
- NS_ASSUME_NONNULL_BEGIN
5
-
6
- @interface ALPluginScanViewController : UIViewController
7
-
8
- @property (nonatomic, assign) NSUInteger quality;
9
-
10
- - (instancetype)initWithLicensekey:(NSString *)licenseKey
11
- configuration:(NSDictionary *)config
12
- uiConfiguration:(ALJSONUIConfiguration *)JSONUIConfig
13
- initializationParamsStr:(NSString *)initializationParamsStr
14
- finished:(ALPluginCallback)callback;
15
-
16
- @end
17
-
18
- NS_ASSUME_NONNULL_END