Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

plugins {
id("com.android.application") version "8.3.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.25" apply false
id("com.android.application") version "8.9.0" apply false
id("org.jetbrains.kotlin.android") version "2.2.21" apply false
id( "org.jetbrains.kotlin.plugin.compose") version "2.2.21" apply false
}

tasks.register("clean", Delete::class.java) {
Expand Down
3 changes: 2 additions & 1 deletion example_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id( "org.jetbrains.kotlin.plugin.compose")
}

android {
Expand Down Expand Up @@ -54,7 +55,7 @@ dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.1.4")


def sdkVersion = "7.1.2"
def sdkVersion = "8.0.0.49-STAGING-SNAPSHOT"

implementation("io.scanbot:scanbot-barcode-scanner-sdk:$sdkVersion")
implementation("io.scanbot:rtu-ui-v2-barcode:$sdkVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.scanbot.example.sdk.barcode

import android.app.Application
import io.scanbot.sap.IScanbotSDKLicenseErrorHandler
import io.scanbot.sap.SdkFeature
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDKInitializer
import io.scanbot.sdk.pdf.PdfImagesExtractor
Expand All @@ -26,11 +25,9 @@ class ExampleApplication : Application() {
.withLogging(true)
// TODO 2/2: Enable the Scanbot Barcode SDK license key
//.license(this, licenseKey)
.licenceErrorHandler(IScanbotSDKLicenseErrorHandler { status, feature, statusMessage ->
.licenseErrorHandler (IScanbotSDKLicenseErrorHandler { status, feature, statusMessage ->
LoggerProvider.logger.d("ExampleApplication", "+++> License status: ${status.name}. Status message: $statusMessage")
if (feature != SdkFeature.NoSdkFeature) {
LoggerProvider.logger.d("ExampleApplication", "+++> Feature not available: ${feature.name}")
}
LoggerProvider.logger.d("ExampleApplication", "+++> Feature not available: ${feature.name}")
})
.pdfImagesExtractorType(PdfImagesExtractor.Type.PDFIUM) // select PDFium or default android pdf library to extract barcode image
// Uncomment to switch back to the legacy camera approach in Ready-To-Use UI screens
Expand All @@ -43,7 +40,7 @@ class ExampleApplication : Application() {
val licenseInfo = ScanbotBarcodeScannerSDK(this).licenseInfo
LoggerProvider.logger.d("ExampleApplication", "License status: ${licenseInfo.status}")
LoggerProvider.logger.d("ExampleApplication", "License isValid: ${licenseInfo.isValid}")
LoggerProvider.logger.d("ExampleApplication", "License expirationDate: ${licenseInfo.expirationDate}")
LoggerProvider.logger.d("ExampleApplication", "License expirationDate: ${licenseInfo.expirationDateString}")
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package io.scanbot.example.sdk.barcode.doc_code_snippet
// TODO: add URLs here

// @Tag("Configuring RTU UI v2 Barcode AR overlay snippet")
import io.scanbot.sdk.barcode.BarcodeFormatCommonConfiguration
import io.scanbot.sdk.barcode.BarcodeFormats
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerConfiguration
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerScreenConfiguration
Expand Down Expand Up @@ -39,7 +40,7 @@ fun arOverlayUseCaseSnippet() {
}

// Set an array of accepted barcode types.
this.scannerConfiguration.barcodeFormats = BarcodeFormats.common
this.scannerConfiguration.barcodeFormatConfigurations = listOf(BarcodeFormatCommonConfiguration(formats = BarcodeFormats.common))

// Configure other parameters as needed.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import java.util.EnumSet

fun barcodeScannerWithAdvancedConfigSnippet(context: Context) {
// @Tag("Advanced configuring Barcode Scanner")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()

var configs = mutableListOf<BarcodeFormatConfigurationBase>()

Expand Down Expand Up @@ -133,7 +133,7 @@ fun barcodeFormatIndividualSimplifiedConfigurationSnippet(context: Context) {

fun barcodeParsersConfigurationSnippet(context: Context) {
// @Tag("Configuring parsers in Barcode Scanner")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()

var configs = mutableListOf<BarcodeFormatConfigurationBase>()

Expand All @@ -149,7 +149,7 @@ fun barcodeParsersConfigurationSnippet(context: Context) {

fun barcodeRegexpConfigurationSnippet(context: Context) {
// @Tag("Configuring regexp in Barcode Scanner")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()

var configs = mutableListOf<BarcodeFormatConfigurationBase>()
val baseConfig = BarcodeFormatCommonConfiguration.default().copy(
Expand All @@ -176,7 +176,7 @@ fun barcodeRegexpConfigurationSnippet(context: Context) {

fun barcodeTinyBarcodeConfigurationSnippet(context: Context) {
// @Tag("Configuring tiny barcodes in Barcode Scanner")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()

barcodeScanner.setConfiguration(barcodeScanner.copyCurrentConfiguration().apply {
// Example of adding a specific configuration for parsed documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import io.scanbot.sdk.barcode.entity.SEPA
import io.scanbot.sdk.barcode.entity.SwissQR
import io.scanbot.sdk.barcode.entity.VCard
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK
import io.scanbot.sdk.image.ImageRef

fun handlingResult(bitmap: Bitmap, context: Context) {
fun handlingResult(imageRef: ImageRef, context: Context) {
// @Tag("Handling the Result")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val result = barcodeScanner.scanFromBitmap(bitmap, 0)
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()
val result = barcodeScanner.run(imageRef).getOrNull()
result?.barcodes?.forEach { barcodeItem ->
// Handle the detected barcode(s) from result
val barcodeText = barcodeItem.text
Expand All @@ -42,10 +43,10 @@ fun handlingResult(bitmap: Bitmap, context: Context) {
// @EndTag("Handling the Result")
}

fun handlingParsedDocumentsResult(bitmap: Bitmap, context: Context) {
fun handlingParsedDocumentsResult(imageRef: ImageRef, context: Context) {
// @Tag("Handling the parsed document result")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val result = barcodeScanner.scanFromBitmap(bitmap, 0)
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()
val result = barcodeScanner.run(imageRef).getOrNull()
result?.barcodes?.forEach { barcodeItem ->
barcodeItem.extractedDocument?.let { document ->
when (document.type.name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package io.scanbot.example.sdk.barcode.doc_code_snippet

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import io.scanbot.common.onSuccess
import io.scanbot.example.sdk.barcode.R
import io.scanbot.sdk.barcode.BarcodeFormats
import io.scanbot.sdk.barcode.BarcodeItem
Expand All @@ -22,8 +23,8 @@ import io.scanbot.sdk.barcode.ui.IBarcodeScannerViewCallback
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK
import io.scanbot.sdk.camera.CameraModule
import io.scanbot.sdk.camera.CaptureInfo
import io.scanbot.sdk.camera.FrameHandlerResult
import io.scanbot.sdk.common.AspectRatio
import io.scanbot.sdk.geometry.AspectRatio
import io.scanbot.sdk.image.ImageRef

class BarcodeScannerClassicUiSnippetActivity : AppCompatActivity() {

Expand All @@ -35,7 +36,7 @@ class BarcodeScannerClassicUiSnippetActivity : AppCompatActivity() {

// @Tag("Barcode Classic UI view snippet")
barcodeScannerView = findViewById<BarcodeScannerView>(R.id.barcode_scanner_view)!!
val barcodeScanner = ScanbotBarcodeScannerSDK(this).createBarcodeScanner()
val barcodeScanner = ScanbotBarcodeScannerSDK(this).createBarcodeScanner().getOrThrow()

// modify config as needed
barcodeScanner.setConfiguration(
Expand All @@ -51,24 +52,27 @@ class BarcodeScannerClassicUiSnippetActivity : AppCompatActivity() {
barcodeScannerView.apply {
initCamera()
initScanningBehavior(barcodeScanner,
{ result ->
if (result is FrameHandlerResult.Success) {
{ result, frame ->
result.onSuccess {
// process the scanned result here
// handleSuccess(result)
}
false
},
object : IBarcodeScannerViewCallback {
override fun onCameraOpen() {
// barcodeScannerView.viewController.useFlash(flashEnabled)
}

override fun onPictureTaken(image: ByteArray, captureInfo: CaptureInfo) {
override fun onPictureTaken(
image: ImageRef,
captureInfo: CaptureInfo
) {
// process the full size images taken by BarcodeAutoSnappingController here
// to enable auto snapping use the following command:
// barcodeScannerView.viewController.autoSnappingEnabled = true
}

override fun onCameraOpen() {
// barcodeScannerView.viewController.useFlash(flashEnabled)
}

override fun onSelectionOverlayBarcodeClicked(barcodeItem: BarcodeItem) {
// handle the barcode item selection here
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.widget.Toast
import io.scanbot.sdk.barcode.BarcodeScanner
import io.scanbot.sdk.barcode.BarcodeScannerResult
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK
import io.scanbot.sdk.image.ImageRef

fun scanOnImageSnippet(context: Context) {
// @Tag("Creating the Scanner")
Expand All @@ -29,11 +30,11 @@ fun scanOnImageSnippet(context: Context) {
fun processImageSnippet(
sdk: ScanbotBarcodeScannerSDK,
barcodeDetector: BarcodeScanner,
bitmap: Bitmap
imageRef: ImageRef
) {
if (!sdk.licenseInfo.isValid) { return; }

val result = barcodeDetector.scanFromBitmap(bitmap, 0)
val result = barcodeDetector.run(imageRef).getOrThrow()
// handle the detected barcode(s) from result
}
// @EndTag("Scanning from Bitmap")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK

fun barcodeScannerWithSimpleConfigSnippet(context: Context) {
// @Tag("Simple configuring Barcode Scanner")
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner()
val barcodeScanner = ScanbotBarcodeScannerSDK(context).createBarcodeScanner().getOrThrow()

barcodeScanner.setConfiguration(
barcodeScanner.copyCurrentConfiguration().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package io.scanbot.example.sdk.barcode.doc_code_snippet
// TODO: add URLs here

// @Tag("Configuring RTU UI v2 Barcode find and pick use case snippet")
import io.scanbot.sdk.barcode.BarcodeFormatCommonConfiguration
import io.scanbot.sdk.barcode.BarcodeFormats
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerScreenConfiguration
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeUseCase
Expand Down Expand Up @@ -66,7 +67,7 @@ fun findAndPickModeUseCaseSnippet() {
}

// Set an array of accepted barcode types.
this.scannerConfiguration.barcodeFormats = BarcodeFormats.common
this.scannerConfiguration.barcodeFormatConfigurations = listOf(BarcodeFormatCommonConfiguration(formats = BarcodeFormats.common))

// Configure other parameters as needed.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK

fun manualBarcodeDataParsing(context: Context, barcodeString: String) {
val scanbotSDK = ScanbotBarcodeScannerSDK(context);
scanbotSDK.createBarcodeDocumentParser().parseDocument(barcodeString)
scanbotSDK.createBarcodeDocumentParser().getOrNull()?.parse(barcodeString)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.scanbot.example.sdk.barcode.doc_code_snippet

/*
NOTE: this snippet of code is to be used only as a part of the website documentation.
This code is not intended for any use outside of the support of documentation by Scanbot SDK GmbH employees.
*/

// NOTE for maintainers: whenever changing this code,
// ensure that links using it are still pointing to valid lines!
// Pay attention to imports adding/removal/sorting!
// Page URLs using this code:
// TODO: add URLs here

// @Tag("Configuring RTU UI v2 Barcode multiple scanning use case snippet")
import io.scanbot.sdk.barcode.BarcodeFormatCommonConfiguration
import io.scanbot.sdk.barcode.BarcodeFormats
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerScreenConfiguration
import io.scanbot.sdk.ui_v2.barcode.configuration.CollapsedVisibleHeight
import io.scanbot.sdk.ui_v2.barcode.configuration.MultipleBarcodesScanningMode
import io.scanbot.sdk.ui_v2.barcode.configuration.MultipleScanningMode
import io.scanbot.sdk.ui_v2.barcode.configuration.SheetMode
import io.scanbot.sdk.ui_v2.common.ScanbotColor

fun multipleScanningCountUseCaseSnippet() {
// Create the default configuration object.
val config = BarcodeScannerScreenConfiguration().apply {
// Configure parameters (use explicit `this.` receiver for better code completion):

// Initialize the use case for multiple scanning.
this.useCase = MultipleScanningMode().apply {
// Set the counting mode.
this.mode = MultipleBarcodesScanningMode.COUNTING

// Set the sheet mode for the barcodes preview.
this.sheet.mode = SheetMode.COLLAPSED_SHEET

// Set the height for the collapsed sheet.
this.sheet.collapsedVisibleHeight = CollapsedVisibleHeight.LARGE

// Enable manual count change.
this.sheetContent.manualCountChangeEnabled = true

// Set the delay before same barcode counting repeat.
this.countingRepeatDelay = 1000

// Configure the submit button.
this.sheetContent.submitButton.text = "Submit"
this.sheetContent.submitButton.foreground.color = ScanbotColor("#000000")

// Configure other parameters, pertaining to multiple-scanning mode as needed.
}

// Set an array of accepted barcode types.
this.scannerConfiguration.barcodeFormatConfigurations = listOf(BarcodeFormatCommonConfiguration(formats = BarcodeFormats.common))

// Configure other parameters as needed.
}
}
// @EndTag("Configuring RTU UI v2 Barcode multiple scanning use case snippet")
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package io.scanbot.example.sdk.barcode.doc_code_snippet
// TODO: add URLs here

// @Tag("Configuring RTU UI v2 Barcode multiple scanning use case snippet")
import io.scanbot.sdk.barcode.BarcodeFormatCommonConfiguration
import io.scanbot.sdk.barcode.BarcodeFormats
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerScreenConfiguration
import io.scanbot.sdk.ui_v2.barcode.configuration.CollapsedVisibleHeight
Expand All @@ -28,7 +29,7 @@ fun multipleScanningUseCaseSnippet() {
// Initialize the use case for multiple scanning.
this.useCase = MultipleScanningMode().apply {
// Set the counting mode.
this.mode = MultipleBarcodesScanningMode.COUNTING
this.mode = MultipleBarcodesScanningMode.UNIQUE

// Set the sheet mode for the barcodes preview.
this.sheet.mode = SheetMode.COLLAPSED_SHEET
Expand All @@ -50,7 +51,7 @@ fun multipleScanningUseCaseSnippet() {
}

// Set an array of accepted barcode types.
this.scannerConfiguration.barcodeFormats = BarcodeFormats.common
this.scannerConfiguration.barcodeFormatConfigurations = listOf(BarcodeFormatCommonConfiguration(formats = BarcodeFormats.common))

// Configure other parameters as needed.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package io.scanbot.example.sdk.barcode.doc_code_snippet
// TODO: add URLs here

// @Tag("Configuring RTU UI v2 Barcode single scan use case snippet")
import io.scanbot.sdk.barcode.BarcodeFormatCommonConfiguration
import io.scanbot.sdk.barcode.BarcodeFormats
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerScreenConfiguration
import io.scanbot.sdk.ui_v2.barcode.configuration.SingleScanningMode
Expand Down Expand Up @@ -53,7 +54,7 @@ fun singleScanningUseCaseSnippet() {
}

// Set an array of accepted barcode types.
this.scannerConfiguration.barcodeFormats = BarcodeFormats.common
this.scannerConfiguration.barcodeFormatConfigurations = listOf(BarcodeFormatCommonConfiguration(formats = BarcodeFormats.common))

// Configure other parameters as needed.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
// @Tag("Add imports for RTU UI v2 activity")
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDKInitializer
import io.scanbot.sdk.common.AspectRatio
import io.scanbot.sdk.geometry.AspectRatio
import io.scanbot.sdk.ui_v2.barcode.BarcodeScannerActivity
import io.scanbot.sdk.ui_v2.barcode.configuration.BarcodeScannerScreenConfiguration
import io.scanbot.sdk.ui_v2.common.FinderStyle
Expand Down
Loading