Skip to content

Commit

Permalink
Release 53.3.0 (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldrichanyline authored Aug 16, 2024
1 parent 2eb819d commit 368c80f
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 32 deletions.
2 changes: 1 addition & 1 deletion example/RNExampleApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5
versionName "53.2.0"
versionName "53.3.0"
multiDexEnabled true

buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNExampleApp/Pods-RNExampleApp-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
"${PODS_ROOT}/Anyline/AnylineSDK_iOS_53.2.0/Framework/AnylineResources.bundle",
"${PODS_ROOT}/Anyline/AnylineSDK_iOS_53.3.0/Framework/AnylineResources.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
Expand Down Expand Up @@ -347,7 +347,7 @@
INFOPLIST_FILE = RNExampleApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 53.2.0;
MARKETING_VERSION = 53.3.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -380,7 +380,7 @@
INFOPLIST_FILE = RNExampleApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 53.2.0;
MARKETING_VERSION = 53.3.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
2 changes: 1 addition & 1 deletion example/RNExampleApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-example-app",
"version": "53.2.0",
"version": "53.3.0",
"private": true,
"scripts": {
"initProject": "yarn add expo && yarn add ../../plugin",
Expand Down
2 changes: 1 addition & 1 deletion plugin/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ repositories {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'io.anyline:anylinesdk:53.2.0'
implementation 'io.anyline:anylinesdk:53.3.0'
implementation "com.facebook.react:react-native:+"
implementation("com.google.android.material:material:1.9.0")
implementation 'androidx.multidex:multidex:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
public static final String REACT_CLASS = "AnylineSDKPlugin";
public static final String EXTRA_LICENSE_KEY = "EXTRA_LICENSE_KEY";
public static final String EXTRA_CONFIG_JSON = "EXTRA_CONFIG_JSON";
public static final String EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS = "EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS";
public static final String EXTRA_SCAN_MODE = "EXTRA_SCAN_MODE";
public static final String EXTRA_ERROR_MESSAGE = "EXTRA_ERROR_MESSAGE";
public static final String EXTRA_OCR_CONFIG_JSON = "EXTRA_OCR_CONFIG_JSON";
Expand All @@ -53,6 +54,7 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
private Promise promise;
private String returnMethod;
private String config;
private String scanViewInitializationParameters;
private AssetContextJsonParser assetContextJsonParser;

private static WrapperConfig wrapperConfig;
Expand Down Expand Up @@ -175,10 +177,16 @@ public void resetUpdate() {

@ReactMethod
public void setup(String config, String scanMode, Callback onResultReact, Callback onErrorReact) {
setupWithInitializationParameters(null, config, scanMode, onResultReact, onErrorReact);
}

@ReactMethod
public void setupWithInitializationParameters(String initializationParameters, String config, String scanMode, Callback onResultReact, Callback onErrorReact) {
onResultCallback = onResultReact;
onErrorCallback = onErrorReact;
this.returnMethod = "callback";
this.config = config;
this.scanViewInitializationParameters = initializationParameters;

routeScanMode(scanMode);
}
Expand Down Expand Up @@ -226,9 +234,14 @@ public void exportCachedEvents(final Promise promise) {

@ReactMethod
public void setupPromise(String config, String scanMode, final Promise promise) {
setupPromiseWithInitializationParameters(null, config, scanMode, promise);
}
@ReactMethod
public void setupPromiseWithInitializationParameters(String initializationParameters, String config, String scanMode, final Promise promise) {
this.promise = promise;
this.returnMethod = "promise";
this.config = config;
this.scanViewInitializationParameters = initializationParameters;

routeScanMode(scanMode);
}
Expand Down Expand Up @@ -281,13 +294,14 @@ private void scan() throws LicenseException, JSONException {

if (optionsJSONObject != null) {
intent.putExtra(
EXTRA_ENABLE_BARCODE_SCANNING,
optionsJSONObject.optBoolean("nativeBarcodeEnabled", false)
EXTRA_ENABLE_BARCODE_SCANNING,
optionsJSONObject.optBoolean("nativeBarcodeEnabled", false)
);
}

intent.putExtra(EXTRA_LICENSE_KEY, license);
intent.putExtra(EXTRA_CONFIG_JSON, configObject.toString());
intent.putExtra(EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS, scanViewInitializationParameters);

ResultReporter.setListener(this);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.anyline.reactnative;

import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_CONFIG_JSON;
import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS;
import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_ERROR_MESSAGE;
import static com.anyline.reactnative.AnylineSDKPlugin.RESULT_ERROR;
import static io.anyline2.sdk.extension.ScanViewInitializationParametersExtensionKt.getScanViewInitializationParametersFromJsonObject;

import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand All @@ -29,6 +31,7 @@
import java.util.Timer;
import java.util.TimerTask;

import io.anyline.plugin.config.ScanViewInitializationParameters;
import io.anyline2.ScanResult;
import io.anyline2.view.ScanView;
import io.anyline2.viewplugin.ScanViewPlugin;
Expand Down Expand Up @@ -98,7 +101,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setupChangeOrientationButton(configJSON);
setupCustomUIFeedback(configJSON);

scanView.init(configJSON);
String initializationParametersString = getIntent().getStringExtra(EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS);
if (initializationParametersString != null) {
ScanViewInitializationParameters scanViewInitializationParameters =
getScanViewInitializationParametersFromJsonObject(
this,
new JSONObject(initializationParametersString));
scanView.init(configJSON, scanViewInitializationParameters);
}
else {
scanView.init(configJSON);
}

ViewPluginBase viewPluginBase = scanView.getScanViewPlugin();

Expand Down
1 change: 1 addition & 0 deletions plugin/ios/ALNFCScanViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithLicensekey:(NSString *)licensekey
configuration:(NSDictionary *)anylineConfig
uiConfig:(ALJSONUIConfiguration *)uiConfig
initializationParamsStr:(NSString *)initializationParamsStr
finished:(ALPluginCallback)callback;
@end

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

@property (nonatomic, nullable) NSString *initializationParamsStr;

@end

Expand All @@ -56,13 +57,14 @@ @implementation ALNFCScanViewController
- (instancetype)initWithLicensekey:(NSString *)licensekey
configuration:(NSDictionary *)anylineConfig
uiConfig:(ALJSONUIConfiguration *)uiConfig
initializationParamsStr:(NSString *)initializationParamsStr
finished:(ALPluginCallback)callback {
if (self = [super init]) {
_licenseKey = licensekey;
_callback = callback;
_config = anylineConfig;
_uiConfig = uiConfig;

_initializationParamsStr = initializationParamsStr;
self.quality = 90;
}
return self;
Expand Down Expand Up @@ -95,12 +97,20 @@ - (void)viewDidLoad {
return;
}

ALScanViewInitializationParameters *initializationParams = nil;
if(_initializationParamsStr){
initializationParams= [ALScanViewInitializationParameters withJSONString:_initializationParamsStr error:&error];
}

[self.view addSubview:self.scanView];

self.resultDict = [[NSMutableDictionary alloc] init];
self.detectedBarcodes = [NSMutableArray array];

self.scanView = [ALScanViewFactory withJSONDictionary:self.config delegate:self error:&error];
self.scanView = [ALScanViewFactory withJSONDictionary:self.config
initializationParams:initializationParams
delegate:self
error:&error];
self.scanView.delegate = self;

[self configureMRZPlugin];
Expand Down
2 changes: 1 addition & 1 deletion plugin/ios/ALPluginHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ typedef void (^ALPluginCallback)(NSDictionary * _Nullable callbackObj, NSError *

@interface ALPluginHelper : NSObject

+ (void)startScan:(NSDictionary *)config finished:(ALPluginCallback)callback;
+ (void)startScan:(NSDictionary *)config initializationParamsStr:(NSString *)initializationParamsStr finished:(ALPluginCallback)callback;

+ (NSString *)saveImageToFileSystem:(UIImage *)image;

Expand Down
6 changes: 4 additions & 2 deletions plugin/ios/ALPluginHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ @implementation ALPluginHelper

#pragma mark - Launch Anyline

+ (void)startScan:(NSDictionary *)config finished:(ALPluginCallback)callback {
+ (void)startScan:(NSDictionary *)config initializationParamsStr:(NSString *)initializationParamsStr finished:(ALPluginCallback)callback {

NSDictionary *pluginConf = config;

Expand All @@ -35,7 +35,8 @@ + (void)startScan:(NSDictionary *)config finished:(ALPluginCallback)callback {
ALNFCScanViewController *nfcScanViewController = [[ALNFCScanViewController alloc] initWithLicensekey:licenseKey
configuration:pluginConf
uiConfig:jsonUIConf
finished:callback];
initializationParamsStr:initializationParamsStr
finished:callback];
if (nfcScanViewController != nil) {
[nfcScanViewController setModalPresentationStyle:UIModalPresentationFullScreen];
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:nfcScanViewController
Expand All @@ -50,6 +51,7 @@ + (void)startScan:(NSDictionary *)config finished:(ALPluginCallback)callback {
ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:licenseKey
configuration:pluginConf
uiConfiguration:jsonUIConf
initializationParamsStr:initializationParamsStr
finished:callback];

if ([pluginConf valueForKey:@"quality"]){
Expand Down
1 change: 1 addition & 0 deletions plugin/ios/ALPluginScanViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithLicensekey:(NSString *)licenseKey
configuration:(NSDictionary *)config
uiConfiguration:(ALJSONUIConfiguration *)JSONUIConfig
initializationParamsStr:(NSString *)initializationParamsStr
finished:(ALPluginCallback)callback;

@end
Expand Down
24 changes: 23 additions & 1 deletion plugin/ios/ALPluginScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ @interface ALPluginScanViewController () <ALScanPluginDelegate, ALViewPluginComp

@property (nonatomic, strong) NSError *scanViewError;

@property (nonatomic, nullable) NSString *initializationParamsStr;

@end


Expand All @@ -49,14 +51,16 @@ - (void)dealloc {
- (instancetype)initWithLicensekey:(NSString *)licenseKey
configuration:(NSDictionary *)config
uiConfiguration:(ALJSONUIConfiguration *)JSONUIConfig
initializationParamsStr:(NSString *)initializationParamsStr
finished:(ALPluginCallback)callback {

if (self = [super init]) {
_licenseKey = licenseKey;
_callback = callback;
_config = config;
_uiConfig = JSONUIConfig;

_initializationParamsStr = initializationParamsStr;

self.quality = 100;
}
return self;
Expand All @@ -79,7 +83,18 @@ - (void)viewDidLoad {
}
}

ALScanViewInitializationParameters *initializationParams = nil;
if(![self isStringEmpty:_initializationParamsStr]){
initializationParams = [ALScanViewInitializationParameters withJSONString: _initializationParamsStr error:&error];
}

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

self.scanView = [ALScanViewFactory withJSONDictionary:self.config
initializationParams:initializationParams
delegate:self
error:&error];

Expand Down Expand Up @@ -434,6 +449,13 @@ - (BOOL)segmentModesAreValid {
return YES;
}

-(BOOL)isStringEmpty:(NSString *)str {
if(str == nil || [str isKindOfClass:[NSNull class]] || str.length==0) {
return YES;
}
return NO;
}

// MARK: - Miscellaneous

- (BOOL)showErrorAlertIfNeeded:(NSError *)error {
Expand Down
4 changes: 2 additions & 2 deletions plugin/ios/AnylineReact.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }

s.source_files = "*.{h,m}"
s.dependency "Anyline", "53.2.0"
s.dependency "Anyline", "53.3.0"
s.dependency "React"

end
end
Loading

0 comments on commit 368c80f

Please sign in to comment.