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,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
@@ -1,476 +0,0 @@
1
- #import <Anyline/Anyline.h>
2
-
3
- #import "ALPluginScanViewController.h"
4
- #import "ALPluginHelper.h"
5
- #import "ALRoundedView.h"
6
- #import "AnylineSDKPlugin.h"
7
-
8
- @interface ALPluginScanViewController () <ALScanPluginDelegate, ALViewPluginCompositeDelegate, ALScanViewDelegate>
9
-
10
- // ACO should it have the `assign` attribute?
11
- @property (nonatomic, strong) ALPluginCallback callback;
12
-
13
- @property (nonatomic, strong) NSDictionary *config;
14
-
15
- @property (nonatomic, copy) NSString *licenseKey;
16
-
17
- @property (nonatomic, strong) ALJSONUIConfiguration *uiConfig;
18
-
19
- @property (nonatomic, strong) ALScanView *scanView;
20
-
21
- @property (nonatomic, strong) UIButton *doneButton;
22
-
23
- @property (nonatomic, strong) UILabel *scannedLabel;
24
-
25
- @property (nonatomic, strong) ALRoundedView *roundedView;
26
-
27
- @property (nonatomic, strong) UISegmentedControl *segment;
28
-
29
- @property (nonatomic, strong) NSMutableArray<NSDictionary *> *detectedBarcodes;
30
-
31
- @property (nonatomic, strong) NSLayoutConstraint *labelHorizontalOffsetConstraint;
32
-
33
- @property (nonatomic, strong) NSLayoutConstraint *labelVerticalOffsetConstraint;
34
-
35
- /// Applicable to non-composites (otherwise null)
36
- @property (nonatomic, readonly, nullable) ALPluginConfig *pluginConfig;
37
-
38
- @property (nonatomic, strong) NSError *scanViewError;
39
-
40
- @property (nonatomic, nullable) NSString *initializationParamsStr;
41
-
42
- @end
43
-
44
-
45
- @implementation ALPluginScanViewController
46
-
47
- - (void)dealloc {
48
- // NSLog(@"ACO dealloc ALPluginScanViewController");
49
- }
50
-
51
- - (instancetype)initWithLicensekey:(NSString *)licenseKey
52
- configuration:(NSDictionary *)config
53
- uiConfiguration:(ALJSONUIConfiguration *)JSONUIConfig
54
- initializationParamsStr:(NSString *)initializationParamsStr
55
- finished:(ALPluginCallback)callback {
56
-
57
- if (self = [super init]) {
58
- _licenseKey = licenseKey;
59
- _callback = callback;
60
- _config = config;
61
- _uiConfig = JSONUIConfig;
62
- _initializationParamsStr = initializationParamsStr;
63
-
64
- self.quality = 100;
65
- }
66
- return self;
67
- }
68
-
69
- - (void)viewDidLoad {
70
- [super viewDidLoad];
71
-
72
- NSError *error = nil;
73
-
74
- self.view.backgroundColor = [UIColor blackColor];
75
-
76
- // Make an isInitialized check. If already initialized, happily move along.
77
- // Otherwise, make a license key check here.
78
- BOOL isInitialized = [ALLicenseUtil sharedInstance].isLicenseValid;
79
- if (!isInitialized) {
80
- [AnylineSDK setupWithLicenseKey:self.licenseKey cacheConfig:nil wrapperConfig:wrapperConfig error:&error];
81
- if ([self showErrorAlertIfNeeded:error]) {
82
- return;
83
- }
84
- }
85
-
86
- ALScanViewInitializationParameters *initializationParams = nil;
87
- if(![self isStringEmpty:_initializationParamsStr]){
88
- initializationParams = [ALScanViewInitializationParameters withJSONString: _initializationParamsStr error:&error];
89
- }
90
-
91
- if ([self showErrorAlertIfNeeded:error]) {
92
- self.scanViewError = error;
93
- return;
94
- }
95
-
96
- self.scanView = [ALScanViewFactory withJSONDictionary:self.config
97
- initializationParams:initializationParams
98
- delegate:self
99
- error:&error];
100
-
101
- if ([self showErrorAlertIfNeeded:error]) {
102
- self.scanViewError = error;
103
- return;
104
- }
105
-
106
- [self.view addSubview:self.scanView];
107
-
108
- self.scanView.translatesAutoresizingMaskIntoConstraints = false;
109
- [self.scanView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
110
- [self.scanView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES;
111
- [self.scanView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
112
- [self.scanView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
113
-
114
- self.scanView.supportedNativeBarcodeFormats = self.uiConfig.nativeBarcodeFormats;
115
- self.scanView.delegate = self;
116
- self.detectedBarcodes = [NSMutableArray array];
117
-
118
- self.doneButton = [ALPluginHelper createButtonForViewController:self config:self.uiConfig];
119
-
120
- self.scannedLabel = [ALPluginHelper createLabelForView:self.view];
121
-
122
- [self configureLabel:self.scannedLabel config:self.uiConfig];
123
-
124
- [self configureSegmentControl];
125
- }
126
-
127
- - (void)viewWillAppear:(BOOL)animated {
128
- [super viewWillAppear:animated];
129
- [self.scanView startCamera];
130
- }
131
-
132
- - (void)viewDidAppear:(BOOL)animated {
133
- [super viewDidAppear:animated];
134
-
135
- // avoid allowing the app to be put to sleep after a long period without touch events
136
- [UIApplication sharedApplication].idleTimerDisabled = YES;
137
-
138
- NSError *error;
139
- if(!self.scanViewError){
140
- [self.scanView.viewPlugin startWithError:&error];
141
- [self showErrorAlertIfNeeded:error];
142
- }
143
- else{
144
- [self dismissViewControllerAnimated:YES completion:^{
145
- self.callback(nil, self.scanViewError);
146
- }];
147
- }
148
- }
149
-
150
- - (void)viewDidDisappear:(BOOL)animated {
151
- [UIApplication sharedApplication].idleTimerDisabled = NO;
152
- [super viewDidDisappear:animated];
153
- }
154
-
155
- - (BOOL)shouldAutorotate {
156
- return NO;
157
- }
158
-
159
- /// The segment control contains a list of scan modes each of which, when selected, reloads the scan view with
160
- /// the appropriate scan mode for the active plugin (keeping everything else the same)
161
- - (void)configureSegmentControl {
162
-
163
- NSString *scanMode = [self currentScanMode];
164
- if (!scanMode) {
165
- // Do nothing else: our plugin does not support scan modes.
166
- return;
167
- }
168
-
169
- NSLog(@"The scan mode: %@", scanMode);
170
-
171
- // At this point, you can safely create segment controls.
172
- if (!self.uiConfig.segmentModes) {
173
- return;
174
- }
175
-
176
- if (![self segmentModesAreValid]) {
177
- return;
178
- }
179
-
180
- // Give it the current scanmode that's initially defined already in the config JSON
181
- self.segment = [ALPluginHelper createSegmentForViewController:self
182
- config:self.uiConfig
183
- initialScanMode:scanMode];
184
-
185
- self.segment.hidden = NO;
186
- self.segment.translatesAutoresizingMaskIntoConstraints = NO;
187
- [self.segment.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES;
188
- [self.segment.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor
189
- constant:self.uiConfig.segmentYPositionOffset].active = YES;
190
-
191
- // NOTE: uncomment this to show the segment full width
192
- [self.segment.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:10].active = YES;
193
- }
194
-
195
- - (void)configureLabel:(UILabel *)label config:(ALJSONUIConfiguration *)config {
196
-
197
- if (config.labelText.length < 1) {
198
- return;
199
- }
200
-
201
- label.alpha = 1;
202
- label.text = config.labelText;
203
- label.font = [UIFont fontWithName:@"HelveticaNeue" size:config.labelSize];
204
- label.textColor = config.labelColor;
205
- label.translatesAutoresizingMaskIntoConstraints = NO;
206
-
207
- [label.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:10].active = YES;
208
-
209
- self.labelHorizontalOffsetConstraint = [label.centerXAnchor
210
- constraintEqualToAnchor:self.view.centerXAnchor constant:0];
211
- self.labelVerticalOffsetConstraint = [label.bottomAnchor
212
- constraintEqualToAnchor:self.view.topAnchor
213
- constant:0];
214
-
215
- self.labelHorizontalOffsetConstraint.active = YES;
216
- self.labelVerticalOffsetConstraint.active = YES;
217
- }
218
-
219
- - (void)handleResult:(id _Nullable)resultObj {
220
-
221
- NSMutableDictionary *resultDictionary = [NSMutableDictionary dictionaryWithDictionary:resultObj];
222
-
223
- if (self.detectedBarcodes.count) {
224
- resultDictionary[@"nativeBarcodesDetected"] = self.detectedBarcodes;
225
- }
226
-
227
- // dismiss the view controller, if cancelOnResult for the config is true
228
- NSObject<ALViewPluginBase> *scanViewPluginBase = self.scanView.viewPlugin;
229
- if ([scanViewPluginBase isKindOfClass:ALScanViewPlugin.class]) {
230
- ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)scanViewPluginBase;
231
- BOOL cancelOnResult = scanViewPlugin.scanPlugin.pluginConfig.cancelOnResult;
232
- if (cancelOnResult) {
233
- __weak __block typeof(self) weakSelf = self;
234
- [self dismissViewControllerAnimated:YES completion:^{
235
- weakSelf.callback(resultDictionary, nil);
236
- }];
237
- }
238
- } else if ([scanViewPluginBase isKindOfClass:ALViewPluginComposite.class]) {
239
- // for composites, the cancelOnResult values for each child don't matter
240
- [self dismissViewControllerAnimated:YES completion:nil];
241
- self.callback(resultDictionary, nil);
242
- }
243
- }
244
-
245
- // MARK: - ALScanPluginDelegate
246
-
247
- - (void)scanPlugin:(ALScanPlugin *)scanPlugin resultReceived:(ALScanResult *)scanResult {
248
-
249
- CGFloat compressionQuality = self.quality / 100.0f;
250
-
251
- NSMutableDictionary *resultDictMutable = [NSMutableDictionary dictionaryWithDictionary:scanResult.resultDictionary];
252
-
253
- NSString *imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.croppedImage
254
- compressionQuality:compressionQuality];
255
- resultDictMutable[@"imagePath"] = imagePath;
256
-
257
- imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.fullSizeImage
258
- compressionQuality:compressionQuality];
259
-
260
- resultDictMutable[@"fullImagePath"] = imagePath;
261
-
262
- [self handleResult:resultDictMutable];
263
- }
264
-
265
-
266
- // MARK: - ALViewPluginCompositeDelegate
267
-
268
- - (void)viewPluginComposite:(ALViewPluginComposite *)viewPluginComposite
269
- allResultsReceived:(NSArray<ALScanResult *> *)scanResults {
270
- // combine all into an array and create a string version of it.
271
- NSMutableDictionary *results = [NSMutableDictionary dictionaryWithCapacity:scanResults.count];
272
- CGFloat compressionQuality = self.quality / 100.0f;
273
-
274
- for (ALScanResult *scanResult in scanResults) {
275
- NSMutableDictionary *resultDictMutable = [NSMutableDictionary dictionaryWithDictionary:scanResult.resultDictionary];
276
- NSString *imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.croppedImage
277
- compressionQuality:compressionQuality];
278
- resultDictMutable[@"imagePath"] = imagePath;
279
- imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.fullSizeImage
280
- compressionQuality:compressionQuality];
281
- resultDictMutable[@"fullImagePath"] = imagePath;
282
- results[scanResult.pluginID] = resultDictMutable;
283
- }
284
- [self handleResult:results];
285
- }
286
-
287
- // MARK: - ALScanViewDelegate
288
-
289
- - (void)scanView:(ALScanView *)scanView updatedCutoutWithPluginID:(NSString *)pluginID frame:(CGRect)frame {
290
-
291
- if (CGRectIsEmpty(frame)) {
292
- return;
293
- }
294
-
295
- CGFloat xOffset = self.uiConfig.labelXPositionOffset;
296
- CGFloat yOffset = self.uiConfig.labelYPositionOffset;
297
-
298
- // takes into account that frame reported for a cutout is in relation to
299
- // its scan view's coordinate system
300
- yOffset += [self.scanView convertRect:frame toView:self.scanView.superview].origin.y;
301
-
302
- self.labelHorizontalOffsetConstraint.constant = xOffset;
303
-
304
- self.labelVerticalOffsetConstraint.constant = yOffset;
305
- }
306
-
307
- - (void)scanView:(ALScanView *)scanView didReceiveNativeBarcodeResult:(ALScanResult *)scanResult {
308
- // for this implementation we just take the last detected (we can show a list of it)
309
- [self.detectedBarcodes removeAllObjects];
310
- [self.detectedBarcodes addObject:scanResult.resultDictionary];
311
- }
312
-
313
- // MARK: - Getters and Setters
314
-
315
- - (ALPluginConfig * _Nullable)pluginConfig {
316
- // applic. only to non-composites
317
- NSObject<ALViewPluginBase> *scanVwPluginBase = self.scanView.viewPlugin;
318
- if ([scanVwPluginBase isKindOfClass:ALScanViewPlugin.class]) {
319
- return ((ALScanViewPlugin *)scanVwPluginBase).scanPlugin.pluginConfig;
320
- }
321
- return nil;
322
- }
323
-
324
- // MARK: - Selector Actions
325
-
326
- - (void)doneButtonPressed:(id)sender {
327
- [self.scanView.viewPlugin stop];
328
-
329
- __weak __block typeof(self) weakSelf = self;
330
- [self dismissViewControllerAnimated:YES completion:^{
331
- weakSelf.callback(nil, [NSError errorWithDomain:@"ALReactDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Canceled"}]);
332
- }];
333
- }
334
-
335
- - (void)segmentChange:(id)sender {
336
- NSString *newMode = self.uiConfig.segmentModes[((UISegmentedControl *)sender).selectedSegmentIndex];
337
- [self updateScanModeWithValue:newMode];
338
- }
339
-
340
- // MARK: - Handle scan mode switching
341
-
342
- - (void)updateScanModeWithValue:(NSString *)modeString {
343
- ALPluginConfig *pluginConfig = self.pluginConfig;
344
-
345
- id key = [ALPluginHelper confPropKeyWithScanModeForPluginConfig:pluginConfig];
346
-
347
- // obj is something like an ALMeterConfig instance, that you can call scanMode: (or setScanMode:) on
348
- id obj = [self.pluginConfig valueForKey:key];
349
- NSAssert(obj, @"obj shouldn't be nil!");
350
-
351
- id scanModeObj = [obj valueForKey:@"scanMode"];
352
- NSString *newScanMode;
353
-
354
- // does the equivalent of +[ALConfigMeterScanMode withValue:modeString],
355
- // (or whatever scan mode object gets evaluated) avoiding warnings:
356
- // https://stackoverflow.com/a/20058585
357
- SEL selector = NSSelectorFromString(@"withValue:");
358
- IMP imp = [[scanModeObj class] methodForSelector:selector];
359
- NSString *(*func)(id, SEL, NSString *) = (void *)imp;
360
- newScanMode = func([scanModeObj class], selector, modeString);
361
-
362
- NSAssert(newScanMode, @"newScanMode is not nil!");
363
-
364
- // like obj, pluginSubConfig should be the the plugin-specific config object
365
- // (e.g. ALLicensePlateConfig) which responds to setScanMode:.
366
- selector = NSSelectorFromString(@"setScanMode:");
367
- imp = [obj methodForSelector:selector];
368
- id (*func2)(id, SEL, id) = (void *)imp;
369
- id pluginSubConfig = func2(obj, selector, newScanMode);
370
-
371
- [pluginConfig setValue:pluginSubConfig forKey:key];
372
-
373
- NSError *error;
374
- BOOL success = [self updatePluginConfig:pluginConfig error:&error];
375
-
376
- if (!success) {
377
- // check error
378
- NSLog(@"there was an error changing the scan mode: %@", error.localizedDescription);
379
- }
380
- }
381
-
382
- // assume that pluginConfig carries the updated scanMode or whatever value that you wish to refresh.
383
- - (BOOL)updatePluginConfig:(ALPluginConfig *)pluginConfig error:(NSError * _Nullable * _Nullable)error {
384
- ALViewPluginConfig *origSVPConfig = ((ALScanViewPlugin *)self.scanView.viewPlugin).scanViewPluginConfig;
385
-
386
- origSVPConfig.pluginConfig = pluginConfig;
387
- BOOL success = [self.scanView setViewPluginConfig:origSVPConfig error:error];
388
- if (!success) {
389
- if([self showErrorAlertIfNeeded:*error]){
390
- [self dismissOnError:*error];
391
- }
392
- return NO;
393
- }
394
-
395
- success = [self.scanView.viewPlugin startWithError:error];
396
- if (!success) {
397
- // check error
398
- if([self showErrorAlertIfNeeded:*error]){
399
- [self dismissOnError:*error];
400
- }
401
- return NO;
402
- }
403
- return YES;
404
- }
405
-
406
-
407
- /// If the running plugin supports a scan mode, this returns the string representation of it.
408
- - (NSString * _Nullable)currentScanMode {
409
- // Does our running plugin contain a property named something like `XXXConfig`?
410
- // If yes, is there a `scanMode` inside?
411
- NSString * _Nullable pluginConfigPropertyWithScanMode = [ALPluginHelper confPropKeyWithScanModeForPluginConfig:self.pluginConfig];
412
- if (!pluginConfigPropertyWithScanMode) {
413
- return nil;
414
- }
415
- // obj is something like an ALMeterConfig instance
416
- id obj = [self.pluginConfig valueForKey:pluginConfigPropertyWithScanMode];
417
- NSAssert(obj, @"obj shouldn't be nil!");
418
- id scanModeObj = [obj valueForKey:@"scanMode"];
419
- return [scanModeObj valueForKey:@"value"];
420
- }
421
-
422
- // Check whether the scan modes indicated in options > segmentConfig are valid.
423
- // Otherwise, the segment control is not shown.
424
- - (BOOL)segmentModesAreValid {
425
- if (self.uiConfig.segmentModes.count < 1) {
426
- return NO;
427
- }
428
-
429
- // easy question first: is there an identical number of segModes and segTitles?
430
- if (self.uiConfig.segmentModes.count != self.uiConfig.segmentTitles.count) {
431
- NSLog(@"Error: should have the same number of segment modes and segment titles!");
432
- return NO;
433
- }
434
-
435
- NSString *propKey = [ALPluginHelper confPropKeyWithScanModeForPluginConfig:self.pluginConfig];
436
- id obj = [self.pluginConfig valueForKey:propKey];
437
- NSAssert(obj, @"obj shouldn't be nil!");
438
-
439
- // go through each self.segmentMode. Each call below should be non-nil.
440
- // NOTE: for now (24.01.2023) TIN and Container scanModes should be named in the JSON config
441
- // in all UPPERCASE (because the schema demands it to be so).
442
- for (NSString *scanModeStr in self.uiConfig.segmentModes) {
443
- if (![[[obj scanMode] class] withValue:scanModeStr]) {
444
- NSLog(@"Error: %@ is not a valid scan mode for the current plugin", scanModeStr);
445
- return NO;
446
- }
447
- }
448
-
449
- return YES;
450
- }
451
-
452
- -(BOOL)isStringEmpty:(NSString *)str {
453
- if(str == nil || [str isKindOfClass:[NSNull class]] || str.length==0) {
454
- return YES;
455
- }
456
- return NO;
457
- }
458
-
459
- // MARK: - Miscellaneous
460
-
461
- - (BOOL)showErrorAlertIfNeeded:(NSError *)error {
462
- if (!error) {
463
- return NO;
464
- }
465
-
466
- return YES;
467
- }
468
-
469
- -(void)dismissOnError:(NSError *)error{
470
- [self dismissViewControllerAnimated:YES completion:^{
471
- self.callback(nil, error);
472
- }];
473
- }
474
-
475
-
476
- @end
@@ -1,25 +0,0 @@
1
- //
2
- // ALRoundedView.h
3
- // Anyline
4
- //
5
- // Created by David Dengg on 18.01.16.
6
- // Copyright © 2016 Anyline GmbH. All rights reserved.
7
- //
8
-
9
- #import <UIKit/UIKit.h>
10
-
11
- @interface ALRoundedView : UIView
12
-
13
- @property (nonatomic, strong) UILabel *textLabel;
14
-
15
- @property (nonatomic, assign) CGFloat cornerRadius;
16
- @property (nonatomic, assign) CGFloat borderWidth;
17
-
18
- @property (nonatomic, strong) UIColor *fillColor;
19
- @property (nonatomic, strong) UIColor *textColor;
20
- @property (nonatomic, strong) UIColor *borderColor;
21
-
22
- - (void)addTarget:(id)target selector:(SEL)selector;
23
- - (void)addImage:(UIImage*)image;
24
-
25
- @end
@@ -1,107 +0,0 @@
1
- //
2
- // ALRoundedView.m
3
- // Anyline
4
- //
5
- // Created by David Dengg on 18.01.16.
6
- // Copyright © 2016 Anyline GmbH. All rights reserved.
7
- //
8
-
9
- #import "ALRoundedView.h"
10
-
11
- @interface ALRoundedView ()
12
- @property (nonatomic, strong) UIButton *button;
13
- @end
14
-
15
-
16
- @implementation ALRoundedView
17
-
18
- - (id)initWithFrame:(CGRect)frame
19
- {
20
- self = [super initWithFrame:frame];
21
- if (self) {
22
- // Initialization code
23
- self.backgroundColor = [UIColor clearColor];
24
- self.borderColor = [UIColor clearColor];
25
- self.fillColor = [UIColor clearColor];
26
- self.cornerRadius = 15;
27
- self.opaque = NO;
28
-
29
-
30
- self.textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
31
- self.textLabel.backgroundColor = [UIColor clearColor];
32
- self.textLabel.textAlignment = NSTextAlignmentCenter;
33
- self.textLabel.textColor = [UIColor whiteColor];
34
- self.textLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
35
- [self addSubview:self.textLabel];
36
- }
37
- return self;
38
- }
39
-
40
- - (void)setFrame:(CGRect)frame {
41
- [super setFrame:frame];
42
- [self.textLabel setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
43
- }
44
-
45
- - (void)setText:(NSString*)text; {
46
- self.textLabel.text = text;
47
- }
48
-
49
- - (void)drawRect:(CGRect)rect {
50
- [super drawRect:rect];
51
-
52
- //CGContextRef context = UIGraphicsGetCurrentContext();
53
- //CGContextSaveGState(context);
54
- //CGContextSetBlendMode(context, kCGBlendModeDestinationOut);
55
-
56
- CGRect frame = CGRectInset(self.bounds, 0, 0);
57
-
58
- CGRect mainRect = frame;
59
-
60
-
61
- UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:mainRect
62
- cornerRadius:self.cornerRadius];
63
-
64
- [_fillColor set];
65
- [path fill];
66
-
67
-
68
- if(nil != _borderColor && _borderWidth > 0) {
69
- UIBezierPath* outlinePath =
70
- self.cornerRadius > 0 ?
71
- [UIBezierPath bezierPathWithRoundedRect:CGRectInset(rect, _borderWidth/2 , _borderWidth/2 ) cornerRadius:self.cornerRadius > 0 ? self.cornerRadius + _borderWidth/2 : 0] :
72
- [UIBezierPath bezierPathWithRect:CGRectInset(rect, _borderWidth-1, _borderWidth-1)];
73
-
74
- [outlinePath setLineWidth:_borderWidth];
75
-
76
- [_borderColor set];
77
- [outlinePath stroke];
78
-
79
- mainRect = CGRectInset(frame, _borderWidth, _borderWidth);
80
- }
81
-
82
- //CGContextRestoreGState(context);
83
- }
84
-
85
- - (void)setBorderColor:(UIColor *)borderColor {
86
- _borderColor = borderColor;
87
- [self setNeedsDisplay];
88
- }
89
-
90
-
91
- - (void)addTarget:(id)target selector:(SEL)selector {
92
- [self.button removeFromSuperview];
93
- UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
94
- button.frame = self.textLabel.frame;
95
- [button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
96
- [self addSubview:button];
97
- self.button = button;
98
- }
99
-
100
- - (void)addImage:(UIImage*)image {
101
- UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectInset(self.bounds, 2, 2)];
102
- iv.contentMode = UIViewContentModeScaleAspectFill;
103
- iv.image = image;
104
- [self addSubview:iv];
105
- }
106
-
107
- @end