-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edde23b
commit 863da6e
Showing
514 changed files
with
1,104 additions
and
865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 77 additions & 64 deletions
141
...ples/Anyline Examples Source/Processes/Composite Scanning/parallel_first_vin_barcode.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,80 @@ | ||
{ | ||
"cameraConfig": { | ||
"captureResolution": "1080p", | ||
"pictureResolution": "1080p" | ||
}, | ||
"flashConfig": { | ||
"mode": "manual", | ||
"alignment": "top_right" | ||
}, | ||
"viewPluginCompositeConfig": { | ||
"id": "parallel-first-vin-barcode", | ||
"processingMode": "parallelFirstScan", | ||
"viewPlugins": [ | ||
{ | ||
"viewPluginConfig": { | ||
"pluginConfig": { | ||
"id": "barcode", | ||
"barcodeConfig": { | ||
"barcodeFormats": ["ALL"] | ||
} | ||
}, | ||
"scanFeedbackConfig": { | ||
"style": "rect", | ||
"strokeWidth": 2, | ||
"strokeColor": "0099FF", | ||
"fillColor": "330099FF", | ||
"cornerRadius": 0, | ||
"beepOnResult": false, | ||
"vibrateOnResult": false, | ||
"blinkAnimationOnResult": true | ||
} | ||
} | ||
}, | ||
{ | ||
"viewPluginConfig": { | ||
"pluginConfig": { | ||
"id": "vin", | ||
"vinConfig": {} | ||
}, | ||
"cutoutConfig": { | ||
"maxWidthPercent": "85%", | ||
"alignment": "top_half", | ||
"ratioFromSize": { "width": 62, "height": 9 }, | ||
"offset": { "x": 0, "y": 0 }, | ||
"outerColor": "000000", | ||
"outerAlpha": 0, | ||
"strokeWidth": 2, | ||
"strokeColor": "0099FF", | ||
"cornerRadius": 4, | ||
"feedbackStrokeColor": "0099FF" | ||
}, | ||
"scanFeedbackConfig": { | ||
"style": "contour_rect", | ||
"animation": "traverse_multi", | ||
"animationDuration": 250, | ||
"strokeWidth": 2, | ||
"strokeColor": "0099FF", | ||
"fillColor": "220099FF", | ||
"beepOnResult": false, | ||
"vibrateOnResult": false, | ||
"blinkAnimationOnResult": true | ||
} | ||
} | ||
"cameraConfig": { | ||
"captureResolution": "1080p", | ||
"pictureResolution": "1080p" | ||
}, | ||
"flashConfig": { | ||
"mode": "manual", | ||
"alignment": "top_right" | ||
}, | ||
"viewPluginCompositeConfig": { | ||
"id": "parallel-first-vin-barcode", | ||
"processingMode": "parallelFirstScan", | ||
"viewPlugins": [ | ||
{ | ||
"viewPluginConfig": { | ||
"pluginConfig": { | ||
"id": "barcode", | ||
"barcodeConfig": { | ||
"barcodeFormats": ["ALL"] | ||
} | ||
] | ||
} | ||
}, | ||
"scanFeedbackConfig": { | ||
"style": "rect", | ||
"strokeWidth": 2, | ||
"strokeColor": "0099FF", | ||
"fillColor": "330099FF", | ||
"cornerRadius": 0, | ||
"beepOnResult": false, | ||
"vibrateOnResult": false, | ||
"blinkAnimationOnResult": true | ||
} | ||
} | ||
}, | ||
{ | ||
"viewPluginConfig": { | ||
"pluginConfig": { | ||
"id": "vin", | ||
"vinConfig": {} | ||
}, | ||
"cutoutConfig": { | ||
"maxWidthPercent": "85%", | ||
"alignment": "top_half", | ||
"ratioFromSize": { "width": 62, "height": 9 }, | ||
"offset": { "x": 0, "y": 0 }, | ||
"outerColor": "000000", | ||
"outerAlpha": 0, | ||
"strokeWidth": 2, | ||
"strokeColor": "0099FF", | ||
"cornerRadius": 4, | ||
"feedbackStrokeColor": "0099FF" | ||
}, | ||
"scanFeedbackConfig": { | ||
"style": "contour_rect", | ||
"animation": "traverse_multi", | ||
"animationDuration": 250, | ||
"strokeWidth": 2, | ||
"strokeColor": "0099FF", | ||
"fillColor": "220099FF", | ||
"beepOnResult": false, | ||
"vibrateOnResult": false, | ||
"blinkAnimationOnResult": true | ||
}, | ||
"uiFeedbackConfig": { | ||
"presets": [ | ||
{ | ||
"presetName": "simple_instruction_label", | ||
"presetAttributes": [ | ||
{ | ||
"attributeName": "instruction_text", | ||
"attributeValue": "Position the VIN in the cutout. The barcode can be anywhere inside the camera frame." | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...les/Anyline Examples Source/Tire/ViewController/ALTINScanNAWithUIFeedbackViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
#import "ALBaseScanViewController.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface ALTINScanNAWithUIFeedbackViewController : ALBaseScanViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
159 changes: 159 additions & 0 deletions
159
...les/Anyline Examples Source/Tire/ViewController/ALTINScanNAWithUIFeedbackViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#import "ALTINScanNAWithUIFeedbackViewController.h" | ||
|
||
#import <Anyline/Anyline.h> | ||
#import "ALConfigurationDialogViewController.h" | ||
#import "AnylineExamples-Swift.h" // for ALResultEntry | ||
#import "ALTinScanRecalledDOTs.h" | ||
|
||
NSString * const kALTINNAScanVC_uiFeedback_configFilename = @"tire_tin_na_uifeedback_config"; | ||
|
||
@interface ALTINScanNAWithUIFeedbackViewController () <ALScanPluginDelegate> | ||
|
||
@property (nonatomic, strong) ALScanViewConfig *scanViewConfig; | ||
|
||
@property (nonatomic, readonly) NSDictionary *scanViewConfigDict; | ||
|
||
@property (nonatomic, readonly) NSArray<NSString *> *recalledDOTs; | ||
|
||
@end | ||
|
||
|
||
@implementation ALTINScanNAWithUIFeedbackViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
self.title = @"Tire DOT/TIN (North America only)"; | ||
self.controllerType = ALScanHistoryTIN; | ||
|
||
self.scanViewConfig = [[ALScanViewConfig alloc] initWithJSONDictionary:self.scanViewConfigDict error:nil]; | ||
|
||
[self reloadScanView]; | ||
|
||
[self setupFlipOrientationButton]; | ||
|
||
[self.scanView startCamera]; | ||
} | ||
|
||
- (void)viewWillAppear:(BOOL)animated { | ||
[super viewWillAppear:animated]; | ||
|
||
// starts in landscape mode (APP-383) | ||
self.isOrientationFlipped = YES; | ||
[self enableLandscapeOrientation:YES]; | ||
|
||
[self startScanning:nil]; | ||
} | ||
|
||
// detect when a rotation is done | ||
- (void)viewWillTransitionToSize:(CGSize)size | ||
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { | ||
__weak __block typeof(self) weakSelf = self; | ||
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {} | ||
completion:^(id<UIViewControllerTransitionCoordinatorContext> context) { | ||
if (weakSelf.scanViewPlugin.isStarted) { | ||
[weakSelf reloadScanView]; | ||
} | ||
}]; | ||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; | ||
} | ||
|
||
// MARK: - Getters and Setters | ||
|
||
- (NSDictionary *)scanViewConfigDict { | ||
return [[self configJSONStrWithFilename:kALTINNAScanVC_uiFeedback_configFilename] asJSONObject]; | ||
} | ||
|
||
// MARK: - Setup | ||
|
||
- (ALScanViewPlugin *)getScanViewPlugin { | ||
NSDictionary *JSONConfigObj = self.scanViewConfigDict; | ||
|
||
// Will edit this object before constructing an ALScanViewPlugin with it later | ||
NSError *error; | ||
ALScanViewPluginConfig *scanViewPluginConfig = [[ALScanViewPluginConfig alloc] initWithJSONDictionary:JSONConfigObj error:&error]; | ||
if ([self popWithAlertOnError:error]) { | ||
return nil; | ||
} | ||
|
||
// Recreate the ScanViewPlugin. Since this is a different ScanViewPlugin than | ||
// the previous one, reset the delegate. | ||
ALScanViewPlugin *scanViewPlugin = [[ALScanViewPlugin alloc] initWithConfig:scanViewPluginConfig error:&error]; | ||
if ([self popWithAlertOnError:error]) { | ||
return nil; | ||
} | ||
|
||
scanViewPlugin.scanPlugin.delegate = self; | ||
return scanViewPlugin; | ||
} | ||
|
||
- (void)reloadScanView { | ||
[self stopScanning]; | ||
ALScanViewPlugin *scanViewPlugin = [self getScanViewPlugin]; | ||
|
||
NSError *error; | ||
if (!self.scanView) { | ||
self.scanView = [[ALScanView alloc] initWithFrame:CGRectZero | ||
scanViewPlugin:scanViewPlugin | ||
scanViewConfig:self.scanViewConfig | ||
error:&error]; | ||
if ([self popWithAlertOnError:error]) { | ||
return; | ||
} | ||
[self installScanView:self.scanView]; | ||
} else { | ||
[self.scanView setScanViewPlugin:scanViewPlugin error:&error]; | ||
if ([self popWithAlertOnError:error]) { | ||
return; | ||
} | ||
} | ||
[self startScanning:nil]; | ||
} | ||
|
||
// MARK: - Getters | ||
|
||
+ (NSArray<NSString *> *)recalledDOTs { | ||
return kRecalledDOTs; | ||
} | ||
|
||
// MARK: - Handle & present results | ||
|
||
- (void)scanPlugin:(ALScanPlugin *)scanPlugin resultReceived:(ALScanResult *)scanResult { | ||
|
||
__weak __block typeof(self) weakSelf = self; | ||
[self anylineDidFindResult:scanResult.pluginResult.tinResult.text | ||
barcodeResult:nil | ||
image:[scanResult croppedImage] | ||
scanPlugin:scanPlugin viewPlugin:self.scanViewPlugin completion:^{ | ||
NSArray<ALResultEntry *> *resultData = [self.class resultDataFromScanResult:scanResult]; | ||
|
||
ALResultViewController *vc = [[ALResultViewController alloc] | ||
initWithResults:resultData]; | ||
vc.imagePrimary = scanResult.croppedImage; | ||
weakSelf.isOrientationFlipped = NO; | ||
[weakSelf enableLandscapeOrientation:NO]; | ||
[weakSelf.navigationController pushViewController:vc animated:YES]; | ||
}]; | ||
} | ||
|
||
+ (NSArray<ALResultEntry *> *)resultDataFromScanResult:(ALScanResult *)scanResult { | ||
NSMutableArray *resultEntries = [NSMutableArray arrayWithArray:scanResult.pluginResult.fieldList.resultEntries]; | ||
// would add a Tire on Recall entry if the result falls in one of the few values hardcoded here. | ||
BOOL needsRecalledEntry = NO; | ||
for (ALResultEntry *res in resultEntries) { | ||
if ([res.title isEqualToString:@"Tire Identification Number"]) { | ||
// if result somehow split the scan result string with spaces, remove them first. | ||
NSString *tin = [res.value stringByReplacingOccurrencesOfString:@" " withString:@""]; | ||
if ([[self.class recalledDOTs] containsObject:tin]) { | ||
needsRecalledEntry = YES; | ||
} | ||
} | ||
} | ||
if (needsRecalledEntry) { | ||
// add it above the first entry | ||
[resultEntries insertObject:[ALResultEntry withTitle:@"Tire on Recall" value:@"YES"] atIndex:0]; | ||
} | ||
return resultEntries; | ||
} | ||
|
||
@end |
7 changes: 0 additions & 7 deletions
7
AnylineExamples/Anyline Examples Source/Tire/ViewController/ALTINScanViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.