Skip to content

Commit

Permalink
Release 47.1.0 (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickAnyline authored Jun 16, 2023
1 parent 948b9a9 commit fdb1a0f
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 57 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="46.1.0" ios-CFBundleVersion="1"
<widget id="com.anyline.examples.cordova" version="47.1.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
11 changes: 8 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "anyline-cordova-example",
"version": "46.1.0",
"version": "47.1.0",
"description": "Cordova plugin for implementing Anyline",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"reinstall": "cordova platform remove android && cordova plugin remove io-anyline-cordova && cordova platform add android@latest && cordova plugin add ../plugin",
"addPlugins": "cordova plugin add cordova-plugin-android-permissions && cordova plugin add cordova-plugin-device && cordova plugin add ../plugin",
"reinstall": "cordova platform remove android && cordova plugin remove io-anyline-cordova && cordova platform add android@latest && yarn addPlugins",
"reinstall-ios": "cordova platform remove ios; cordova plugin remove io-anyline-cordova; cordova platform add ios@latest; cordova plugin add ../plugin",
"reinstall-win": "cordova platform remove windows && cordova plugin remove io-anyline-cordova && cordova platform add windows@latest && cordova plugin add ../plugin",
"overwrite": "rm -R ../src/android/io && rm -R ../src/android/res && cp -R platforms/android/src/io ../src/android/ && cp -R platforms/android/res ../src/android",
Expand All @@ -20,6 +21,8 @@
"ANDROIDX_WEBKIT_VERSION": "1.4.0"
},
"cordova-plugin-dialogs": {},
"cordova-plugin-android-permissions": {},
"cordova-plugin-device": {},
"io-anyline-cordova": {}
},
"platforms": [
Expand All @@ -28,8 +31,10 @@
]
},
"devDependencies": {
"cordova-android": "^11.0.0",
"cordova-android": "^12.0.0",
"cordova-ios": "^6.3.0",
"cordova-plugin-android-permissions": "^1.1.5",
"cordova-plugin-device": "^2.1.0",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-file": "^7.0.0",
"io-anyline-cordova": "file:../plugin",
Expand Down
1 change: 0 additions & 1 deletion example/www/assets/anyline_austrian_driving_license.ale

This file was deleted.

1 change: 0 additions & 1 deletion example/www/assets/anyline_driving_license.ale

This file was deleted.

84 changes: 60 additions & 24 deletions example/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,27 @@
}

function onDeviceReady() {

changeLoadingState(true);

showSDKVersion();
requestCameraPermissionOnAndroid();
}

cordova.exec(
function (initWasSuccessful) {
console.log(initWasSuccessful);
changeLoadingState(false);
},
function (err) {
console.error(err);
var errorMessage = 'The Anyline SDK could not be initialized. Please check if you have a valid license key.';
navigator.notification.alert(errorMessage, null, 'Error', []);
},
"AnylineSDK",
"initAnylineSDK",
[licenseKey]
);
function changeLoadingState(isLoading = false) {
var buttons = document.getElementsByClassName('formButton');
for (var i = 0; i < buttons.length; i++) {
buttons[i].disabled = isLoading;
}
localStorage.setItem("hasStartedAnyline", isLoading);
}

function showSDKVersion() {
console.error("showSDKVersion");
cordova.exec(
function (sdkVersion) {
showMRZIfiOS();
var div = document.getElementById('SDK');
div.innerHTML = "<p>Anyline SDK Version: " + sdkVersion + "</p>";
initAnylineSDK();
},
function (err) {
console.error(err);
Expand All @@ -61,14 +55,6 @@
);
}

function changeLoadingState(isLoading = false) {
var buttons = document.getElementsByClassName('formButton');
for (var i = 0; i < buttons.length; i++) {
buttons[i].disabled = isLoading;
}
localStorage.setItem("hasStartedAnyline", isLoading);
}

function showMRZIfiOS() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Windows Phone must come first because its UA also contains "Android"
Expand All @@ -83,6 +69,56 @@
document.getElementById(1234).style.display = 'span';
}
}

function initAnylineSDK(){
cordova.exec(
function (initWasSuccessful) {
changeLoadingState(false);
checkLicense();
},
function (err) {
var errorMessage = 'The Anyline SDK could not be initialized. Please check if you have a valid license key.';
navigator.notification.alert(errorMessage, null, 'Error', []);
},
"AnylineSDK",
"initAnylineSDK",
[licenseKey]
);
}

function checkLicense(){
cordova.exec(
function (date) {
console.log(date);
},
function (err) {
console.error(err);
},
"AnylineSDK",
"checkLicense",
[licenseKey]
);
}

function requestCameraPermissionOnAndroid() {
if(device.platform == "Android") {
var permissions = cordova.plugins.permissions;

permissions.hasPermission(permissions.CAMERA, function(status){
if (!status.hasPermission) {
permissions.requestPermission(
permissions.CAMERA,
function(status) {
if(!status.hasPermission) console.warn('Camera permission is needed to use the app!');
},
function() {
console.warn('Camera permission is needed to use the app!');
}
);
}
});
}
}
</script>
</head>

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": "46.1.0",
"version": "47.1.0",
"description": "The cordova plugin for the Anyline SDK",
"cordova": {
"id": "io-anyline-cordova",
Expand Down
2 changes: 1 addition & 1 deletion plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<!-- <resource-file src="src/ios/anyline_sdk/AnylineResources.bundle"/>-->

<!-- Anyline Framework & Resource Bundle CocoaPods-->
<framework src="Anyline" type="podspec" swift-version="4.2" spec="~> 44"/>
<framework src="Anyline" type="podspec" swift-version="4.2" spec="~> 47.0"/>

<!-- <podspec>
<config>
Expand Down
41 changes: 33 additions & 8 deletions 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:46.1.0'
implementation 'io.anyline:anylinesdk:47.1.0'
implementation("com.google.android.material:material:1.4.0-rc01")
}

Expand All @@ -29,21 +29,46 @@ android {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'

def anylineRetainAssetsPattern = '';
// Below is the full list of modules
def all_modules = [
"module_anyline_ocr",
"module_barcode",
"module_document",
"module_energy",
"module_id",
"module_license_plate",
"module_tire"
].toList()

def used_modulesString = ''
new XmlSlurper().parse(file('../app/src/main/res/xml/config.xml')).preference.each {
if (it.@name.text() == 'anyline-retain-assets-pattern') {
anylineRetainAssetsPattern = it.@value.text().toLowerCase()
used_modulesString = it.@value.text().toLowerCase()
}
}

if (!anylineRetainAssetsPattern.empty) {
println "Anyline: retain assets pattern --> $anylineRetainAssetsPattern"
aaptOptions {
retainAssetsPattern "$anylineRetainAssetsPattern"
def used_modules

// Convert the string to a list
if (!used_modulesString.isEmpty()) {
used_modules = used_modulesString.split(":")
}

if (used_modules) {

// All used modules are kept, the rest are discarded (to shrink your app)
all_modules.removeAll(used_modules)

def all_removed_modules = all_modules.join(":")

if (!all_removed_modules.isEmpty()) {
aaptOptions {
println "Anyline: ignore assets pattern --> $all_removed_modules"
ignoreAssetsPattern all_removed_modules
}
}
}
}

}

ext.postBuildExtras = {
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/android/io/anyline/cordova/AnylinePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo

private void initAnylineSDK(String licenseKey) throws LicenseException {
Activity activity = cordova.getActivity();
AnylineSdk.init(licenseKey, activity);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, "Anyline SDK init was successful."));
AnylineSdk.init(licenseKey, activity, "www/assets");
onResult(new PluginResult(PluginResult.Status.OK, "Anyline SDK init was successful."), true);
}

private void getLicenseExpirationDate(String license) throws LicenseException {
Expand Down
29 changes: 14 additions & 15 deletions plugin/www/anyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@
*/
function Anyline() {}

/**
* Scan a credit card with card.io.
*
*
* @parameter options: an object; may be {}. Sample options object:
* {licenseKey: '', config: {...}}
*
* @parameter onSuccess: a callback function that accepts a response object; response keys
* include ...
*
* @parameter onFailure: a zero argument callback function that will be called if the user
* cancels card scanning.
*/
Anyline.prototype.scan = function(options, onSuccess, onFailure) {
cordova.exec(onSuccess, onFailure, "AnylineSDK", "scan", [options.licenseKey, options.config]);
Anyline.prototype.checkLicense = function(licenseKey, onSuccess, onFailure) {
cordova.exec(onSuccess, onFailure, "AnylineSDK", "checkLicense", [licenseKey]);
};

Anyline.prototype.initAnylineSDK = function(licenseKey, onSuccess, onFailure) {
cordova.exec(onSuccess, onFailure, "AnylineSDK", "initAnylineSDK", [licenseKey]);
};

Anyline.prototype.getSDKVersion = function(onSuccess, onFailure) {
cordova.exec(onSuccess, onFailure, "AnylineSDK", "getSDKVersion", []);
};

Anyline.prototype.scan = function(config, onSuccess, onFailure) {
cordova.exec(onSuccess, onFailure, "AnylineSDK", "scan", [config]);
};

/**
Expand Down

0 comments on commit fdb1a0f

Please sign in to comment.