100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Added QrScannerProvider for Android
Michael Rademaker713541a552f8
diff --git a/console/android/ORLib/build.gradle b/console/android/ORLib/build.gradleindex 123b08e89..da3b978b1 100644--- a/console/android/ORLib/build.gradle+++ b/console/android/ORLib/build.gradle@@ -43,11 +43,8 @@ dependencies {implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.preference:preference-ktx:1.1.1'implementation "com.google.android.gms:play-services-location:18.0.0"+ implementation 'com.google.android.gms:play-services-vision:20.1.3'implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8"implementation platform('com.google.firebase:firebase-bom:26.0.0')implementation 'com.google.firebase:firebase-messaging-ktx'- implementation 'androidx.camera:camera-core:1.1.0-alpha03'- implementation 'androidx.camera:camera-lifecycle:1.1.0-alpha03'- implementation 'com.google.mlkit:vision-common:16.3.0'- implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:16.2.1'}\ No newline at end of filediff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/service/GeofenceProvider.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/service/GeofenceProvider.ktindex ce6b01463..bbe4b3a7e 100644--- a/console/android/ORLib/src/main/java/io/openremote/orlib/service/GeofenceProvider.kt+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/service/GeofenceProvider.kt@@ -383,8 +383,8 @@ class GeofenceProvider(val context: Context) {.setIcon(R.mipmap.ic_launcher).setTitle(R.string.location_background_disabled_title).setMessage(R.string.background_location_alert_body)- .setNegativeButton(R.string.background_location_decline, null)- .setPositiveButton(R.string.background_location_accept) { dialog, which ->+ .setNegativeButton(R.string.no, null)+ .setPositiveButton(R.string.yes) { dialog, which ->activity.requestPermissions(arrayOf(ACCESS_BACKGROUND_LOCATION@@ -421,8 +421,8 @@ class GeofenceProvider(val context: Context) {.setIcon(R.mipmap.ic_launcher).setTitle(R.string.background_location_alert_title).setMessage(R.string.background_location_alert_body)- .setNegativeButton(R.string.background_location_decline, null)- .setPositiveButton(R.string.background_location_accept) { dialog, which ->+ .setNegativeButton(R.string.no, null)+ .setPositiveButton(R.string.yes) { dialog, which ->activity.requestPermissions(arrayOf(ACCESS_BACKGROUND_LOCATIONdiff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/service/QrScannerProvider.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/service/QrScannerProvider.ktindex 88ef87ff4..f4ede87f4 100644--- a/console/android/ORLib/src/main/java/io/openremote/orlib/service/QrScannerProvider.kt+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/service/QrScannerProvider.kt@@ -1,4 +1,133 @@package io.openremote.orlib.service-class QrScannerProvider {+import android.Manifest+import android.app.Activity+import android.content.Context+import android.content.Intent+import android.content.pm.PackageManager+import androidx.appcompat.app.AlertDialog+import androidx.core.app.ActivityCompat+import io.openremote.orlib.R+import io.openremote.orlib.ui.QrScannerActivity++class QrScannerProvider(val context: Context) {+ interface ScannerCallback {+ fun accept(responseData: Map<String, Any>)+ }++ companion object {+ private const val cameraPermissionAskedKey = "CameraPermissionAsked"+ private const val qrDisabledKey = "qrDisabled"+ private const val version = "qr"+ const val REQUEST_CAMERA_PERMISSION = 201+ const val REQUEST_SCAN_QR = 222+ }++ private var enableCallback: ScannerCallback? = null++ fun initialize(): Map<String, Any> {+ val sharedPreferences =+ context.getSharedPreferences(context.getString(R.string.app_name), Context.MODE_PRIVATE)++ return hashMapOf(+ "action" to "PROVIDER_INIT",+ "provider" to "qr",+ "version" to version,+ "requiresPermission" to true,+ "hasPermission" to (+ context.checkSelfPermission(+ Manifest.permission.CAMERA+ ) == PackageManager.PERMISSION_GRANTED),+ "success" to true,+ "enabled" to false, // Always require enabling to ensure geofences are refresh at startup+ "disabled" to sharedPreferences.contains(qrDisabledKey)+ )+ }++ fun enable(callback: ScannerCallback?) {+ val sharedPreferences =+ context.getSharedPreferences(context.getString(R.string.app_name), Context.MODE_PRIVATE)++ sharedPreferences.edit()+ .remove(qrDisabledKey)+ .apply()++ val hasPermission =+ context.checkSelfPermission(+ Manifest.permission.CAMERA+ ) == PackageManager.PERMISSION_GRANTED++++ if (!hasPermission && !sharedPreferences.getBoolean(+ cameraPermissionAskedKey, false+ )+ ) {+ sharedPreferences.edit().putBoolean(cameraPermissionAskedKey, true).apply()+ ActivityCompat.requestPermissions(+ context as Activity,+ arrayOf(Manifest.permission.CAMERA),+ REQUEST_CAMERA_PERMISSION+ )+ enableCallback = callback+ } else {+ callback?.accept(+ hashMapOf(+ "action" to "PROVIDER_ENABLE",+ "provider" to "qr",+ "hasPermission" to hasPermission,+ "success" to true+ )+ )+ }+ }++ fun disable(): Map<String, Any> {+ val sharedPreferences =+ context.getSharedPreferences(context.getString(R.string.app_name), Context.MODE_PRIVATE)+ sharedPreferences.edit()+ .putBoolean(cameraPermissionAskedKey, true)+ .apply()++ return hashMapOf(+ "action" to "PROVIDER_DISABLE",+ "provider" to "qr"+ )+ }++ fun onRequestPermissionsResult(+ requestCode: Int,+ permissions: Array<String>,+ grantResults: IntArray+ ) {+ if (requestCode == REQUEST_CAMERA_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) {+ enableCallback?.accept(+ hashMapOf(+ "action" to "PROVIDER_ENABLE",+ "provider" to "qr",+ "hasPermission" to true,+ "success" to true+ )+ )+ } else {+ AlertDialog.Builder(context)+ .setIcon(R.mipmap.ic_launcher)+ .setTitle(R.string.camera_needed_alert_title)+ .setMessage(R.string.camera_needed_alert_body)+ .setNegativeButton(R.string.no, null)+ .setPositiveButton(R.string.yes) { dialog, which ->+ ActivityCompat.requestPermissions(+ context as Activity,+ arrayOf(Manifest.permission.CAMERA),+ REQUEST_CAMERA_PERMISSION+ )+ }+ .show()+ }+ }++ fun startScanner(activity: Activity) {+ val intent = Intent(activity, QrScannerActivity::class.java)+ activity.startActivityForResult(intent, REQUEST_SCAN_QR)+ }}\ No newline at end of filediff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.ktindex 5000c1aee..64f07855b 100644--- a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt@@ -34,6 +34,7 @@ import io.openremote.orlib.databinding.ActivityOrMainBindingimport io.openremote.orlib.models.ORAppConfigimport io.openremote.orlib.network.ApiManagerimport io.openremote.orlib.service.GeofenceProvider+import io.openremote.orlib.service.QrScannerProviderimport org.json.JSONExceptionimport org.json.JSONObjectimport java.util.*@@ -53,6 +54,7 @@ open class OrMainActivity : Activity() {private var webViewLoaded = falseprivate var sharedPreferences: SharedPreferences? = nullprivate var geofenceProvider: GeofenceProvider? = null+ private var qrScannerProvider: QrScannerProvider? = nullprivate var consoleId: String? = nullprivate var appConfig: ORAppConfig? = nullprivate var onDownloadCompleteReciever: BroadcastReceiver = object : BroadcastReceiver() {@@ -515,10 +517,20 @@ open class OrMainActivity : Activity() {}} else if (requestCode == GeofenceProvider.locationResponseCode) {geofenceProvider?.onRequestPermissionsResult(this)+ } else if (requestCode == QrScannerProvider.REQUEST_CAMERA_PERMISSION) {+ qrScannerProvider?.onRequestPermissionsResult(requestCode, permissions, grantResults)}super.onRequestPermissionsResult(requestCode, permissions, grantResults)}+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {+ super.onActivityResult(requestCode, resultCode, data)+ if (requestCode == QrScannerProvider.REQUEST_SCAN_QR) {+ val qrResult = data?.getStringExtra("result")+ notifyClient(hashMapOf("result" to qrResult))+ }+ }+private inner class WebAppInterface(private val activity: Activity) {@@ -713,6 +725,34 @@ open class OrMainActivity : Activity() {}}+ @Throws(JSONException::class)+ private fun handleQrScannerProviderMessage(data: JSONObject) {+ val action = data.getString("action")+ if (qrScannerProvider == null) {+ qrScannerProvider = QrScannerProvider(activity)+ }+ when {+ action.equals("PROVIDER_INIT", ignoreCase = true) -> {+ val initData: Map<String, Any> = qrScannerProvider!!.initialize()+ notifyClient(initData)+ }+ action.equals("PROVIDER_ENABLE", ignoreCase = true) -> {++ qrScannerProvider?.enable(object : QrScannerProvider.ScannerCallback {+ override fun accept(responseData: Map<String, Any>) {+ notifyClient(responseData)+ }+ })+ }+ action.equals("PROVIDER_DISABLE", ignoreCase = true) -> {+ val response = qrScannerProvider?.disable()+ notifyClient(response)+ }+ action.equals("SCAN_QR", ignoreCase = true) -> {+ qrScannerProvider?.startScanner(this@OrMainActivity)+ }+ }+ }}private fun notifyClient(data: Map<String, Any?>?) {diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerActivity.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerActivity.ktindex 059d94c7d..7a5218729 100644--- a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerActivity.kt+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerActivity.kt@@ -2,234 +2,126 @@ package io.openremote.orlib.uiimport android.Manifestimport android.annotation.SuppressLint-import android.app.Activity+import android.content.Intentimport android.content.pm.PackageManager-import android.net.Uriimport android.os.Bundle-import android.util.Log-import android.widget.Toast-import androidx.camera.core.*-import androidx.camera.lifecycle.ProcessCameraProvider+import android.view.SurfaceHolder+import android.view.SurfaceView+import androidx.appcompat.app.AppCompatActivityimport androidx.core.app.ActivityCompat-import androidx.core.content.ContextCompat-import com.google.mlkit.vision.barcode.Barcode-import com.google.mlkit.vision.barcode.BarcodeScannerOptions-import com.google.mlkit.vision.barcode.BarcodeScanning-import com.google.mlkit.vision.common.InputImage-import io.openremote.orlib.databinding.ActivityOrMainBinding+import com.google.android.gms.vision.CameraSource+import com.google.android.gms.vision.Detector+import com.google.android.gms.vision.Detector.Detections+import com.google.android.gms.vision.barcode.Barcode+import com.google.android.gms.vision.barcode.BarcodeDetector+import io.openremote.orlib.Rimport io.openremote.orlib.databinding.ActivityOrQrScannerBinding-import java.io.File-import java.nio.ByteBuffer-import java.text.SimpleDateFormat-import java.util.*-import java.util.concurrent.ExecutorService-import java.util.concurrent.Executors+import java.io.IOException-typealias QrListener = (qrValue: String) -> Unit--class QrScannerActivity : Activity() {- private lateinit var binding: ActivityOrQrScannerBinding-- private var imageCapture: ImageCapture? = null-- private lateinit var outputDirectory: File- private lateinit var cameraExecutor: ExecutorService+class QrScannerActivity : AppCompatActivity() {+ private var binding: ActivityOrQrScannerBinding? = null+ private var surfaceView: SurfaceView? = null+ private var barcodeDetector: BarcodeDetector? = null+ private var cameraSource: CameraSource? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)binding = ActivityOrQrScannerBinding.inflate(layoutInflater)- val view = binding.root- setContentView(view)-- // Request camera permissions- if (allPermissionsGranted()) {- startCamera()- } else {- ActivityCompat.requestPermissions(- this, REQUIRED_PERMISSIONS, REQUEST_CODE_PERMISSIONS- )- }-- // Setup the listener for take photo button-// camera_capture_button.setOnClickListener { takePhoto() }+ val view = binding!!.root- outputDirectory = getOutputDirectory()-- cameraExecutor = Executors.newSingleThreadExecutor()+ setContentView(view)+ supportActionBar!!.title = "Scan QR Code"+ initViews()}- private fun takePhoto() {- // Get a stable reference of the modifiable image capture use case- val imageCapture = imageCapture ?: return-- // Create timestamped output file to hold the image- val photoFile = File(- outputDirectory,- SimpleDateFormat(- FILENAME_FORMAT, Locale.US- ).format(System.currentTimeMillis()) + ".jpg"- )-- // Create output options object which contains file + metadata- val outputOptions = ImageCapture.OutputFileOptions.Builder(photoFile).build()-- // Setup image capture listener which is triggered after photo has- // been taken- imageCapture.takePicture(- outputOptions,- ContextCompat.getMainExecutor(this),- object : ImageCapture.OnImageSavedCallback {- override fun onError(exc: ImageCaptureException) {- Log.e(TAG, "Photo capture failed: ${exc.message}", exc)- }-- override fun onImageSaved(output: ImageCapture.OutputFileResults) {- val savedUri = Uri.fromFile(photoFile)- val msg = "Photo capture succeeded: $savedUri"- Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show()- Log.d(TAG, msg)- }- })+ private fun initViews() {+ surfaceView = findViewById(R.id.surfaceView)}- private fun startCamera() {- val cameraProviderFuture = ProcessCameraProvider.getInstance(this)-- cameraProviderFuture.addListener(Runnable {- // Used to bind the lifecycle of cameras to the lifecycle owner- val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()-- // Preview- val preview = Preview.Builder()- .build()- .also {- it.setSurfaceProvider(viewFinder.createSurfaceProvider())- }-- imageCapture = ImageCapture.Builder()- .build()-- val imageAnalyzer = ImageAnalysis.Builder()- .build()- .also {- it.setAnalyzer(cameraExecutor, QrAnalyzer { luma ->- Log.d(TAG, "Average luminosity: $luma")- })+ private fun initialiseDetectorsAndSources() {+ barcodeDetector = BarcodeDetector.Builder(this)+ .setBarcodeFormats(Barcode.QR_CODE)+ .build()+ cameraSource = CameraSource.Builder(this, barcodeDetector)+ .setAutoFocusEnabled(true) //you should add this feature+ .setFacing(CameraSource.CAMERA_FACING_BACK)+ .build()+ surfaceView!!.holder.addCallback(object : SurfaceHolder.Callback {+ override fun surfaceCreated(holder: SurfaceHolder) {+ try {+ if (ActivityCompat.checkSelfPermission(+ this@QrScannerActivity,+ Manifest.permission.CAMERA+ ) == PackageManager.PERMISSION_GRANTED+ ) {+ cameraSource!!.start(surfaceView!!.holder)+ } else {+ ActivityCompat.requestPermissions(+ this@QrScannerActivity,+ arrayOf(Manifest.permission.CAMERA),+ REQUEST_CAMERA_PERMISSION+ )+ }+ } catch (e: IOException) {+ e.printStackTrace()}-- // Select back camera as a default- val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA-- try {- // Unbind use cases before rebinding- cameraProvider.unbindAll()-- // Bind use cases to camera- cameraProvider.bindToLifecycle(- this, cameraSelector, preview, imageCapture, imageAnalyzer- )-- } catch (exc: Exception) {- Log.e(TAG, "Use case binding failed", exc)}- }, ContextCompat.getMainExecutor(this))- }-- private fun allPermissionsGranted() = REQUIRED_PERMISSIONS.all {- ContextCompat.checkSelfPermission(- baseContext, it- ) == PackageManager.PERMISSION_GRANTED- }+ override fun surfaceChanged(+ holder: SurfaceHolder,+ format: Int,+ width: Int,+ height: Int+ ) {+ }- private fun getOutputDirectory(): File {- val mediaDir = externalMediaDirs.firstOrNull()?.let {- File(it, resources.getString(R.string.app_name)).apply { mkdirs() }- }- return if (mediaDir != null && mediaDir.exists())- mediaDir else filesDir- }+ override fun surfaceDestroyed(holder: SurfaceHolder) {+ cameraSource!!.stop()+ }+ })+ barcodeDetector!!.setProcessor(object : Detector.Processor<Barcode> {+ override fun release() {+ }- override fun onDestroy() {- super.onDestroy()- cameraExecutor.shutdown()+ override fun receiveDetections(detections: Detections<Barcode>) {+ val barcodes = detections.detectedItems+ if (barcodes.size() != 0) {+ val data = Intent()+ data.putExtra("result", barcodes.valueAt(0).displayValue)+ setResult(RESULT_OK, data)+ finish()+ }+ }+ })}+ @SuppressLint("MissingPermission")override fun onRequestPermissionsResult(- requestCode: Int, permissions: Array<String>, grantResults:- IntArray+ requestCode: Int,+ permissions: Array<String>,+ grantResults: IntArray) {- if (requestCode == REQUEST_CODE_PERMISSIONS) {- if (allPermissionsGranted()) {- startCamera()- } else {- Toast.makeText(- this,- "Permissions not granted by the user.",- Toast.LENGTH_SHORT- ).show()- finish()+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)+ if (requestCode == REQUEST_CAMERA_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) {+ try {+ cameraSource!!.start(surfaceView!!.holder)+ } catch (e: IOException) {+ e.printStackTrace()}}}- companion object {- private const val TAG = "CameraXBasic"- private const val FILENAME_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS"- private const val REQUEST_CODE_PERMISSIONS = 10- private val REQUIRED_PERMISSIONS = arrayOf(Manifest.permission.CAMERA)- }-}--class QrAnalyzer(private val listener: QrListener) : ImageAnalysis.Analyzer {-- private fun ByteBuffer.toByteArray(): ByteArray {- rewind() // Rewind the buffer to zero- val data = ByteArray(remaining())- get(data) // Copy the buffer into a byte array- return data // Return the byte array+ override fun onPause() {+ super.onPause()+ cameraSource!!.release()}- @SuppressLint("UnsafeExperimentalUsageError")- override fun analyze(image: ImageProxy) {-- val mediaImage = image.image- if (mediaImage != null) {- val img = InputImage.fromMediaImage(mediaImage, image.imageInfo.rotationDegrees)- // Pass image to an ML Kit Vision API- // ...- scan(img)- }-- image.close()+ override fun onResume() {+ super.onResume()+ initialiseDetectorsAndSources()}- private fun scan(image: InputImage) {-- val options = BarcodeScannerOptions.Builder()- .setBarcodeFormats(- Barcode.FORMAT_ALL_FORMATS- )- .build()-- val scanner = BarcodeScanning.getClient(options)- val result = scanner.process(image)- .addOnSuccessListener { barcodes ->- // Task completed successfully- // [START_EXCLUDE]- // [START get_barcodes]- for (barcode in barcodes) {- val bounds = barcode.boundingBox- val corners = barcode.cornerPoints-- val rawValue = barcode.rawValue-- val valueType = barcode.valueType- // See API reference for complete list of supported types- Log.v("TESTING: ", "Barcode detected: $rawValue")- }- }- .addOnFailureListener { }- .addOnCompleteListener { }+ companion object {+ private const val REQUEST_CAMERA_PERMISSION = 201}}\ No newline at end of filediff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerView.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerView.ktnew file mode 100644index 000000000..627123f04--- /dev/null+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/QrScannerView.kt@@ -0,0 +1,84 @@+package io.openremote.orlib.ui++import android.content.Context+import android.graphics.Canvas+import android.graphics.Color+import android.graphics.Paint+import android.graphics.Point+import android.os.Build+import android.util.AttributeSet+import android.view.View+import androidx.annotation.RequiresApi+import androidx.core.content.ContextCompat+import io.openremote.orlib.R++class QrScannerView : View {+ private var mPaint: Paint? = null+ private var mStrokePaint: Paint? = null+ private val pTopLeft = Point()+ private val pBotRight = Point()++ constructor(context: Context?) : super(context) {+ initPaints()+ }++ constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {+ initPaints()+ }++ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(+ context,+ attrs,+ defStyleAttr+ ) {+ initPaints()+ }++ private fun initPaints() {+ mPaint = Paint()+ mPaint!!.color = Color.parseColor("#A6000000")+ mStrokePaint = Paint()+ mStrokePaint!!.color = Color.YELLOW+ mStrokePaint!!.strokeWidth = 4f+ mStrokePaint!!.style = Paint.Style.STROKE+ }++ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)+ override fun onDraw(canvas: Canvas) {+ super.onDraw(canvas)+ pTopLeft.x = width / 13 + 10+ pTopLeft.y = height / 4 + 20+ pBotRight.x = width - pTopLeft.x - 10+ pBotRight.y = height - pTopLeft.y - 20+ mPaint!!.color = Color.parseColor("#77000000")++ //Top Rect+ canvas.drawRect(0f, 0f, width.toFloat(), pTopLeft.y.toFloat(), mPaint!!)++ //Left Rect+ canvas.drawRect(+ 0f,+ pTopLeft.y.toFloat(),+ pTopLeft.x.toFloat(),+ pBotRight.y.toFloat(),+ mPaint!!+ )++ //Right Rect+ canvas.drawRect(+ pBotRight.x.toFloat(),+ pTopLeft.y.toFloat(),+ width.toFloat(),+ pBotRight.y.toFloat(),+ mPaint!!+ )++ //Bottom rect+ canvas.drawRect(0f, pBotRight.y.toFloat(), width.toFloat(), height.toFloat(), mPaint!!)++ //Draw Outer Line drawable+ val d = ContextCompat.getDrawable(context, R.drawable.scanner_outline)+ d?.setBounds(pTopLeft.x, pTopLeft.y, pBotRight.x, pBotRight.y)+ d?.draw(canvas)+ }+}\ No newline at end of filediff --git a/console/android/ORLib/src/main/res/drawable/scanner_outline.xml b/console/android/ORLib/src/main/res/drawable/scanner_outline.xmlnew file mode 100644index 000000000..3453e035a--- /dev/null+++ b/console/android/ORLib/src/main/res/drawable/scanner_outline.xml@@ -0,0 +1,16 @@+<vector+ xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="220dp" android:height="220dp" android:viewportHeight="230.0" android:viewportWidth="230.0">+ <path android:fillColor="#00000000" android:fillType="evenOdd"+ android:pathData="M165,5C178.2,5 198.2,5 225,5L225,30.79L225,65"+ android:strokeColor="@color/qr_code_reader_square" android:strokeWidth="10"/>+ <path android:fillColor="#00000000" android:fillType="evenOdd"+ android:pathData="M5,65C5,51.8 5,31.8 5,5L30.79,5L65,5"+ android:strokeColor="@color/qr_code_reader_square" android:strokeWidth="10"/>+ <path android:fillColor="#00000000" android:fillType="evenOdd"+ android:pathData="M165,225C178.2,225 198.2,225 225,225L225,199.21L225,165"+ android:strokeColor="@color/qr_code_reader_square" android:strokeWidth="10"/>+ <path android:fillColor="#00000000" android:fillType="evenOdd"+ android:pathData="M5,165C5,178.2 5,198.2 5,225L30.79,225L65,225"+ android:strokeColor="@color/qr_code_reader_square" android:strokeWidth="10"/>+</vector>\ No newline at end of filediff --git a/console/android/ORLib/src/main/res/layout/activity_or_qr_scanner.xml b/console/android/ORLib/src/main/res/layout/activity_or_qr_scanner.xmlindex 1d7f1afa5..4252061c1 100644--- a/console/android/ORLib/src/main/res/layout/activity_or_qr_scanner.xml+++ b/console/android/ORLib/src/main/res/layout/activity_or_qr_scanner.xml@@ -1,8 +1,20 @@<?xml version="1.0" encoding="utf-8"?>-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:tools="http://schemas.android.com/tools"tools:context=".ui.QrScannerActivity">-</androidx.constraintlayout.widget.ConstraintLayout>\ No newline at end of file+ <SurfaceView+ android:id="@+id/surfaceView"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:layout_alignParentStart="true"+ android:layout_alignParentLeft="true"+ android:layout_centerVertical="true" />++ <io.openremote.orlib.ui.QrScannerView+ android:layout_width="match_parent"+ android:layout_height="match_parent"/>++</RelativeLayout>\ No newline at end of filediff --git a/console/android/ORLib/src/main/res/values/colors.xml b/console/android/ORLib/src/main/res/values/colors.xmlindex 8f707b9e3..40309c13a 100644--- a/console/android/ORLib/src/main/res/values/colors.xml+++ b/console/android/ORLib/src/main/res/values/colors.xml@@ -16,4 +16,6 @@<item name="yellow" type="color">#fffbc02d</item><item name="blue" type="color">#ff1976d2</item><item name="purple" type="color">#ff660092</item>++ <color name="qr_code_reader_square">#FFFFFFFF</color></resources>\ No newline at end of filediff --git a/console/android/ORLib/src/main/res/values/strings.xml b/console/android/ORLib/src/main/res/values/strings.xmlindex f4e631976..2b483085a 100644--- a/console/android/ORLib/src/main/res/values/strings.xml+++ b/console/android/ORLib/src/main/res/values/strings.xml@@ -17,9 +17,11 @@<string name="download_completed">Download completed</string><string name="background_location_alert_title">Background location needed</string><string name="background_location_alert_body">In order to receive these notifications when the app is running in the background, background location access is needed.\nNo location history is stored, only the latest location is saved.\nDo you want to enabled it in the settings?</string>+ <string name="camera_needed_alert_title">Camera access needed</string>+ <string name="camera_needed_alert_body">In order to scan QR codes, access to the devices camera is needed.</string><string name="location_background_disabled_title">Background location disabled</string>- <string name="background_location_decline">No</string>- <string name="background_location_accept">Yes</string>+ <string name="no">No</string>+ <string name="yes">Yes</string><string name="button_accept">Accept</string><string name="NOTIFICATION_CHANNEL_ID">OR</string></resources>\ No newline at end of file