barkoder-nativescript
Advanced tools
Comparing version 1.5.2 to 1.5.6
@@ -5,3 +5,6 @@ import { BarkoderConstants } from "./barkoder-nativescript.common"; | ||
import { BarkoderView } from "./barkoder-nativescript.common"; | ||
import { ImageSource } from '@nativescript/core'; | ||
const androidSupport = | ||
@@ -58,2 +61,31 @@ global.androidx && global.androidx.appcompat | ||
scanImage( | ||
base64Image: string, | ||
BarkoderResultCallback: BarkoderConstants.BarkoderResultCallback | ||
): void { | ||
const BarkoderHelper = com.barkoder.BarkoderHelper; | ||
// Convert base64 string to bitmap | ||
const bitmap = ImageSource.fromBase64Sync(base64Image).android; | ||
// Create an instance of BarkoderResultCallback | ||
const resultCallback = new com.barkoder.interfaces.BarkoderResultCallback({ | ||
scanningFinished: ( | ||
results: any[], | ||
thumbnails: any[], | ||
resultImage: any | ||
) => { | ||
BarkoderResultCallback.scanningFinished( | ||
results, | ||
thumbnails, | ||
resultImage | ||
); | ||
}, | ||
}); | ||
// Pass the result callback correctly to scanImage | ||
BarkoderHelper.scanImage(bitmap, this.bkdView.config, resultCallback, context); | ||
} | ||
/** | ||
@@ -129,2 +161,15 @@ * Halts the barcode scanning process, stopping the camera from capturing and processing barcode information | ||
setIdDocumentMasterChecksumEnabled(enabled: boolean): void { | ||
if(enabled){ | ||
this.bkdView.config.getDecoderConfig().IDDocument.masterChecksumType = com.barkoder.Barkoder.StandardChecksumType.Enabled | ||
} else { | ||
this.bkdView.config.getDecoderConfig().IDDocument.masterChecksumType = com.barkoder.Barkoder.StandardChecksumType.Disabled | ||
} | ||
} | ||
isIdDocumentMasterChecksumEnabled(): boolean { | ||
return this.bkdView.config.getDecoderConfig().IDDocument.masterChecksumType === com.barkoder.Barkoder.StandardChecksumType.Enabled; | ||
} | ||
/** | ||
@@ -997,2 +1042,22 @@ * Sets the color of the lines outlining the Region of Interest (ROI) for barcode scanning on the camera feed | ||
setQRDpmModeEnabled(dpmModeEnabled: boolean): void { | ||
this.bkdView.config.getDecoderConfig().QR.dpmMode = dpmModeEnabled; | ||
} | ||
setQRMicroDpmModeEnabled(dpmModeEnabled: boolean): void { | ||
this.bkdView.config.getDecoderConfig().QRMicro.dpmMode = dpmModeEnabled; | ||
} | ||
isDatamatrixDpmModeEnabled(): any { | ||
return this.bkdView.config.getDecoderConfig().Datamatrix.dpmMode; | ||
} | ||
isQRDpmModeEnabled() : any { | ||
return this.bkdView.config.getDecoderConfig().QR.dpmMode | ||
} | ||
isQRMicroDpmModeEnabled() : any { | ||
return this.bkdView.config.getDecoderConfig().QRMicro.dpmMode | ||
} | ||
/** | ||
@@ -999,0 +1064,0 @@ * Sets whether the deblurring feature for UPC/EAN barcodes is enabled |
@@ -379,2 +379,57 @@ import { Observable } from 'tns-core-modules/data/observable'; | ||
export class QRBarcodeConfig { | ||
enabled?: boolean; | ||
dpmMode?: number; | ||
private minLength?: number; | ||
private maxLength?: number; | ||
constructor(config: Partial<QRBarcodeConfig>) { | ||
Object.assign(this, config); | ||
} | ||
toMap() { | ||
let map: { [key: string]: any } = { | ||
"enabled": this.enabled, | ||
"dpmMode": this.dpmMode, | ||
"minimumLength": this.minLength, | ||
"maximumLength": this.maxLength, | ||
} | ||
return map; | ||
} | ||
setLengthRange(minLength: number, maxLength: number) { | ||
this.minLength = minLength; | ||
this.maxLength = maxLength; | ||
} | ||
} | ||
export class QRMicroBarcodeConfig { | ||
enabled?: boolean; | ||
dpmMode?: number; | ||
private minLength?: number; | ||
private maxLength?: number; | ||
constructor(config: Partial<QRMicroBarcodeConfig>) { | ||
Object.assign(this, config); | ||
} | ||
toMap() { | ||
let map: { [key: string]: any } = { | ||
"enabled": this.enabled, | ||
"dpmMode": this.dpmMode, | ||
"minimumLength": this.minLength, | ||
"maximumLength": this.maxLength, | ||
} | ||
return map; | ||
} | ||
setLengthRange(minLength: number, maxLength: number) { | ||
this.minLength = minLength; | ||
this.maxLength = maxLength; | ||
} | ||
} | ||
export class GeneralSettings { | ||
@@ -381,0 +436,0 @@ threadsLimit?: number; |
@@ -25,2 +25,30 @@ import { BarkoderConstants } from "./barkoder-nativescript.common"; | ||
scanImage(base64Image: string, callback: BarkoderConstants.BarkoderResultCallback): void { | ||
// Convert Base64 to UIImage | ||
const uiImage = this.convertBase64ToUIImage(base64Image); | ||
const resultDelegate = new BarkoderViewWraper(callback); | ||
ios.delegate = resultDelegate; | ||
BarkoderHelper.scanImageBkdConfigResultDelegate(uiImage,this.bkdView.config, resultDelegate) | ||
} | ||
convertBase64ToUIImage(base64String: string): UIImage | null { | ||
if (!base64String) { | ||
console.warn('Invalid Base64 string provided'); | ||
return null; | ||
} | ||
// Decode the Base64 string to NSData | ||
const imageData = NSData.alloc().initWithBase64EncodedStringOptions(base64String, 0); // Using 0 as the option | ||
if (!imageData) { | ||
console.warn('Failed to decode Base64 string to NSData'); | ||
return null; | ||
} | ||
// Create a UIImage from NSData | ||
const uiImage = UIImage.imageWithData(imageData); | ||
return uiImage; | ||
} | ||
/** | ||
@@ -162,2 +190,14 @@ * Halts the barcode scanning process, stopping the camera from capturing and processing barcode information | ||
setIdDocumentMasterChecksumEnabled(enabled: boolean): void { | ||
if (enabled) { | ||
this.bkdView.config.decoderConfig.idDocument.masterChecksum = 1 | ||
} else { | ||
this.bkdView.config.decoderConfig.idDocument.masterChecksum = 0 | ||
} | ||
} | ||
isIdDocumentMasterChecksumEnabled(): boolean { | ||
return this.bkdView.config.decoderConfig.idDocument.masterChecksum === 1 | ||
} | ||
/** | ||
@@ -988,2 +1028,30 @@ * Defines the Region of Interest (ROI) on the camera preview for barcode scanning, specifying an area where the application focuses on detecting barcodes | ||
setQRDpmModeEnabled(dpmModeEnabled: boolean): void { | ||
if (dpmModeEnabled) { | ||
this.bkdView.config.decoderConfig.qr.dpmMode = 1; | ||
} else if (dpmModeEnabled == false) { | ||
this.bkdView.config.decoderConfig.qr.dpmMode = 0; | ||
} | ||
} | ||
setQRMicroDpmModeEnabled(dpmModeEnabled: boolean): void { | ||
if (dpmModeEnabled) { | ||
this.bkdView.config.decoderConfig.qrMicro.dpmMode = 1; | ||
} else if (dpmModeEnabled == false) { | ||
this.bkdView.config.decoderConfig.qrMicro.dpmMode = 0; | ||
} | ||
} | ||
isDatamatrixDpmModeEnabled(): any { | ||
return this.bkdView.config.decoderConfig.datamatrix.dpmMode; | ||
} | ||
isQRDpmModeEnabled(): any { | ||
return this.bkdView.config.decoderConfig.qr.dpmMode | ||
} | ||
isQRMicroDpmModeEnabled(): any { | ||
return this.bkdView.config.decoderConfig.qrMicro.dpmMode | ||
} | ||
/** | ||
@@ -990,0 +1058,0 @@ * Retrieves the delay in milliseconds for considering duplicate barcodes during scanning |
{ | ||
"name": "barkoder-nativescript", | ||
"version": "1.5.2", | ||
"version": "1.5.6", | ||
"description": "Nativescript support for Barkoder - a Barcode Scanner SDK for the modern enterprise.", | ||
@@ -5,0 +5,0 @@ "main": "barkoder-nativescript", |
@@ -415,2 +415,10 @@ { | ||
}, | ||
"QR": { | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
"QR Micro": { | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
"general": { | ||
@@ -675,3 +683,4 @@ "maxThreads": 2, | ||
"ID Document": { | ||
"enabled": true | ||
"enabled": true, | ||
"masterChecksum": 0 | ||
}, | ||
@@ -720,6 +729,8 @@ "general": { | ||
"QR": { | ||
"enabled": true | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
"QR Micro": { | ||
"enabled": true | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
@@ -726,0 +737,0 @@ "Code 128": { |
@@ -415,2 +415,10 @@ { | ||
}, | ||
"QR": { | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
"QR Micro": { | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
"general": { | ||
@@ -675,3 +683,4 @@ "maxThreads": 2, | ||
"ID Document": { | ||
"enabled": true | ||
"enabled": true, | ||
"masterChecksum": 0 | ||
}, | ||
@@ -720,6 +729,8 @@ "general": { | ||
"QR": { | ||
"enabled": true | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
"QR Micro": { | ||
"enabled": true | ||
"enabled": true, | ||
"dpmMode": 1 | ||
}, | ||
@@ -726,0 +737,0 @@ "Code 128": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53533414
57
23260