Skip to content

Commit

Permalink
51.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aldrichanyline committed Apr 23, 2024
1 parent edde23b commit 863da6e
Show file tree
Hide file tree
Showing 514 changed files with 1,104 additions and 865 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "ALVRCScanViewController.h"
#import "ALTINScanViewController.h"
#import "ALTINScanWithUIFeedbackViewController.h"
#import "ALTINScanNAWithUIFeedbackViewController.h"

NSString * const kVehicleRegistrationCertificate = @"Vehicle Registration Certificate DE";

Expand Down Expand Up @@ -45,11 +46,15 @@ - (void)initExampleData {

ALExample *tinScanning = [[ALExample alloc] initWithName:NSLocalizedString(@"Tire DOT/TIN", nil)
image:[UIImage imageNamed:@"tin"]
viewController:[ALTINScanViewController class] title:@"Tire DOT/TIN"];
viewController:[ALTINDotViewController class] title:@"Tire DOT/TIN"];

ALExample *tinUniversalScanningUIFeedback = [[ALExample alloc] initWithName:NSLocalizedString(@"Universal Tire (with UIFeedback)", nil)
image:[UIImage imageNamed:@"tin_universal"]
viewController:[ALTINScanWithUIFeedbackViewController class] title:@"Universal Tire"];

ALExample *tinScanningUIFeedback = [[ALExample alloc] initWithName:NSLocalizedString(@"Tire DOT/TIN (with UIFeedback)", nil)
image:[UIImage imageNamed:@"tin"]
viewController:[ALTINScanWithUIFeedbackViewController class] title:@"Tire DOT/TIN"];
ALExample *tinNAScanningUIFeedback = [[ALExample alloc] initWithName:NSLocalizedString(@"Tire DOT/TIN (with UIFeedback)", nil)
image:[UIImage imageNamed:@"tin_na"]
viewController:[ALTINScanNAWithUIFeedbackViewController class] title:@"Tire (DOT/TIN)"];

ALExample *tireSizeScanning = [[ALExample alloc] initWithName:NSLocalizedString(@"Tire Size", nil)
image:[UIImage imageNamed:@"tin"]
Expand Down Expand Up @@ -85,7 +90,8 @@ - (void)initExampleData {
licensePlate,
vinScanning,
tinScanning,
tinScanningUIFeedback,
tinUniversalScanningUIFeedback,
tinNAScanningUIFeedback,
tireSizeScanning,
tireMakeScanning,
commercialTireScanning,
Expand Down
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."
}
]
}
]
}
}
}
]
}
}
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
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// ALTINScanViewController.h
// AnylineExamples
//
// Created by Angela Brett on 26.08.19.
//

#import <UIKit/UIKit.h>

#import "ALBaseScanViewController.h"
Expand Down
Loading

0 comments on commit 863da6e

Please sign in to comment.