From 96d46e0cbf4cfab8bbc15da02d56beefe37a9824 Mon Sep 17 00:00:00 2001 From: Daniel Kim Date: Thu, 23 Nov 2023 20:42:56 +0900 Subject: [PATCH 1/4] return empty barcode array when none found. readbarcodesFromImage would return nothing(result or error) on an image not containing any barcode. --- packages/barcode-scanning/ios/Plugin/BarcodeScanner.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/barcode-scanning/ios/Plugin/BarcodeScanner.swift b/packages/barcode-scanning/ios/Plugin/BarcodeScanner.swift index 62d925d..3bb4864 100644 --- a/packages/barcode-scanning/ios/Plugin/BarcodeScanner.swift +++ b/packages/barcode-scanning/ios/Plugin/BarcodeScanner.swift @@ -68,6 +68,7 @@ typealias MLKitBarcodeScanner = MLKitBarcodeScanning.BarcodeScanner } CAPLog.print("\(features?.count ?? 0)") guard let features = features, !features.isEmpty else { + completion(features, nil) return } completion(features, nil) From 081c7408d2951e3aa0b302d18ce2c281b3fa8ba8 Mon Sep 17 00:00:00 2001 From: Daniel Kim Date: Thu, 23 Nov 2023 20:45:14 +0900 Subject: [PATCH 2/4] fix missing cornerPoints --- .../ios/Plugin/BarcodeScannerHelper.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/barcode-scanning/ios/Plugin/BarcodeScannerHelper.swift b/packages/barcode-scanning/ios/Plugin/BarcodeScannerHelper.swift index 47f38da..17a8cbb 100644 --- a/packages/barcode-scanning/ios/Plugin/BarcodeScannerHelper.swift +++ b/packages/barcode-scanning/ios/Plugin/BarcodeScannerHelper.swift @@ -39,7 +39,14 @@ public class BarcodeScannerHelper { cornerPointsResult.append(value) } } - + else if let cornerPoints = barcode.cornerPoints { + for cornerPoint in cornerPoints { + var value = [Int]() + value.append(Int(cornerPoint.cgPointValue.x)) + value.append(Int(cornerPoint.cgPointValue.y)) + cornerPointsResult.append(value) + } + } var result = JSObject() if let rawData = barcode.rawData { result["bytes"] = convertDataToJsonArray(rawData) From bfc8a7462f3a1e4c544bf5da1e1aefaf9c82d85f Mon Sep 17 00:00:00 2001 From: Daniel Kim Date: Fri, 24 Nov 2023 16:29:02 +0900 Subject: [PATCH 3/4] include raw cornerPoints for methods other than startScan --- .../mlkit/barcodescanning/BarcodeScannerHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java b/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java index 413aa7c..defecb4 100644 --- a/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java +++ b/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java @@ -30,7 +30,14 @@ public static JSObject createBarcodeResultForBarcode(@NonNull Barcode barcode, @ cornerPointsResult.put(cornerPointResult); } } - + else if (cornerPoints != null) { + for (int i = 0; i < cornerPoints.length; i++) { + JSArray cornerPointResult = new JSArray(); + cornerPointResult.put(cornerPoints[i].x); + cornerPointResult.put(cornerPoints[i].y); + cornerPointsResult.put(cornerPointResult); + } + } JSObject result = new JSObject(); result.put("bytes", convertByteArrayToJsonArray(barcode.getRawBytes())); if (cornerPoints != null) { From 6a2b2aacb0fe49ad240d9c0376944edb5f02062d Mon Sep 17 00:00:00 2001 From: Nurfgun Date: Fri, 24 Nov 2023 16:39:29 +0900 Subject: [PATCH 4/4] version up --- packages/barcode-scanning/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/barcode-scanning/package.json b/packages/barcode-scanning/package.json index 482b5fd..8b2222a 100644 --- a/packages/barcode-scanning/package.json +++ b/packages/barcode-scanning/package.json @@ -1,6 +1,6 @@ { "name": "@capacitor-mlkit/barcode-scanning", - "version": "5.3.0", + "version": "5.3.1", "description": "Capacitor plugin for ML Kit Barcode Scanning.", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js",