Skip to content
Merged
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
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[versions]
scan-engine = "2.0.1"
scan-engine = "2.0.2"
kotlin = "2.2.0"
agp = "8.11.1"
compose = "1.8.1"
atomicfu = "0.28.0"

camera-core = "1.4.2"
camera-extensions = "1.4.2"
camera-lifecycle = "1.4.2"
camera-view = "1.4.2"
camera-core = "1.5.0"
camera-extensions = "1.5.0"
camera-lifecycle = "1.5.0"
camera-view = "1.5.0"

mlKit = "17.3.0"
playServicesMlkit = "18.3.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.google.mlkit.vision.barcode.BarcodeScanning
import com.google.mlkit.vision.barcode.common.Barcode
import com.google.mlkit.vision.common.InputImage
import de.tillhub.scanengine.camera.common.CameraProvider
import de.tillhub.scanengine.camera.common.Manufacturer
import java.util.concurrent.Executor

/**
Expand Down Expand Up @@ -87,6 +88,12 @@ internal actual class CameraController(
.setResolutionSelector(createResolutionSelector())
.build()
.also {
previewView.apply {
if (Manufacturer.matches(Manufacturer.VERIFONE)) {
scaleX = -1f
scaleY = -1f
}
}
it.surfaceProvider = previewView.surfaceProvider
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.tillhub.scanengine.camera.common

import android.os.Build

internal enum class Manufacturer(open val value: String) {
VERIFONE("Verifone"),
OTHER("OTHER"),
;

companion object {
fun get(): Manufacturer = entries.firstOrNull { it.value == Build.MANUFACTURER } ?: OTHER
fun matches(value: Manufacturer): Boolean = get() == value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.tillhub.scanengine.camera.contract.legacy

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract
import de.tillhub.scanengine.camera.ui.CameraScanActivity
import de.tillhub.scanengine.data.ScannerEvent

class CameraScanContract : ActivityResultContract<String?, ScannerEvent>() {
override fun createIntent(
context: Context,
input: String?,
): Intent = Intent(context, CameraScanActivity::class.java).apply {
input?.let {
putExtra(CameraScanActivity.SCAN_KEY, it)
}
}

override fun parseResult(
resultCode: Int,
intent: Intent?,
): ScannerEvent {
val resultData = intent?.extras?.getString(CameraScanActivity.DATA_KEY)
val scanKey = intent?.extras?.getString(CameraScanActivity.SCAN_KEY)

return if (resultCode == Activity.RESULT_OK && !resultData.isNullOrEmpty()) {
ScannerEvent.ScanResult(
value = resultData,
scanKey = scanKey,
)
} else {
ScannerEvent.Camera.Canceled
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class CameraScanActivity : ComponentActivity() {
val resultIntent =
Intent().apply {
putExtra(DATA_KEY, barcode)
intent.getStringExtra(SCAN_KEY)?.let {
putExtra(SCAN_KEY, barcode)
}
}
setResult(RESULT_OK, resultIntent)
finish()
Expand All @@ -28,5 +31,6 @@ class CameraScanActivity : ComponentActivity() {

companion object {
const val DATA_KEY = "scanned_data"
const val SCAN_KEY = "scan_key"
}
}
Loading