Skip to content

Commit 01e2b06

Browse files
committed
fix dc compiling 8.0.0
1 parent f60069b commit 01e2b06

File tree

15 files changed

+151
-90
lines changed

15 files changed

+151
-90
lines changed

data-capture-ready-to-use-ui-example/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ dependencies {
7474
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
7575
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
7676

77-
def scanbotSdkVersion = "8.0.0.1158-SNAPSHOT"
77+
def scanbotSdkVersion = "8.0.0.48-STAGING-SNAPSHOT"
7878

7979
implementation("io.scanbot:sdk-package-4:$scanbotSdkVersion")
8080
implementation("io.scanbot:sdk-package-ui:$scanbotSdkVersion")

data-capture-ready-to-use-ui-example/app/src/main/java/io/scanbot/example/doc_code_snippet/ocr/OcrSnippets.kt

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Context
55
import android.net.Uri
66
import android.util.Log
77
import androidx.core.net.toFile
8+
import io.scanbot.common.getOrNull
89
import io.scanbot.sdk.*
910
import io.scanbot.sdk.docprocessing.Document
1011
import io.scanbot.sdk.entity.*
@@ -32,58 +33,59 @@ import io.scanbot.sdk.pdfgeneration.ResamplingMethod
3233
fun initSdkSnippet(application: Application, licenseKey: String) {
3334
// @Tag("Initialize SDK")
3435
ScanbotSDKInitializer()
35-
.license(application, licenseKey)
36-
.prepareOCRLanguagesBlobs(true)
37-
//...
38-
.initialize(application)
36+
.license(application, licenseKey)
37+
.prepareOCRLanguagesBlobs(true)
38+
//...
39+
.initialize(application)
3940
// @EndTag("Initialize SDK")
4041
}
4142

4243
fun createOcrEngine(context: Context) {
4344
// @Tag("Create OCR Engine")
4445
val scanbotSDK = ScanbotSDK(context)
45-
val ocrEngine = scanbotSDK.createOcrEngineExtension()
46+
val ocrEngine = scanbotSDK.createOcrEngineManager()
4647
// @EndTag("Create OCR Engine")
4748
}
4849

4950
fun enableBinarizationInOcrSettingsSnippet(application: Application) {
5051
// @Tag("Enable Binarization in OCR Settings")
5152
ScanbotSDKInitializer()
52-
.useOcrSettings(OcrSettings.Builder().binarizeImage(true).build())
53-
//...
54-
.initialize(application)
53+
.useOcrSettings(OcrSettings.Builder().binarizeImage(true).build())
54+
//...
55+
.initialize(application)
5556
// @EndTag("Enable Binarization in OCR Settings")
5657
}
5758

5859
fun engineModeTesseractSnippet(context: Context) {
5960
// @Tag("Engine Mode Tesseract")
60-
val ocrRecognizer = ScanbotSDK(context).createOcrEngineExtension()
61+
val ocrRecognizer = ScanbotSDK(context).createOcrEngineManager()
6162

6263
val languages = mutableSetOf<Language>()
6364
languages.add(Language.ENG)
6465

6566
ocrRecognizer.setOcrConfig(
66-
OcrEngineExtension.OcrConfig(
67-
engineMode = OcrEngineExtension.EngineMode.TESSERACT,
68-
languages = languages,
69-
)
67+
OcrEngineManager.OcrConfig(
68+
engineMode = OcrEngineManager.EngineMode.TESSERACT,
69+
languages = languages,
70+
)
7071
)
7172
// @EndTag("Engine Mode Tesseract")
7273
}
7374

74-
fun runOcrOnUrisSnippet(ocrEngine: OcrEngineExtension) {
75+
fun runOcrOnUrisSnippet(ocrEngine: OcrEngineManager) {
7576
// @Tag("Run OCR from images")
76-
val imageFileUris: List<Uri> = listOf() // ["file:///some/path/file1.jpg", "file:///some/path/file2.jpg", ...]
77+
val imageFileUris: List<Uri> =
78+
listOf() // ["file:///some/path/file1.jpg", "file:///some/path/file2.jpg", ...]
7779

78-
var result: OcrResult = ocrEngine.recognizeFromUris(imageFileUris, false)
80+
var result: OcrResult? = ocrEngine.recognizeFromUris(imageFileUris, false).getOrNull()
7981
// @EndTag("Run OCR from images")
8082
}
8183

82-
fun runOcrOnDocumentSnippet(ocrEngine: OcrEngineExtension, yourDocument: Document) {
84+
fun runOcrOnDocumentSnippet(ocrEngine: OcrEngineManager, yourDocument: Document) {
8385
// @Tag("Run OCR from Document")
8486
val document: Document = yourDocument
8587

86-
var result: OcrResult = ocrEngine.recognizeFromDocument(document)
88+
var result: OcrResult? = ocrEngine.recognizeFromDocument(document).getOrNull()
8789
// @EndTag("Run OCR from Document")
8890
}
8991

@@ -118,16 +120,16 @@ fun generatePdfWithOcrLayerSnippet(scanbotSDK: ScanbotSDK, document: Document) {
118120
pageFit = PageFit.NONE,
119121
resamplingMethod = ResamplingMethod.NONE,
120122
)
121-
val ocrConfig = OcrEngineExtension.OcrConfig(
122-
engineMode = OcrEngineExtension.EngineMode.SCANBOT_OCR
123+
val ocrConfig = OcrEngineManager.OcrConfig(
124+
engineMode = OcrEngineManager.EngineMode.SCANBOT_OCR
123125
)
124126
val pdfGenerated = pdfGenerator.generateWithOcrFromDocument(
125-
document = document,
126-
pdfConfig = pdfConfig,
127-
ocrConfig = ocrConfig
128-
)
127+
document = document,
128+
pdfConfig = pdfConfig,
129+
ocrConfig = ocrConfig
130+
).getOrNull()
129131
val pdfFile = document.pdfUri.toFile()
130-
if (pdfGenerated && pdfFile.exists()) {
132+
if (pdfGenerated != null && pdfFile.exists()) {
131133
// Do something with the PDF file
132134
} else {
133135
Log.e("PdfWithOcrFromDocument", "Failed to create PDF")
@@ -141,27 +143,27 @@ fun generatePdfWithOcrLayerFormUrisSnippet(scanbotSDK: ScanbotSDK, imageFileUris
141143
val pdfGenerator = scanbotSDK.createPdfGenerator()
142144

143145
val pdfConfig = PdfConfiguration(
144-
attributes = PdfAttributes(
145-
author = "",
146-
title = "",
147-
subject = "",
148-
keywords = "",
149-
creator = ""
150-
),
151-
pageSize = PageSize.A4,
152-
pageDirection = PageDirection.AUTO,
153-
dpi = 200,
154-
jpegQuality = 100,
155-
pageFit = PageFit.NONE,
156-
resamplingMethod = ResamplingMethod.NONE,
146+
attributes = PdfAttributes(
147+
author = "",
148+
title = "",
149+
subject = "",
150+
keywords = "",
151+
creator = ""
152+
),
153+
pageSize = PageSize.A4,
154+
pageDirection = PageDirection.AUTO,
155+
dpi = 200,
156+
jpegQuality = 100,
157+
pageFit = PageFit.NONE,
158+
resamplingMethod = ResamplingMethod.NONE,
157159
)
158-
val ocrConfig = OcrEngineExtension.OcrConfig(
159-
engineMode = OcrEngineExtension.EngineMode.SCANBOT_OCR
160+
val ocrConfig = OcrEngineManager.OcrConfig(
161+
engineMode = OcrEngineManager.EngineMode.SCANBOT_OCR
160162
)
161163
val generatedPdfFile = pdfGenerator.generateWithOcrFromUris(
162-
imageFileUris = imageFileUris,
163-
pdfConfig = pdfConfig,
164-
ocrConfig = ocrConfig
164+
imageFileUris = imageFileUris,
165+
pdfConfig = pdfConfig,
166+
ocrConfig = ocrConfig
165167
)
166168
if (generatedPdfFile != null) {
167169
// Do something with the PDF file

data-capture-ready-to-use-ui-example/settings.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ dependencyResolutionManagement {
1414
google()
1515
maven(url = "https://nexus.scanbot.io/nexus/content/repositories/releases/")
1616
maven(url = "https://nexus.scanbot.io/nexus/content/repositories/snapshots/")
17+
val stagingNexusLogin = System.getenv()["STAGING_NEXUS_LOGIN"] ?: providers.gradleProperty("STAGING_NEXUS_LOGIN").orNull
18+
val stagingNexusPassword = System.getenv()["STAGING_NEXUS_PASSWORD"] ?: providers.gradleProperty("STAGING_NEXUS_PASSWORD").orNull
19+
maven(url = "https://nexus2-staging.scanbot.io/nexus/content/repositories/snapshots/") {
20+
credentials {
21+
username = stagingNexusLogin
22+
password = stagingNexusPassword
23+
}
24+
}
1725
}
26+
1827
}
1928

2029
include(":app")

document-scanner-ready-to-use-ui-example/.idea/codeStyles/Project.xml

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

document-scanner-ready-to-use-ui-example/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ android {
3939
}
4040
}
4141

42-
def scanbotSdkVersion = "8.0.0.1158-SNAPSHOT"
42+
def scanbotSdkVersion = "8.0.0.39-STAGING-SNAPSHOT"
4343

4444
dependencies {
4545

document-scanner-ready-to-use-ui-example/app/src/main/java/com/example/scanbot/ExampleApplication.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ package com.example.scanbot
33
import android.app.Application
44
import android.widget.Toast
55
import io.scanbot.sap.IScanbotSDKLicenseErrorHandler
6-
import io.scanbot.sap.Status
76
import io.scanbot.sdk.ScanbotSDK
87
import io.scanbot.sdk.ScanbotSDKInitializer
9-
import io.scanbot.sdk.document.DocumentScannerEngineMode
108
import io.scanbot.sdk.persistence.CameraImageFormat
119
import io.scanbot.sdk.persistence.page.PageStorageSettings
1210
import kotlinx.coroutines.CoroutineScope
1311
import kotlinx.coroutines.Dispatchers
1412
import kotlinx.coroutines.Job
1513
import kotlinx.coroutines.launch
1614
import kotlin.coroutines.CoroutineContext
15+
import io.scanbot.sdk.documentscanner.DocumentScannerEngineMode
16+
import io.scanbot.sdk.licensing.LicenseStatus
1717

1818
class ExampleApplication : Application(), CoroutineScope {
1919

@@ -47,13 +47,13 @@ class ExampleApplication : Application(), CoroutineScope {
4747
.imageQuality(80)
4848
.build()
4949
)
50-
.licenceErrorHandler(IScanbotSDKLicenseErrorHandler { status, sdkFeature, errorMessage ->
50+
.licenseErrorHandler (IScanbotSDKLicenseErrorHandler { status, sdkFeature, errorMessage ->
5151
when (status) {
52-
Status.StatusFailureNotSet,
53-
Status.StatusFailureCorrupted,
54-
Status.StatusFailureWrongOS,
55-
Status.StatusFailureAppIDMismatch,
56-
Status.StatusFailureExpired -> {
52+
LicenseStatus.FAILURE_NOT_SET,
53+
LicenseStatus.FAILURE_CORRUPTED,
54+
LicenseStatus.FAILURE_WRONG_OS,
55+
LicenseStatus.FAILURE_APP_ID_MISMATCH,
56+
LicenseStatus.FAILURE_EXPIRED -> {
5757
Toast.makeText(this, "License error: $status ", Toast.LENGTH_LONG).show()
5858
}
5959

document-scanner-ready-to-use-ui-example/app/src/main/java/com/example/scanbot/di/ExampleSingleton.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
package com.example.scanbot.di
22

33
import android.content.Context
4+
import io.scanbot.common.getOrNull
45
import io.scanbot.sdk.ScanbotSDK
56
import io.scanbot.sdk.docprocessing.PdfPagesExtractor
7+
import io.scanbot.sdk.documentqualityanalyzer.DocumentQualityAnalyzer
68
import io.scanbot.sdk.ocr.OcrEngine
9+
import io.scanbot.sdk.ocr.OcrEngineManager
710
import io.scanbot.sdk.persistence.fileio.FileIOProcessor
811
import io.scanbot.sdk.persistence.page.PageFileStorage
9-
import io.scanbot.sdk.process.DocumentQualityAnalyzer
1012
import io.scanbot.sdk.process.PdfGenerator
11-
import io.scanbot.sdk.tiff.TiffGenerator
13+
import io.scanbot.sdk.tiff.TiffGeneratorManager
14+
import io.scanbot.sdk.tiffgeneration.TiffGenerator
1215

1316
/** This singleton is used only for simplicity. Please, use Hilt or other DI framework in production code. */
1417
interface ExampleSingleton {
1518
fun pagePdfExtractorInstance(): PdfPagesExtractor
16-
fun pageOcrEngine(): OcrEngine
19+
fun pageOcrEngine(): OcrEngineManager
1720
fun pagePDFRenderer(): PdfGenerator
18-
fun pageTIFFWriter(): TiffGenerator
21+
fun pageTIFFWriter(): TiffGeneratorManager
1922
fun pageDocQualityAnalyzer(): DocumentQualityAnalyzer
2023
fun fileIOProcessor(): FileIOProcessor
2124
fun pageFileStorage(): PageFileStorage
@@ -33,9 +36,9 @@ class ExampleSingletonImpl(private val context: Context) : ExampleSingleton {
3336
return pdfExtractor!!
3437
}
3538

36-
override fun pageOcrEngine(): OcrEngine {
39+
override fun pageOcrEngine(): OcrEngineManager {
3740
if (textRecognition == null) {
38-
textRecognition = scanbotSdk.createOcrEngine()
41+
textRecognition = scanbotSdk.createOcrEngineManager()
3942
}
4043
return textRecognition!!
4144
}
@@ -47,16 +50,16 @@ class ExampleSingletonImpl(private val context: Context) : ExampleSingleton {
4750
return pdfGenerator!!
4851
}
4952

50-
override fun pageTIFFWriter(): TiffGenerator {
53+
override fun pageTIFFWriter(): TiffGeneratorManager {
5154
if (tiffGenerator == null) {
52-
tiffGenerator = scanbotSdk.createTiffGenerator()
55+
tiffGenerator = scanbotSdk.createTiffGeneratorManager()
5356
}
5457
return tiffGenerator!!
5558
}
5659

5760
override fun pageDocQualityAnalyzer(): DocumentQualityAnalyzer {
5861
if (documentQualityAnalyzer == null) {
59-
documentQualityAnalyzer = scanbotSdk.createDocumentQualityAnalyzer()
62+
documentQualityAnalyzer = scanbotSdk.createDocumentQualityAnalyzer().getOrNull()
6063
}
6164
return documentQualityAnalyzer!!
6265
}
@@ -77,9 +80,9 @@ class ExampleSingletonImpl(private val context: Context) : ExampleSingleton {
7780

7881
companion object {
7982
private var pdfExtractor: PdfPagesExtractor? = null
80-
private var textRecognition: OcrEngine? = null
83+
private var textRecognition: OcrEngineManager? = null
8184
private var pdfGenerator: PdfGenerator? = null
82-
private var tiffGenerator: TiffGenerator? = null
85+
private var tiffGenerator: TiffGeneratorManager? = null
8386
private var documentQualityAnalyzer: DocumentQualityAnalyzer? = null
8487
private var fileIOProcessor: FileIOProcessor? = null
8588
private var pageFileStorage: PageFileStorage? = null

document-scanner-ready-to-use-ui-example/app/src/main/java/com/example/scanbot/doc_code_snippet/PdfFromDocumentSnippet.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.example.scanbot.utils.toBitmap
1414
import kotlinx.coroutines.Dispatchers
1515
import kotlinx.coroutines.launch
1616
import kotlinx.coroutines.withContext
17+
import io.scanbot.common.Result
1718
import io.scanbot.sdk.ScanbotSDK
1819
import io.scanbot.sdk.docprocessing.Document
1920
import io.scanbot.sdk.pdfgeneration.PageDirection
@@ -82,12 +83,12 @@ class PdfFromDocumentSnippet : AppCompatActivity() {
8283
pageFit = PageFit.NONE,
8384
resamplingMethod = ResamplingMethod.NONE,
8485
)
85-
val pdfGenerated = pdfGenerator.generateFromDocument(
86+
val result = pdfGenerator.generateFromDocument(
8687
document,
8788
config
8889
)
8990
val pdfFile = document.pdfUri.toFile()
90-
if (pdfGenerated && pdfFile.exists()) {
91+
if (result is Result.Success && pdfFile.exists()) {
9192
// Do something with the PDF file
9293
} else {
9394
Log.e("PdfFromDocumentSnippet", "Failed to create PDF")

document-scanner-ready-to-use-ui-example/app/src/main/java/com/example/scanbot/doc_code_snippet/PdfFromImageSnippet.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.example.scanbot.utils.getUrisFromGalleryResult
1212
import kotlinx.coroutines.Dispatchers
1313
import kotlinx.coroutines.launch
1414
import kotlinx.coroutines.withContext
15+
import io.scanbot.common.getOrNull
1516
import io.scanbot.sdk.ScanbotSDK
1617
import io.scanbot.sdk.pdfgeneration.PdfConfiguration
1718

@@ -59,7 +60,7 @@ class PdfFromImageSnippet : AppCompatActivity() {
5960
imageFileUris = list.toTypedArray(),
6061
sourceFilesEncrypted = encryptionEnabled,
6162
config
62-
)
63+
).getOrNull()
6364

6465
if (pdfFile != null && pdfFile.exists()) {
6566
// Do something with the PDF file

0 commit comments

Comments
 (0)