Navaron Bracke

forward initial torch state on Android

... ... @@ -368,11 +368,22 @@ class MobileScanner(
val height = resolution.height.toDouble()
val portrait = (camera?.cameraInfo?.sensorRotationDegrees ?: 0) % 180 == 0
// Start with 'unavailable' torch state.
var currentTorchState: Int = -1
camera?.cameraInfo?.let {
if (!it.hasFlashUnit()) {
return@let
}
currentTorchState = it.torchState.value ?: -1
}
mobileScannerStartedCallback(
MobileScannerStartParameters(
if (portrait) width else height,
if (portrait) height else width,
camera?.cameraInfo?.hasFlashUnit() ?: false,
currentTorchState,
textureEntry!!.id(),
numberOfCameras ?: 0
)
... ...
... ... @@ -183,7 +183,7 @@ class MobileScannerHandler(
result.success(mapOf(
"textureId" to it.id,
"size" to mapOf("width" to it.width, "height" to it.height),
"torchable" to it.hasFlashUnit,
"currentTorchState" to it.currentTorchState,
"numberOfCameras" to it.numberOfCameras
))
}
... ...
... ... @@ -3,7 +3,7 @@ package dev.steenbakker.mobile_scanner.objects
class MobileScannerStartParameters(
val width: Double = 0.0,
val height: Double,
val hasFlashUnit: Boolean,
val currentTorchState: Int,
val id: Long,
val numberOfCameras: Int
)
\ No newline at end of file
... ...