Skip to content

Commit

Permalink
Release 53.0.0 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
vimalvenugopalananyline authored Aug 1, 2024
1 parent 2c2cff4 commit fe4cb81
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 143 deletions.
2 changes: 1 addition & 1 deletion example/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.anyline.examples.cordova" version="52.0.1" ios-CFBundleVersion="1"
<widget id="com.anyline.examples.cordova" version="53.0.0" ios-CFBundleVersion="1"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Anyline Cordova Example</name>
Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anyline-cordova-example",
"version": "52.0.1",
"version": "53.0.0",
"description": "Cordova plugin for implementing Anyline",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -32,8 +32,8 @@
]
},
"devDependencies": {
"cordova-android": "^12.0.1",
"cordova-ios": "^7.1.0",
"cordova-android": "^13.0.0",
"cordova-ios": "^7.1.1",
"cordova-plugin-android-permissions": "^1.1.5",
"cordova-plugin-device": "^2.1.0",
"cordova-plugin-dialogs": "^2.0.2",
Expand Down
4 changes: 2 additions & 2 deletions example/www/js/anyline.compositeScan.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ anyline.compositeScan = {
"feedbackStrokeColor": "0099FF"
},
"scanFeedbackConfig": {
"style": "CONTOUR_RECT",
"visualFeedbackRedrawTimeout": 100,
"style": "contour_rect",
"redrawTimeout": 100,
"strokeColor": "0099FF",
"fillColor": "220099FF",
"beepOnResult": true,
Expand Down
2 changes: 1 addition & 1 deletion example/www/js/anyline.energy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ anyline.energy = {
"text": "Position your meter inside the box",
"color": "f0f0f0",
"size": 12,
"offset.y": -10,
"offset.y": -10
},
"segmentConfig": {
"titles": ["Analog", "Digital", "Dial"],
Expand Down
12 changes: 6 additions & 6 deletions example/www/js/anyline.id.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ anyline.universalId = {
"feedbackStrokeColor": "0099FF"
},
"scanFeedbackConfig": {
"style": "CONTOUR_RECT",
"visualFeedbackRedrawTimeout": 100,
"style": "contour_rect",
"redrawTimeout": 100,
"strokeColor": "0099FF",
"fillColor": "220099FF",
"beepOnResult": true,
Expand Down Expand Up @@ -335,8 +335,8 @@ anyline.universalId = {
"feedbackStrokeColor": "0099FF"
},
"scanFeedbackConfig": {
"style": "CONTOUR_RECT",
"visualFeedbackRedrawTimeout": 100,
"style": "contour_rect",
"redrawTimeout": 100,
"strokeColor": "0099FF",
"fillColor": "220099FF",
"beepOnResult": true,
Expand Down Expand Up @@ -485,8 +485,8 @@ anyline.universalId = {
"feedbackStrokeColor": "0099FF"
},
"scanFeedbackConfig": {
"style": "CONTOUR_RECT",
"visualFeedbackRedrawTimeout": 100,
"style": "contour_rect",
"redrawTimeout": 100,
"strokeColor": "0099FF",
"fillColor": "220099FF",
"beepOnResult": true,
Expand Down
4 changes: 2 additions & 2 deletions example/www/js/anyline.vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ tireMakeConfig: {
}
},
"scanFeedbackConfig" : {
"style" : "CONTOUR_RECT",
"style" : "contour_rect",
"strokeColor" : "0099FF",
"fillColor" : "220099FF",
"blinkOnResult": true,
"blinkAnimationOnResult": true,
"beepOnResult": true,
"vibrateOnResult": true
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io-anyline-cordova",
"version": "52.0.1",
"version": "53.0.0",
"description": "The cordova plugin for the Anyline SDK",
"cordova": {
"id": "io-anyline-cordova",
Expand Down
4 changes: 2 additions & 2 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android" id="io-anyline-cordova" version="52.0.1">
xmlns:android="http://schemas.android.com/apk/res/android" id="io-anyline-cordova" version="53.0.0">

<name>AnylineSDK</name>

Expand Down Expand Up @@ -50,7 +50,7 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Anyline" type="podspec" spec="~>52" />
<pod name="Anyline" type="podspec" spec="53.0.0" />
</pods>
</podspec>

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
}

dependencies {
implementation 'io.anyline:anylinesdk:52.0.1'
implementation 'io.anyline:anylinesdk:53.0.0'
implementation("com.google.android.material:material:1.4.0-rc01")
}

Expand Down
13 changes: 10 additions & 3 deletions plugin/src/android/io/anyline/cordova/ScanActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
};
} catch (JSONException e) {
finishWithError("Error parsing view config: " + e.getMessage());
} catch (Exception e) {
finishWithError(getString(getResources().getIdentifier("error_invalid_json_data", "string", getPackageName()))
+ "\n" + e.getLocalizedMessage());
}
} else {
finishWithError("View config not found");
Expand Down Expand Up @@ -194,13 +197,17 @@ protected void onSaveInstanceState(Bundle outState) {
@Override
protected void onResume() {
super.onResume();
scanView.start();
if (scanView.isInitialized()) {
scanView.start();
}
}

@Override
protected void onPause() {
scanView.stop();
scanView.getCameraView().releaseCameraInBackground();
if (scanView.isInitialized()) {
scanView.stop();
scanView.getCameraView().releaseCameraInBackground();
}
super.onPause();
}

Expand Down
44 changes: 31 additions & 13 deletions plugin/src/ios/ALNFCScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ @interface ALNFCScanViewController () <ALNFCDetectorDelegate, ALScanPluginDelega
// JPEG compression quality 0-100
@property (nonatomic, assign) NSUInteger quality;

@property (nonatomic, strong) NSError *scanViewError;

@end


Expand Down Expand Up @@ -59,7 +61,9 @@ - (void)viewDidLoad {
} else {
error = [ALPluginHelper errorWithMessage:@"iOS 13.0 or newer is required to scan with MRZ / NFC."];
}

if ([self showErrorAlertIfNeeded:error]) {
self.scanViewError = error;
return;
}

Expand All @@ -77,7 +81,7 @@ - (void)viewDidLoad {
return;
}

self.mrzScanViewPlugin = (ALScanViewPlugin *)self.scanView.scanViewPlugin;
self.mrzScanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;

// TODO: reeenable this
// self.scanView.supportedNativeBarcodeFormats = self.uiConfig.nativeBarcodeFormats;
Expand All @@ -104,8 +108,15 @@ - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

NSError *error;
[self startMRZScanning:&error];
[self showErrorAlertIfNeeded:error];
if(!self.scanViewError){
[self startMRZScanning:&error];
[self showErrorAlertIfNeeded:error];
}
else{
[self dismissViewControllerAnimated:YES completion:^{
self.callback(nil, self.scanViewError);
}];
}
}

- (void)viewDidDisappear:(BOOL)animated {
Expand All @@ -125,7 +136,7 @@ - (void)stopMRZScanning {

- (void)configureMRZPlugin {

ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)self.scanView.scanViewPlugin;
ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
if (![scanViewPlugin isKindOfClass:ALScanViewPlugin.class]) {
return;
}
Expand Down Expand Up @@ -153,14 +164,11 @@ - (void)configureMRZPlugin {
mrzConfig.mrzMinFieldConfidences.dateOfExpiry = @(90);

NSError *error;
ALScanViewPluginConfig *scanViewPluginConfig = [ALScanViewPluginConfig withPluginConfig:pluginConfig
cutoutConfig:cutoutConfig
scanFeedbackConfig:scanFeedbackConfig];
ALScanViewPlugin *updatedScanViewPlugin = [[ALScanViewPlugin alloc] initWithConfig:scanViewPluginConfig error:&error];
[self.scanView setScanViewPlugin:updatedScanViewPlugin error:&error];
ALViewPluginConfig *scanViewPluginConfig = scanViewPlugin.scanViewPluginConfig;
[self.scanView setViewPluginConfig:scanViewPluginConfig error:&error];

// the delegate binding was lost when you recreated the ScanPlugin it so you have to bring it back here
scanViewPlugin = (ALScanViewPlugin *)self.scanView.scanViewPlugin;
scanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
scanViewPlugin.scanPlugin.delegate = self;
}

Expand Down Expand Up @@ -213,7 +221,7 @@ - (void)handleResult:(id _Nullable)resultObj {
resultDictionary[@"nativeBarcodesDetected"] = self.detectedBarcodes;
}

NSObject<ALScanViewPluginBase> *scanViewPluginBase = self.scanView.scanViewPlugin;
NSObject<ALViewPluginBase> *scanViewPluginBase = self.scanView.viewPlugin;
// TODO: handle this for composites: cancelOnResult = true? dismiss
if ([scanViewPluginBase isKindOfClass:ALScanViewPlugin.class]) {
ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)scanViewPluginBase;
Expand All @@ -233,7 +241,7 @@ - (void)doneButtonPressed:(id)sender {

__weak __block __typeof(self) weakSelf = self;
[self dismissViewControllerAnimated:YES completion:^{
weakSelf.callback(nil, @"Canceled");
weakSelf.callback(nil, [NSError errorWithDomain:@"ALCordovaErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Canceled"}]);
}];
}

Expand Down Expand Up @@ -370,7 +378,17 @@ - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
}

- (BOOL)showErrorAlertIfNeeded:(NSError *)error {
return [ALPluginHelper showErrorAlertIfNeeded:error pluginCallback:self.callback];
if (!error) {
return NO;
}

return YES;
}

-(void)dismissOnError:(NSError *)error{
[self dismissViewControllerAnimated:YES completion:^{
self.callback(nil, error);
}];
}

// MARK: - User Interface
Expand Down
36 changes: 18 additions & 18 deletions plugin/src/ios/ALPluginHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ + (ALPluginScanViewController *)startScan:(NSDictionary *)config
if (isNFC) {
if (@available(iOS 13.0, *)) {
if (![ALNFCDetector readingAvailable]) {
callback(nil, @"NFC passport reading is not supported on this device or app.");
callback(nil, [NSError errorWithDomain:ALCordovaErrorDomain code:100 userInfo:@{@"Error reason": @"NFC passport reading is not supported on this device or app."}]);
return nil;
}
__weak __block __typeof(self) weakSelf = self;
Expand All @@ -30,7 +30,7 @@ + (ALPluginScanViewController *)startScan:(NSDictionary *)config
[weakSelf presentViewController:nfcScanViewController];
});
} else {
callback(nil, @"NFC passport reading is only supported on iOS 13 and later.");
callback(nil,[NSError errorWithDomain:ALCordovaErrorDomain code:100 userInfo:@{@"Error reason": @"NFC passport reading is only supported on iOS 13 and later."}]);
}
return nil;
} else {
Expand Down Expand Up @@ -59,7 +59,7 @@ + (NSString *)saveImageToFileSystem:(UIImage *)image compressionQuality:(CGFloat
NSData *binaryImageData = UIImageJPEGRepresentation(image, compressionQuality);
NSString *uuid = [NSUUID UUID].UUIDString;
NSString *imageName = [NSString stringWithFormat:@"%@.jpg",uuid];

NSString *fullPath = [basePath stringByAppendingPathComponent:imageName];
[binaryImageData writeToFile:fullPath atomically:YES];

Expand All @@ -69,17 +69,17 @@ + (NSString *)saveImageToFileSystem:(UIImage *)image compressionQuality:(CGFloat
// MARK: - UI helpers

+ (UILabel *)createLabelForView:(UIView *)view {

UILabel *scannedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, 44)];
scannedLabel.center = CGPointMake(view.center.x, view.center.y+166);

scannedLabel.alpha = 0.0;
scannedLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:33];
scannedLabel.textColor = [UIColor whiteColor];
scannedLabel.textAlignment = NSTextAlignmentCenter;

[view addSubview:scannedLabel];

return scannedLabel;
}

Expand Down Expand Up @@ -115,7 +115,7 @@ + (UISegmentedControl *)createSegmentForViewController:(UIViewController *)viewC

+ (UIButton *)createButtonForViewController:(UIViewController *)viewController
config:(ALCordovaUIConfiguration *)config {

UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
[doneButton setTitle:config.buttonDoneTitle
forState:UIControlStateNormal];
Expand All @@ -124,11 +124,11 @@ + (UIButton *)createButtonForViewController:(UIViewController *)viewController
[doneButton addTarget:viewController action:@selector(doneButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[viewController.view addSubview:doneButton];

[ALPluginHelper updateButtonPosition:doneButton
withConfiguration:config
onView:viewController.view];

return doneButton;
}

Expand Down Expand Up @@ -265,14 +265,14 @@ + (NSString *)stringForDate:(NSDate *)date {
if (!date) {
return nil;
}

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC+0:00"]];
[dateFormatter setDateFormat:@"EEE MMM d hh:mm:ss ZZZZ yyyy"];

//Date will be formatted to string - e.g.: "Fri Jan 11 12:00:00 GMT+0:00 1980"
NSString *dateString = [dateFormatter stringFromDate:date];

return dateString;
}

Expand Down Expand Up @@ -313,11 +313,11 @@ + (BOOL)showErrorAlertIfNeeded:(NSError *)error pluginCallback:(ALPluginCallback
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {

[[UIApplication sharedApplication].keyWindow.rootViewController
dismissViewControllerAnimated:YES completion:^{
callback(nil, @"Canceled");
}];
}];
[[UIApplication sharedApplication].keyWindow.rootViewController
dismissViewControllerAnimated:YES completion:^{
callback(nil, [NSError errorWithDomain:@"ALCordovaErrorDomain" code:-1 userInfo:@{@"Error reason": @"Canceled"}]);
}];
}];

[alert addAction:action];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/ios/ALPluginScanViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

NS_ASSUME_NONNULL_BEGIN

typedef void (^ALPluginCallback)(id _Nullable callbackObj, NSString * _Nullable errorString);
typedef void (^ALPluginCallback)(NSDictionary * _Nullable callbackObj, NSError * _Nullable error);

@interface ALPluginScanViewController : UIViewController

Expand Down
Loading

0 comments on commit fe4cb81

Please sign in to comment.