diff --git a/example/config.xml b/example/config.xml index 1a2441ce..4fe866e0 100644 --- a/example/config.xml +++ b/example/config.xml @@ -1,5 +1,5 @@ - + Anyline Cordova Example diff --git a/example/package-lock.json b/example/package-lock.json index 4b9e477c..dc8ec8be 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -1,5 +1,6 @@ { "name": "anyline-cordova-example", - "version": "7.0.0", + + "version": "7.0.1", "lockfileVersion": 1 } diff --git a/example/package.json b/example/package.json index 6269bf6e..476c2b03 100644 --- a/example/package.json +++ b/example/package.json @@ -1,6 +1,6 @@ { "name": "anyline-cordova-example", - "version": "7.0.0", + "version": "7.0.1", "description": "Cordova plugin for implementing Anyline", "main": "index.js", "scripts": { @@ -21,4 +21,4 @@ "platforms": [] }, "dependencies": {} -} \ No newline at end of file +} diff --git a/plugin/package.json b/plugin/package.json index 480f52e2..5c91a4a6 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -1,6 +1,6 @@ { "name": "io-anyline-cordova", - "version": "7.0.0", + "version": "7.0.1", "description": "The cordova plugin for the Anyline SDK", "cordova": { "id": "io-anyline-cordova", @@ -13,7 +13,8 @@ "keywords": [ "ecosystem:cordova", "cordova-ios", - "cordova-android" + "cordova-android", + "cordova-windows" ], "repository": { "type": "git", diff --git a/plugin/plugin.xml b/plugin/plugin.xml index c2935bd5..d139f071 100644 --- a/plugin/plugin.xml +++ b/plugin/plugin.xml @@ -3,7 +3,7 @@ xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="io-anyline-cordova" - version="7.0.0"> + version="7.0.1"> AnylineSDK @@ -156,6 +156,7 @@ + diff --git a/plugin/src/windows/css/anylineDefault.css b/plugin/src/windows/css/anylineDefault.css index 952aae2b..e9f33292 100644 --- a/plugin/src/windows/css/anylineDefault.css +++ b/plugin/src/windows/css/anylineDefault.css @@ -15,7 +15,7 @@ } #anylineVideoElement{ - position: fixed; + position: relative; z-index: -1; top:0; bottom: 0; @@ -58,11 +58,12 @@ background-color: transparent; } -#anylineFlashButton{ +#anylineFlashButton { position: fixed; z-index: 99999; font-size: 3em; background-color: transparent; - border: solid; + border: none; color: white; -} \ No newline at end of file +} + diff --git a/plugin/src/windows/img/torch_off.png b/plugin/src/windows/img/torch_off.png new file mode 100644 index 00000000..78243703 Binary files /dev/null and b/plugin/src/windows/img/torch_off.png differ diff --git a/plugin/src/windows/img/torch_on.png b/plugin/src/windows/img/torch_on.png new file mode 100644 index 00000000..18c538c2 Binary files /dev/null and b/plugin/src/windows/img/torch_on.png differ diff --git a/plugin/src/windows/lib/arm/Anyline.JS.winmd b/plugin/src/windows/lib/arm/Anyline.JS.winmd index 612ea634..d439099e 100644 Binary files a/plugin/src/windows/lib/arm/Anyline.JS.winmd and b/plugin/src/windows/lib/arm/Anyline.JS.winmd differ diff --git a/plugin/src/windows/lib/arm/Anyline.SDK.dll b/plugin/src/windows/lib/arm/Anyline.SDK.dll index 0a6d8d77..250180b3 100644 Binary files a/plugin/src/windows/lib/arm/Anyline.SDK.dll and b/plugin/src/windows/lib/arm/Anyline.SDK.dll differ diff --git a/plugin/src/windows/lib/arm/Anyline.dll b/plugin/src/windows/lib/arm/Anyline.dll index bf087729..d35061ab 100644 Binary files a/plugin/src/windows/lib/arm/Anyline.dll and b/plugin/src/windows/lib/arm/Anyline.dll differ diff --git a/plugin/src/windows/lib/arm/Anyline.winmd b/plugin/src/windows/lib/arm/Anyline.winmd index 806e86d7..f0db0dd1 100644 Binary files a/plugin/src/windows/lib/arm/Anyline.winmd and b/plugin/src/windows/lib/arm/Anyline.winmd differ diff --git a/plugin/src/windows/lib/x86/Anyline.JS.winmd b/plugin/src/windows/lib/x86/Anyline.JS.winmd index 3a5972bc..d2eeb2b6 100644 Binary files a/plugin/src/windows/lib/x86/Anyline.JS.winmd and b/plugin/src/windows/lib/x86/Anyline.JS.winmd differ diff --git a/plugin/src/windows/lib/x86/Anyline.SDK.dll b/plugin/src/windows/lib/x86/Anyline.SDK.dll index 34cfd775..800da219 100644 Binary files a/plugin/src/windows/lib/x86/Anyline.SDK.dll and b/plugin/src/windows/lib/x86/Anyline.SDK.dll differ diff --git a/plugin/src/windows/scanview.js b/plugin/src/windows/scanview.js index 26559667..9e7a48cd 100644 --- a/plugin/src/windows/scanview.js +++ b/plugin/src/windows/scanview.js @@ -6,23 +6,25 @@ const urlutil = require('cordova/urlutil'); let scanViewController = null; let onErrorGlobal; let baseConfig; - -let TORCH_OFF = "TORCH OFF"; -let TORCH_ON = "TORCH ON"; - +let skipFocus = false; +let TORCH_OFF = ""; +let TORCH_ON = ""; module.exports = { init: function (licenseKey, mode, config, onSuccess, onError, ocrConfig) { - Anyline.JS.Util.Debug.verbosity = 4; + // enable for debug purposes only! + /*Anyline.JS.Util.Debug.verbosity = 4; - /*Anyline.JS.Util.Debug.onlog = function (args) { + Anyline.JS.Util.Debug.onlog = function (args) { console.log(args.toString()); }*/ baseConfig = config; onErrorGlobal = onError; scanViewController = new Anyline.JS.ScanViewController(); + + // set this if you're experiencing memory issues scanViewController.setMemoryCollectionMode(2); scanViewController.onnotifyexception = function (args) { @@ -83,9 +85,10 @@ module.exports = { scanViewController.captureManager.onpreviewrotated = () => { calcVideoRelation(); } - + scanViewController.onnotifyupdatevisualfeedback = function (args) { if (args) { + const argsString = args.toString(); const functionName = argsString.split('(')[0]; const functionArgs = argsString.split('(')[1].split(')')[0]; @@ -149,13 +152,13 @@ function createPreview(cancelButton) { // Scripts if (!document.getElementById("anylineCutoutScript")) { - includeScript(urlutil.makeAbsolute("/www/js/cutout.js"), console.log, 'anylineCutoutScript'); + includeScript(urlutil.makeAbsolute("/www/js/cutout.js"), 'anylineCutoutScript'); } if (!document.getElementById("anylineVFScript")) { - includeScript(urlutil.makeAbsolute("/www/js/visualFeedback.js"), console.log, 'anylineVFScript'); + includeScript(urlutil.makeAbsolute("/www/js/visualFeedback.js"), 'anylineVFScript'); } if (!document.getElementById("anylineUtilScript")) { - includeScript(urlutil.makeAbsolute("/www/js/util.js"), console.log, 'anylineUtilScript'); + includeScript(urlutil.makeAbsolute("/www/js/util.js"), 'anylineUtilScript'); } // Root const anylineRoot = document.createElement('div') @@ -172,7 +175,7 @@ function createPreview(cancelButton) { closeCamera(); destroyPreview(); delete scanViewController; - onErrorGlobal('canceled'); + onErrorGlobal('Canceled'); } anylineRoot.appendChild(cancelBtnElement); @@ -198,22 +201,31 @@ function createPreview(cancelButton) { flashButton.style.visibility = "hidden"; flashButton.innerHTML = TORCH_OFF; flashButton.onclick = function () { + + skipFocus = true; + setTimeout(function () { skipFocus = false; }, 1000); + if (scanViewController == null) return; if (scanViewController.isFlashSupported()) { - if (!scanViewController.isFlashEnabled()) { + if (!scanViewController.captureManager.mediaCapture.videoDeviceController.flashControl.enabled) { var success = scanViewController.enableFlash(); + scanViewController.captureManager.mediaCapture.videoDeviceController.flashControl.enabled = true; // flash is enabled: if (success == true) { flashButton.innerHTML = TORCH_ON; + console.log("Torch enabled."); } } else { var success = scanViewController.disableFlash(); + scanViewController.captureManager.mediaCapture.videoDeviceController.flashControl.enabled = false; // flash is disabled: if (success == true) { flashButton.innerHTML = TORCH_OFF; + console.log("Torch disabled."); } } } + }; flashButtonRoot.appendChild(flashButton); @@ -276,7 +288,7 @@ function enableZoomAndScroll() { document.body.classList.remove('no-scroll'); } -function includeScript(path, cb, id) { +function includeScript(path, id) { if (!(window.MSApp && window.MSApp.execUnsafeLocalFunction)) { var node = document.createElement("script"), okHandler, errHandler; @@ -287,12 +299,10 @@ function includeScript(path, cb, id) { okHandler = function () { this.removeEventListener("load", okHandler); this.removeEventListener("error", errHandler); - cb(path, 'success'); }; errHandler = function (error) { this.removeEventListener("load", okHandler); this.removeEventListener("error", errHandler); - cb("Error loading script: " + path); }; node.addEventListener("load", okHandler); @@ -305,7 +315,6 @@ function includeScript(path, cb, id) { var node = document.createElement("script"); node.text = result; document.body.appendChild(node); - cb(); }); }); } @@ -335,6 +344,26 @@ function readLocalFile(path, cb) { /////////////////////// Camera /////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// +function focus() { + try { + + if (skipFocus) + return; + + if (scanViewController != null) { + if (scanViewController.captureManager.mediaCapture.videoDeviceController.focusControl.supported == true) { + scanViewController.captureManager.mediaCapture.videoDeviceController.focusControl.focusAsync(); + //console.log("Focused successfully."); + } else { + //console.log("Focus is not supported on this device."); + } + } + } + catch (exception) { + console.log("Unable to focus: " + exception); + } +} + // Visual Feedback let VFRender = null; @@ -348,13 +377,24 @@ function openCamera() { } videoElement.src = URL.createObjectURL(scanViewController.captureManager.mediaCapture, { oneTimeOnly: true }); - - videoElement.play().then(function () { - console.log("Playing."); - VFRender = setInterval(function () { - updateFrames(); - }, 100); - }); + try { + videoElement.onplay = function () { + console.log("Playing."); + VFRender = setInterval(function () { + updateFrames(); + }, 100); + }; + videoElement.play(); + + // tap to focus + const anylineRoot = document.getElementById("anylineRoot"); + anylineRoot.onclick = function () { + focus(); + }; + } + catch (ex) { + console.log(ex); + } }); updateFlashButton(); @@ -366,6 +406,10 @@ function openCamera() { // stops the camera function closeCamera() { + const anylineRoot = document.getElementById("anylineRoot"); + if (anylineRoot) + anylineRoot.onclick = null; + scanViewController.cancelScanning(); if (scanViewController.captureManager.mediaCapture == null) return; @@ -387,7 +431,7 @@ function msVisibilityChangeHandler() { closeCamera(); destroyPreview(); delete scanViewController; - onErrorGlobal('canceled'); + onErrorGlobal('Canceled'); } // align & update button from config @@ -448,10 +492,15 @@ function calcVideoRelation() { const canvasElement = document.getElementById("anylineCanvas"); const backgroundElement = document.getElementById("anylineBackground"); const videoElement = document.getElementById("anylineVideoElement"); + const flashElement = document.getElementById("anylineFlashButton"); if (canvasElement == null || backgroundElement == null || videoElement == null) return; + if (flashElement != null) { + flashElement.style.opacity = scanViewController.captureManager.mediaCapture.videoDeviceController.flashControl.supported ? 1.0 : 0.3; + } + // mirror preview & VF when the camera is front-facing if (scanViewController.captureManager.isPreviewMirrored) { @@ -493,11 +542,14 @@ function calcVideoRelation() { const overflowHeight = window.innerWidth / camRelation - window.innerHeight; - videoElement.style.left = 0; - backgroundElement.style.left = 0; - canvasElement.style.left = 0; + videoElement.style.left = 0 + 'px'; + backgroundElement.style.left = 0 + 'px'; + canvasElement.style.left = 0 + 'px'; var oh = -(overflowHeight / 2) + 'px'; backgroundElement.style.top = oh; + + videoElement.style.top = oh; + } // Update Cutout from SDK