Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EPIC-5458] Android ds 7.0.0 #397

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
a29ea87
fixes for sdk 7.0.0
4BooM04 Nov 13, 2024
9a354de
update examples to 7.0.0
4BooM04 Nov 14, 2024
7f361ce
fix classic barcode example
4BooM04 Nov 14, 2024
566c81b
fix compiling issues in classic component
4BooM04 Nov 15, 2024
8431fca
update imports ordering
4BooM04 Nov 21, 2024
4041c08
Classic component example for creditcard scanner
Den-Rimus Dec 17, 2024
5ec559a
update document scanner example after packages renaming
4BooM04 Dec 20, 2024
5c97a62
fix compiling for data example app after package renaming
4BooM04 Dec 20, 2024
f18e491
Update example (ONLY CREDIT CARD SCANNER PART) to 7.0 RC
Den-Rimus Dec 20, 2024
28a166a
fix document wrapping snippet
4BooM04 Dec 20, 2024
efc3f76
fix names of renamed scanners
4BooM04 Dec 20, 2024
eba9676
fix name for DocumentDataExtractorFrameHandlerSnippet
4BooM04 Jan 2, 2025
2099366
fix package naming
4BooM04 Jan 2, 2025
afc8494
add mc scan from image example
4BooM04 Jan 2, 2025
940b249
add document data extractor example for stable image
4BooM04 Jan 2, 2025
1eec069
add check snippets
4BooM04 Jan 2, 2025
515cd59
extend image snapping snippets
4BooM04 Jan 2, 2025
0464d8a
fix documentation
4BooM04 Jan 2, 2025
5a153df
add mrz stable image example
4BooM04 Jan 3, 2025
1453c7b
added more documentation snippets
Kubiria Jan 10, 2025
f92cb2f
added snippet tag
Kubiria Jan 10, 2025
746b2d4
added snippet tag
Kubiria Jan 10, 2025
98095a3
added snippet tags
Kubiria Jan 13, 2025
8c44a19
updated snippet tags format
Kubiria Jan 13, 2025
09d4d63
added tags for doc snippets
Kubiria Jan 13, 2025
b0c9f90
add mrz ui example
4BooM04 Jan 14, 2025
c41bb4c
Updated Document Data Extractor doc snippets
Kubiria Jan 14, 2025
2a6100d
Merge branch 'sc/7.0.0_document_update' into android-ds-7.0.0
4BooM04 Jan 14, 2025
04ad157
Updated Medical Certificate Scanner doc snippets
Kubiria Jan 14, 2025
a17a7bb
add check ui snippets
4BooM04 Jan 14, 2025
a8c7588
fix check stable image
4BooM04 Jan 14, 2025
f651f13
Updated Text Pattern Scanner doc snippets
Kubiria Jan 14, 2025
2ccdf44
Merge branch 'android-ds-7.0.0' of github.com:doo/scanbot-sdk-example…
Kubiria Jan 14, 2025
8d6c756
Updated Vin Scanner doc snippets
Kubiria Jan 14, 2025
5deae02
add license plate snippet
4BooM04 Jan 14, 2025
0251af9
Merge branch 'android-ds-7.0.0' of github.com:doo/scanbot-sdk-example…
4BooM04 Jan 14, 2025
976756a
fix tags
4BooM04 Jan 14, 2025
7ee71fc
add storage snippets
4BooM04 Jan 14, 2025
c53d2c0
storage snippet update
4BooM04 Jan 14, 2025
d1c46b7
fix license plate
4BooM04 Jan 14, 2025
d4e17d3
Updated OcrEngine doc snippets
Kubiria Jan 15, 2025
a15e839
Updated RTU v1-v2 migration doc snippets
Kubiria Jan 15, 2025
cf614b3
Updated doc snippets
Kubiria Jan 15, 2025
4165185
Updated doc snippets
Kubiria Jan 15, 2025
096eabe
Updated doc snippets
Kubiria Jan 16, 2025
dc51c79
Updated doc snippets
Kubiria Jan 16, 2025
89515f0
test sdk version
4BooM04 Jan 30, 2025
b6816f7
fix example snippets
4BooM04 Jan 30, 2025
ab068ec
update mrz snippet
4BooM04 Feb 6, 2025
02a56d8
add compose artu example
4BooM04 Feb 6, 2025
a97a81d
cleanup
4BooM04 Feb 6, 2025
d81d553
update credit card snippet
4BooM04 Feb 7, 2025
d79d8d9
Merge branch 'android-ds-7.0.0' into dd/7.0-preparation
4BooM04 Feb 7, 2025
20a00e3
Merge pull request #396 from doo/dd/7.0-preparation
4BooM04 Feb 7, 2025
d2f7f61
update classic component to renamed 7.0.0
4BooM04 Feb 7, 2025
a7bf442
cleanup
4BooM04 Feb 7, 2025
7e087fa
naming cleanup
4BooM04 Feb 7, 2025
c126a98
delete ehic scanner
4BooM04 Feb 7, 2025
5cafffc
cleanup credit card snippets
4BooM04 Feb 10, 2025
614ce81
add textPattern ui v2 example
4BooM04 Feb 10, 2025
dfb001b
Fixed intro text string for text pattern scanner
4BooM04 Feb 10, 2025
eb65e8e
fix compiling issues
4BooM04 Feb 11, 2025
b6130a7
fix naming
4BooM04 Feb 11, 2025
b2bdc84
fix naming
4BooM04 Feb 11, 2025
e542489
fix result props naming
4BooM04 Feb 11, 2025
579fd2a
fix docs namings
4BooM04 Feb 11, 2025
a2a36ec
Merge pull request #398 from doo/update_classic_examples_7.0.0
Kubiria Feb 11, 2025
f4cdad0
Add comments to mrz classic example
4BooM04 Feb 17, 2025
43d2cc4
update credit card classic example component
4BooM04 Feb 18, 2025
91a0488
update Libraries txt
4BooM04 Feb 18, 2025
3765bed
fix tag
4BooM04 Feb 21, 2025
d526a4c
add tags for text pattern classic example
4BooM04 Feb 25, 2025
79fd743
add tags for xml layout
4BooM04 Feb 25, 2025
0a3931b
fix compiling
4BooM04 Mar 4, 2025
520db07
fix compiling issues
4BooM04 Mar 4, 2025
0abdecd
Added missing DQA assets dependency
Kubiria Mar 5, 2025
66d1c82
removed deprecated license plate example
Kubiria Mar 5, 2025
a2bd6fe
Added Activity edge-to-edge support for Classic examples
Kubiria Mar 6, 2025
0fc0e3d
Merge pull request #399 from doo/ak/classic-examples-edge-to-edge
4BooM04 Mar 7, 2025
670e670
Merge branch 'master' into android-ds-7.0.0
4BooM04 Mar 10, 2025
d9d7bad
fix standalone cropping screen tag position
4BooM04 Mar 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ proguard/
*.iml
*.ipr
*.iws
.idea/
*/.idea/*
!*/.idea/codeStyles/
.DS_Store

.gradle/
Expand Down
2 changes: 1 addition & 1 deletion Libraries.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Open Source libraries used in the Scanbot SDK for Android version 6.2.1
Open Source libraries used in the Scanbot SDK for Android version 7.0.0

CWAC-Camera

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:name=".ExampleApplication"
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.squareup.picasso.Callback
import com.squareup.picasso.MemoryPolicy
import com.squareup.picasso.Picasso
import io.scanbot.example.common.Const
import io.scanbot.example.common.applyEdgeToEdge
import io.scanbot.example.common.showToast
import io.scanbot.example.databinding.ActivityFiltersTunesBinding
import io.scanbot.example.fragment.ErrorFragment
Expand Down Expand Up @@ -53,6 +54,7 @@ class FilterActivity : AppCompatActivity(), FiltersListener {
super.onCreate(savedInstanceState)
setContentView(binding.root)
initActionBar()
applyEdgeToEdge(findViewById(R.id.root_view))

scanbotSdk = ScanbotSDK(application)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import io.scanbot.example.common.Const
import io.scanbot.example.common.applyEdgeToEdge
import io.scanbot.example.common.showToast
import io.scanbot.example.databinding.ActivityMainBinding
import io.scanbot.sdk.ScanbotSDK
import io.scanbot.sdk.core.contourdetector.DocumentDetectionStatus
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand All @@ -38,7 +38,7 @@ class MainActivity : AppCompatActivity() {
}

lifecycleScope.launch {
val documentId = createAndDetectDocumentPage(uri)
val documentId = createAndScanDocumentPage(uri)

if (documentId != null) {
filterActivityResultLauncher.launch(FilterActivity.newIntent(this@MainActivity, documentId))
Expand Down Expand Up @@ -77,13 +77,16 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
supportActionBar?.hide()

applyEdgeToEdge(findViewById(R.id.root_view))

binding.importFromLibBtn.setOnClickListener {
selectGalleryImageResultLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}
}

private suspend fun createAndDetectDocumentPage(imageUri: Uri): String? {
private suspend fun createAndScanDocumentPage(imageUri: Uri): String? {
val bitmap = withContext(Dispatchers.IO) {
val inputStream = contentResolver.openInputStream(imageUri)
BitmapFactory.decodeStream(inputStream)
Expand All @@ -104,29 +107,29 @@ class MainActivity : AppCompatActivity() {

binding.progressBar.visibility = View.VISIBLE
val resultDocument = withContext(Dispatchers.Default) {
val contourResult = sdk.createContourDetector().detect(bitmap)
val result = sdk.createDocumentScanner().scanFromBitmap(bitmap)

if (contourResult == null) {
Log.e(Const.LOG_TAG, "Error detecting document (result is `null`)!")
showToast("Error detecting document!")
if (result == null) {
Log.e(Const.LOG_TAG, "Error finding document (result is `null`)!")
showToast("Error finding document!")
return@withContext null
}
Log.d(Const.LOG_TAG, "Doc detected: ${contourResult.status}")
Log.d(Const.LOG_TAG, "Doc found: ${result.status}")

/** We allow all `OK_*` [statuses][DocumentDetectionStatus] just for purpose of this example.
* Otherwise it is a good practice to differentiate between statuses and handle them accordingly.
*/
val isDetectionOk = contourResult.status.name.startsWith("OK", true)
if (isDetectionOk.not()) {
Log.e(Const.LOG_TAG, "Bad document photo - detection status was ${contourResult.status.name}!")
showToast("Bad document photo - status ${contourResult.status.name}!")
val isScanOk = result.status.name.startsWith("OK", true)
if (isScanOk.not()) {
Log.e(Const.LOG_TAG, "Bad document photo - scanning status was ${result.status.name}!")
showToast("Bad document photo - status ${result.status.name}!")
return@withContext null
}

val document = sdk.documentApi.createDocument()
val page = document.addPage(bitmap)
Log.d(Const.LOG_TAG, "Page added: ${page.uuid}")
page.apply(newPolygon = contourResult.polygonF)
page.apply(newPolygon = result.pointsNormalized)
document
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<uses-feature android:name="android.hardware.camera" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.scanbot.example.model

import io.scanbot.sdk.barcode.entity.BarcodeScanningResult
import io.scanbot.sdk.barcode.BarcodeScannerResult

data class BarcodeResultBundle(
val barcodeScanningResult: BarcodeScanningResult,
val barcodeScanningResult: BarcodeScannerResult,
val imagePath: String? = null,
val previewPath: String? = null
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.scanbot.example.repository

import io.scanbot.example.model.BarcodeResultBundle
import io.scanbot.sdk.barcode.entity.BarcodeItem
import io.scanbot.sdk.barcode.BarcodeItem

object BarcodeResultRepository {
var barcodeResultBundle: BarcodeResultBundle? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.scanbot.example.repository

import io.scanbot.sdk.barcode.entity.BarcodeFormat
import io.scanbot.sdk.barcode.BarcodeFormat
import io.scanbot.sdk.barcode.BarcodeFormats


object BarcodeTypeRepository {
val selectedTypes = mutableSetOf<BarcodeFormat>().also {
it.addAll(BarcodeFormat.COMMON_CODES)
it.addAll(BarcodeFormats.common)
}

fun selectType(type: BarcodeFormat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ package io.scanbot.example.ui
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import com.squareup.picasso.Picasso
import io.scanbot.example.R
import io.scanbot.example.common.applyEdgeToEdge
import io.scanbot.example.databinding.ActivityBarcodeResultBinding
import io.scanbot.example.databinding.BarcodeItemBinding
import io.scanbot.example.databinding.SnapImageItemBinding
import io.scanbot.example.repository.BarcodeResultRepository
import io.scanbot.sdk.barcode.entity.BarcodeScanningResult
import io.scanbot.sdk.barcode.BarcodeScannerResult
import io.scanbot.sdk.barcode.textWithExtension
import java.io.File

class BarcodeResultActivity : AppCompatActivity() {
Expand All @@ -21,6 +28,8 @@ class BarcodeResultActivity : AppCompatActivity() {
setContentView(binding.root)
setSupportActionBar(binding.toolbar)

applyEdgeToEdge(findViewById(R.id.root_view))

showSnapImageIfExists(
BarcodeResultRepository.barcodeResultBundle?.previewPath
?: BarcodeResultRepository.barcodeResultBundle?.imagePath
Expand All @@ -31,10 +40,10 @@ class BarcodeResultActivity : AppCompatActivity() {

private fun showSnapImageIfExists(imagePath: String?) {
imagePath?.let { path ->
binding.recognisedItems.addView(
binding.scannedItems.addView(
SnapImageItemBinding.inflate(
layoutInflater,
binding.recognisedItems,
binding.scannedItems,
false
).also {
Picasso.get().load(File(path)).into(it.snapImage)
Expand All @@ -43,20 +52,20 @@ class BarcodeResultActivity : AppCompatActivity() {
}
}

private fun showLatestBarcodeResult(detectedBarcodes: BarcodeScanningResult?) {
detectedBarcodes?.let {
detectedBarcodes.barcodeItems.asSequence().map { item ->
BarcodeItemBinding.inflate(layoutInflater, binding.recognisedItems, false)
private fun showLatestBarcodeResult(scannedBarcodes: BarcodeScannerResult?) {
scannedBarcodes?.let {
scannedBarcodes.barcodes.asSequence().map { item ->
BarcodeItemBinding.inflate(layoutInflater, binding.scannedItems, false)
.also {
item.image?.let { bitmap ->
it.image.setImageBitmap(bitmap)
item.sourceImage?.let { image ->
it.image.setImageBitmap(image.toBitmap())
}
it.barcodeFormat.text = item.barcodeFormat.name
it.docFormat.text = item.formattedResult?.let {
it.barcodeFormat.text = item.format.name
it.docFormat.text = item.extractedDocument?.let {
it::class.java.simpleName
} ?: "Unknown document"
it.docFormat.visibility =
if (item.formattedResult != null) View.VISIBLE else View.GONE
if (item.extractedDocument != null) View.VISIBLE else View.GONE
it.docText.text = item.textWithExtension
it.root.setOnClickListener {
val intent = Intent(this, DetailedItemDataActivity::class.java)
Expand All @@ -65,7 +74,7 @@ class BarcodeResultActivity : AppCompatActivity() {
}
}
}.forEach {
binding.recognisedItems.addView(it.root)
binding.scannedItems.addView(it.root)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ import android.graphics.RectF
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import io.scanbot.example.R
import io.scanbot.example.common.applyEdgeToEdge
import io.scanbot.example.repository.BarcodeTypeRepository
import io.scanbot.sdk.ScanbotSDK
import io.scanbot.sdk.barcode.entity.BarcodeItem
import io.scanbot.sdk.barcode.BarcodeItem
import io.scanbot.sdk.barcode.setBarcodeFormats
import io.scanbot.sdk.barcode.textWithExtension
import io.scanbot.sdk.barcode.ui.BarcodePolygonsStaticView
import io.scanbot.sdk.barcode.ui.BarcodeScanAndCountView
import io.scanbot.sdk.barcode.ui.IBarcodeScanCountViewCallback
Expand All @@ -36,16 +43,17 @@ class BarcodeScanAndCountViewActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_barcode_count_view)

applyEdgeToEdge(findViewById(R.id.root_view))

scanCountView = findViewById(R.id.barcode_scanner_view)
scanButton = findViewById(R.id.snapButton)
nextButton = findViewById(R.id.nextButton)
snapResult = findViewById(R.id.snapped_message)

val barcodeDetector = ScanbotSDK(this).createBarcodeDetector()
barcodeDetector.modifyConfig {
setBarcodeFormats(BarcodeTypeRepository.selectedTypes.toList())
setSaveCameraPreviewFrame(false)
}
val scanner = ScanbotSDK(this).createBarcodeScanner()
scanner.setConfiguration(scanner.copyCurrentConfiguration().copy().apply {
setBarcodeFormats(barcodeFormats = BarcodeTypeRepository.selectedTypes.toList())
} )
scanButton.setOnClickListener {
scanCountView.viewController.scanAndCount() // call this to run the scan and count
}
Expand All @@ -60,8 +68,8 @@ class BarcodeScanAndCountViewActivity : AppCompatActivity() {

scanCountView.apply {
initCamera()
initDetectionBehavior(
barcodeDetector,
initScanningBehavior(
scanner,
callback = object : IBarcodeScanCountViewCallback {
override fun onCameraOpen() {
scanCountView.viewController.useFlash(flashEnabled)
Expand Down Expand Up @@ -98,8 +106,7 @@ class BarcodeScanAndCountViewActivity : AppCompatActivity() {
defaultStyle: BarcodePolygonsStaticView.BarcodePolygonStyle,
barcodeItem: BarcodeItem
): BarcodePolygonsStaticView.BarcodePolygonStyle {
// you can customize the style of the barcode polygon here
return defaultStyle
return defaultStyle
}
})
scanCountView.counterOverlayController.setBarcodeItemViewFactory(object :
Expand All @@ -111,7 +118,11 @@ class BarcodeScanAndCountViewActivity : AppCompatActivity() {
})
scanCountView.counterOverlayController.setBarcodeItemViewBinder(object :
BarcodePolygonsStaticView.BarcodeItemViewBinder {
override fun bindView(view: View, barcodeItem: BarcodeItem, isBarcodeAccepted: Boolean) {
override fun bindView(
view: View,
barcodeItem: BarcodeItem,
isBarcodeAccepted: Boolean
) {
val valueTextView = view.findViewById<TextView>(R.id.custom_ar_view_value)
val imageView = view.findViewById<ImageView>(R.id.custom_ar_view)
// valueTextView.isVisible = false //uncomment to show barcode value
Expand Down
Loading