diff --git a/app/build.gradle b/app/build.gradle
index c7441b0..3c77a69 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "org.communiquons.dccaggregator"
- minSdk 21
+ minSdk 24
targetSdk 32
versionCode 1
versionName "1.0"
@@ -41,6 +41,7 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.preference:preference:1.2.0'
+ implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64e8bc..e8dc064 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,10 +1,12 @@
+ android:exported="false"
+ android:label="@string/activity_certsmanagers" />
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/org/communiquons/dccaggregator/activities/CertsManager.kt b/app/src/main/java/org/communiquons/dccaggregator/activities/CertsManager.kt
index 2dd2de5..26f4561 100644
--- a/app/src/main/java/org/communiquons/dccaggregator/activities/CertsManager.kt
+++ b/app/src/main/java/org/communiquons/dccaggregator/activities/CertsManager.kt
@@ -4,12 +4,17 @@ import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
+import com.journeyapps.barcodescanner.ScanContract
+import com.journeyapps.barcodescanner.ScanOptions
+import org.communiquons.dccaggregator.R
import org.communiquons.dccaggregator.databinding.ActivityCertsManagerBinding
class CertsManager : AppCompatActivity() {
private lateinit var binding: ActivityCertsManagerBinding
+ private val TAG = CertsManager::class.java.canonicalName
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCertsManagerBinding.inflate(layoutInflater)
@@ -18,7 +23,7 @@ class CertsManager : AppCompatActivity() {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
binding.scanCertButton.setOnClickListener {
- Log.d("d", "FAb clicked!")
+ addNewCertificate()
}
}
@@ -30,4 +35,19 @@ class CertsManager : AppCompatActivity() {
return super.onOptionsItemSelected(item)
}
+
+ private val barcodeLauncher = registerForActivityResult(ScanContract()) {
+ if (it.contents == null)
+ return@registerForActivityResult
+
+ Log.v(TAG, it.contents)
+ }
+
+ private fun addNewCertificate() {
+ barcodeLauncher.launch(ScanOptions().apply {
+ setOrientationLocked(true)
+ setDesiredBarcodeFormats(ScanOptions.QR_CODE)
+ setPrompt(resources.getString(R.string.scan_qr_prompt))
+ })
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2dd4fae..06ea874 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,4 +2,5 @@
DCCAggregator
Input certificates
Add a new certificate
+ Please present the QrCode of the certificate you want to add
\ No newline at end of file