diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 572ce2d..ca59e1b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
package="cy.agorise.bitsybitshareswallet">
+
+
, grantResults: IntArray) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+
+ if (requestCode == REQUEST_CAMERA_PERMISSION) {
+ if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
+ startCameraPreview()
+ } else {
+ // TODO extract string resource
+ Toast.makeText(context!!, "Camera permission is necessary to read QR codes.", Toast.LENGTH_SHORT).show()
+ }
+ return
+ }
+ }
+
+ private fun startCameraPreview() {
+ cameraPreview.visibility = View.VISIBLE
+ fabOpenCamera.setImageResource(R.drawable.ic_close)
+ isCameraPreviewVisible = true
+
+ // Configure QR scanner
+ cameraPreview.setFormats(listOf(BarcodeFormat.QR_CODE))
+ cameraPreview.setAspectTolerance(0.5f)
+ cameraPreview.setAutoFocus(true)
+ cameraPreview.setLaserColor(R.color.colorAccent)
+ cameraPreview.setMaskColor(R.color.colorAccent)
+ cameraPreview.setResultHandler(this)
+ cameraPreview.startCamera()
+ }
+
+ private fun stopCameraPreview() {
+ cameraPreview.visibility = View.INVISIBLE
+ fabOpenCamera.setImageResource(R.drawable.ic_camera)
+ isCameraPreviewVisible = false
+ cameraPreview.stopCamera()
+ }
+
+ override fun handleResult(result: Result?) {
+ Toast.makeText(context!!, result!!.text, Toast.LENGTH_SHORT).show()
+ }
+
+ override fun onResume() {
+ super.onResume()
+ if (isCameraPreviewVisible)
+ startCameraPreview()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ if (!isCameraPreviewVisible)
+ stopCameraPreview()
+ }
}
diff --git a/app/src/main/res/drawable/ic_close.xml b/app/src/main/res/drawable/ic_close.xml
new file mode 100644
index 0000000..0c8775c
--- /dev/null
+++ b/app/src/main/res/drawable/ic_close.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/fragment_send_transaction.xml b/app/src/main/res/layout/fragment_send_transaction.xml
index 4b5c111..74fe56b 100644
--- a/app/src/main/res/layout/fragment_send_transaction.xml
+++ b/app/src/main/res/layout/fragment_send_transaction.xml
@@ -42,6 +42,7 @@
android:id="@+id/tietTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:digits="abcdefghijklmnopqrstuvwxyz-0123456789"
android:maxLines="1"/>
@@ -135,7 +136,7 @@
app:layout_constraintEnd_toStartOf="@id/cameraVerticalGuideline"/>