From 1d81b4c362d1ffc1bb673c112bfd8d73e1e75041 Mon Sep 17 00:00:00 2001 From: rohitlokhandeanyline Date: Mon, 4 Nov 2024 15:14:10 +0530 Subject: [PATCH] Release 54.2.2 (#96) --- example/config.xml | 2 +- example/package.json | 2 +- plugin/package.json | 2 +- plugin/plugin.xml | 2 +- .../io/anyline/cordova/AnylinePlugin.java | 31 +++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/example/config.xml b/example/config.xml index 797e465..25255fd 100644 --- a/example/config.xml +++ b/example/config.xml @@ -1,5 +1,5 @@ - Anyline Cordova Example diff --git a/example/package.json b/example/package.json index 9847b15..acddc4c 100644 --- a/example/package.json +++ b/example/package.json @@ -1,6 +1,6 @@ { "name": "anyline-cordova-example", - "version": "54.2.1", + "version": "54.2.2", "description": "Cordova plugin for implementing Anyline", "main": "index.js", "scripts": { diff --git a/plugin/package.json b/plugin/package.json index 0c3af04..76e8bc6 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -1,6 +1,6 @@ { "name": "io-anyline-cordova", - "version": "54.2.1", + "version": "54.2.2", "description": "The cordova plugin for the Anyline SDK", "cordova": { "id": "io-anyline-cordova", diff --git a/plugin/plugin.xml b/plugin/plugin.xml index 3bb651b..3786840 100644 --- a/plugin/plugin.xml +++ b/plugin/plugin.xml @@ -1,6 +1,6 @@ + xmlns:android="http://schemas.android.com/apk/res/android" id="io-anyline-cordova" version="54.2.2"> AnylineSDK diff --git a/plugin/src/android/io/anyline/cordova/AnylinePlugin.java b/plugin/src/android/io/anyline/cordova/AnylinePlugin.java index 4a30a7c..3fa1b66 100644 --- a/plugin/src/android/io/anyline/cordova/AnylinePlugin.java +++ b/plugin/src/android/io/anyline/cordova/AnylinePlugin.java @@ -138,6 +138,7 @@ private void onError(String errorMessage) { private void startScanning(String action, JSONArray args) { if (action.equals("scan")) { + deleteAllPreviousScanResultImages(cordova.getContext()); scan(ScanActivity.class, REQUEST_ANYLINE_4, args); } else { this.callbackContext.error(getString("error_unkown_scan_mode") + " " + action); @@ -203,4 +204,34 @@ private void getPluginVersion() { private void getSDKVersion() { onResult(at.nineyards.anyline.BuildConfig.VERSION_NAME, true); } + + /** + * This function removes all previous scan result images from disk, either from external + * or internal files dir, e.g.: + * /sdcard/Android/[applicationId]/files/results/image1729849635965 + */ + private void deleteAllPreviousScanResultImages(Context context) { + String imagePath = ""; + if (context.getExternalFilesDir(null) != null) { + imagePath = context + .getExternalFilesDir(null) + .toString() + "/results/"; + + } else if (context.getFilesDir() != null) { + imagePath = context + .getFilesDir() + .toString() + "/results/"; + } + + File resultFolder = new File(imagePath); + File[] files = resultFolder.listFiles(); + if (files != null) { + for (File file : files) { + if (file.getName().startsWith("image")) { + file.delete(); + } + } + } + } + }