Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-08-08 11:48:30 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8bc2cfe5bc43ea37f4d252fcdb3691631395aaac
8bc2cfe5
1 parent
8951c43d
provide an overridable method to create the barcode scanner in tests
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
View file @
8bc2cfe
...
...
@@ -13,6 +13,7 @@ import android.os.Looper
import android.util.Size
import android.view.Surface
import android.view.WindowManager
import androidx.annotation.VisibleForTesting
import androidx.camera.core.Camera
import androidx.camera.core.CameraSelector
import androidx.camera.core.ExperimentalGetImage
...
...
@@ -41,7 +42,7 @@ class MobileScanner(
private val activity: Activity,
private val textureRegistry: TextureRegistry,
private val mobileScannerCallback: MobileScannerCallback,
private val mobileScannerErrorCallback: MobileScannerErrorCallback
private val mobileScannerErrorCallback: MobileScannerErrorCallback
,
) {
/// Internal variables
...
...
@@ -159,6 +160,15 @@ class MobileScanner(
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
}
/**
* Create a barcode scanner from the given options.
*
* Can be overridden in tests.
*/
@VisibleForTesting
fun createBarcodeScanner(options: BarcodeScannerOptions?) : BarcodeScanner {
return if (options == null) BarcodeScanning.getClient() else BarcodeScanning.getClient(options)
}
// scales the scanWindow to the provided inputImage and checks if that scaled
// scanWindow contains the barcode
...
...
@@ -238,11 +248,7 @@ class MobileScanner(
}
lastScanned = null
scanner = if (barcodeScannerOptions != null) {
BarcodeScanning.getClient(barcodeScannerOptions)
} else {
BarcodeScanning.getClient()
}
scanner = createBarcodeScanner(barcodeScannerOptions)
val cameraProviderFuture = ProcessCameraProvider.getInstance(activity)
val executor = ContextCompat.getMainExecutor(activity)
...
...
Please
register
or
login
to post a comment