Start to show certificates description
This commit is contained in:
parent
afa65c8239
commit
e7595892f8
@ -5,10 +5,10 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.ImageView
|
|
||||||
import com.google.zxing.BarcodeFormat
|
import com.google.zxing.BarcodeFormat
|
||||||
import com.journeyapps.barcodescanner.BarcodeEncoder
|
import com.journeyapps.barcodescanner.BarcodeEncoder
|
||||||
import org.communiquons.dccaggregator.R
|
import org.communiquons.dccaggregator.R
|
||||||
|
import org.communiquons.dccaggregator.databinding.QrEntryBinding
|
||||||
import org.communiquons.dccaggregator.ext.toDimensSize
|
import org.communiquons.dccaggregator.ext.toDimensSize
|
||||||
import org.communiquons.dccaggregator.models.Certificate
|
import org.communiquons.dccaggregator.models.Certificate
|
||||||
|
|
||||||
@ -20,17 +20,23 @@ class CertificatesAdapter(cxt: Context, list: ArrayList<Certificate>) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
val view =
|
val binding =
|
||||||
convertView ?: LayoutInflater.from(context).inflate(R.layout.qr_entry, parent, false)
|
if (convertView == null)
|
||||||
|
QrEntryBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||||
|
else QrEntryBinding.bind(convertView)
|
||||||
|
|
||||||
val cert = getItem(position) as Certificate
|
val cert = getItem(position) as Certificate
|
||||||
|
|
||||||
// Generate Qr code
|
// Generate Qr code
|
||||||
val bitmap =
|
val bitmap =
|
||||||
BarcodeEncoder().encodeBitmap(cert.encoded, BarcodeFormat.QR_CODE, qrSize, qrSize)
|
BarcodeEncoder().encodeBitmap(cert.encoded, BarcodeFormat.QR_CODE, qrSize, qrSize)
|
||||||
view.findViewById<ImageView>(R.id.certQrCode).setImageBitmap(bitmap)
|
binding.certQrCode.setImageBitmap(bitmap)
|
||||||
|
|
||||||
|
|
||||||
return view
|
binding.userName.text = cert.fullName
|
||||||
|
binding.dateOfBirth.text = cert.dateOfBirth
|
||||||
|
binding.certificateDescription.text = cert.descText(context)
|
||||||
|
|
||||||
|
return binding.root
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
package org.communiquons.dccaggregator.models
|
package org.communiquons.dccaggregator.models
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import dgca.verifier.app.decoder.CertificateDecodingResult
|
import dgca.verifier.app.decoder.CertificateDecodingResult
|
||||||
import dgca.verifier.app.decoder.DefaultCertificateDecoder
|
import dgca.verifier.app.decoder.DefaultCertificateDecoder
|
||||||
import dgca.verifier.app.decoder.base45.Base45Decoder
|
import dgca.verifier.app.decoder.base45.Base45Decoder
|
||||||
import dgca.verifier.app.decoder.model.GreenCertificate
|
import dgca.verifier.app.decoder.model.GreenCertificate
|
||||||
|
import dgca.verifier.app.decoder.model.RecoveryStatement
|
||||||
|
import org.communiquons.dccaggregator.R
|
||||||
|
|
||||||
@OptIn(ExperimentalUnsignedTypes::class)
|
@OptIn(ExperimentalUnsignedTypes::class)
|
||||||
class Certificate(val encoded: String) {
|
class Certificate(val encoded: String) {
|
||||||
@ -29,4 +32,19 @@ class Certificate(val encoded: String) {
|
|||||||
* Get certificate id
|
* Get certificate id
|
||||||
*/
|
*/
|
||||||
val id get() = decoded.getDgci()
|
val id get() = decoded.getDgci()
|
||||||
|
|
||||||
|
val dateOfBirth get() = decoded.dateOfBirth
|
||||||
|
|
||||||
|
val recovery: RecoveryStatement? get() = decoded.recoveryStatements?.getOrNull(0)
|
||||||
|
|
||||||
|
fun descText(ctx: Context): String {
|
||||||
|
if (recovery != null)
|
||||||
|
return ctx.resources.getString(
|
||||||
|
R.string.desc_recovery_certificate,
|
||||||
|
recovery!!.dateOfFirstPositiveTest
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
return ctx.resources.getString(R.string.desc_unknown_certificate)
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,4 +6,7 @@
|
|||||||
<string name="action_import_certificate">Import certificate</string>
|
<string name="action_import_certificate">Import certificate</string>
|
||||||
<string name="invalid_certificate">The given certificate could not be decoded!</string>
|
<string name="invalid_certificate">The given certificate could not be decoded!</string>
|
||||||
<string name="certificate_qr_code">Certificate QR Code</string>
|
<string name="certificate_qr_code">Certificate QR Code</string>
|
||||||
|
|
||||||
|
<string name="desc_recovery_certificate">Recovery certificate\nTested positive on %1$s</string>
|
||||||
|
<string name="desc_unknown_certificate">Unknown certificate type</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user