Display correctly all kind of certificates
This commit is contained in:
parent
e7595892f8
commit
5b40805a8b
@ -4,4 +4,10 @@ package org.communiquons.dccaggregator
|
|||||||
const val WALLET_URL = "https://bonjour.tousanticovid.gouv.fr/app/walletdcc#"
|
const val WALLET_URL = "https://bonjour.tousanticovid.gouv.fr/app/walletdcc#"
|
||||||
|
|
||||||
// Name of the preferences file holding certificates list
|
// Name of the preferences file holding certificates list
|
||||||
const val PREF_CERTS_LIST = "certs_list"
|
const val PREF_CERTS_LIST = "certs_list"
|
||||||
|
|
||||||
|
const val RESULT_TEST_NEGATIVE = "260415000"
|
||||||
|
const val RESULT_TEST_POSITIVE = "260373001"
|
||||||
|
|
||||||
|
const val TEST_PCR = "LP6464-4"
|
||||||
|
const val TEST_ANTIGENIC = "LP217198-3"
|
@ -93,6 +93,9 @@ class CertsManager : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshList() {
|
private fun refreshList() {
|
||||||
|
certsList.clear()
|
||||||
|
certsList.addAll(certsManager.certsList)
|
||||||
|
|
||||||
|
listAdapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,6 +33,8 @@ class CertificatesList(context: Context) {
|
|||||||
* Add a certificate to the list
|
* Add a certificate to the list
|
||||||
*/
|
*/
|
||||||
fun addCertificate(cert: Certificate) {
|
fun addCertificate(cert: Certificate) {
|
||||||
listString = listString.apply { add(cert.encoded) }
|
val list = HashSet(listString)
|
||||||
|
list.add(cert.encoded)
|
||||||
|
listString = list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,11 @@ 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 dgca.verifier.app.decoder.model.RecoveryStatement
|
||||||
|
import dgca.verifier.app.decoder.model.Vaccination
|
||||||
import org.communiquons.dccaggregator.R
|
import org.communiquons.dccaggregator.R
|
||||||
|
import org.communiquons.dccaggregator.RESULT_TEST_POSITIVE
|
||||||
|
import org.communiquons.dccaggregator.TEST_ANTIGENIC
|
||||||
|
import org.communiquons.dccaggregator.TEST_PCR
|
||||||
|
|
||||||
@OptIn(ExperimentalUnsignedTypes::class)
|
@OptIn(ExperimentalUnsignedTypes::class)
|
||||||
class Certificate(val encoded: String) {
|
class Certificate(val encoded: String) {
|
||||||
@ -35,15 +39,44 @@ class Certificate(val encoded: String) {
|
|||||||
|
|
||||||
val dateOfBirth get() = decoded.dateOfBirth
|
val dateOfBirth get() = decoded.dateOfBirth
|
||||||
|
|
||||||
|
val test get() = decoded.tests?.getOrNull(0)
|
||||||
|
|
||||||
|
val vaccination: Vaccination? get() = decoded.vaccinations?.getOrNull(0)
|
||||||
|
|
||||||
val recovery: RecoveryStatement? get() = decoded.recoveryStatements?.getOrNull(0)
|
val recovery: RecoveryStatement? get() = decoded.recoveryStatements?.getOrNull(0)
|
||||||
|
|
||||||
fun descText(ctx: Context): String {
|
fun descText(ctx: Context): String {
|
||||||
|
if (vaccination != null)
|
||||||
|
return ctx.resources.getString(
|
||||||
|
R.string.desc_vaccine_certificate,
|
||||||
|
vaccination!!.doseNumber,
|
||||||
|
vaccination!!.totalSeriesOfDoses,
|
||||||
|
vaccination!!.dateOfVaccination,
|
||||||
|
vaccination!!.vaccine
|
||||||
|
)
|
||||||
|
|
||||||
if (recovery != null)
|
if (recovery != null)
|
||||||
return ctx.resources.getString(
|
return ctx.resources.getString(
|
||||||
R.string.desc_recovery_certificate,
|
R.string.desc_recovery_certificate,
|
||||||
recovery!!.dateOfFirstPositiveTest
|
recovery!!.dateOfFirstPositiveTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (test != null)
|
||||||
|
return ctx.resources.getString(
|
||||||
|
R.string.desc_test_certificate,
|
||||||
|
ctx.resources.getString(
|
||||||
|
if (test!!.testResult == RESULT_TEST_POSITIVE)
|
||||||
|
R.string.positive
|
||||||
|
else
|
||||||
|
R.string.negative
|
||||||
|
).uppercase(),
|
||||||
|
test!!.dateTimeOfCollection,
|
||||||
|
ctx.resources.getString(when(test!!.typeOfTest) {
|
||||||
|
TEST_ANTIGENIC -> R.string.antigenic
|
||||||
|
TEST_PCR -> R.string.pcr
|
||||||
|
else -> R.string.unkown_test_type
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
return ctx.resources.getString(R.string.desc_unknown_certificate)
|
return ctx.resources.getString(R.string.desc_unknown_certificate)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
<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="positive">positive</string>
|
||||||
|
<string name="negative">negative</string>
|
||||||
|
|
||||||
|
<string name="pcr">PCR</string>
|
||||||
|
<string name="antigenic">Antigenic</string>
|
||||||
|
<string name="unkown_test_type">Unknown test type</string>
|
||||||
|
|
||||||
|
<string name="desc_test_certificate">Test certificate\nTested %1$s\nDate: %2$s\nTest type: %3$s</string>
|
||||||
|
<string name="desc_vaccine_certificate">Vaccine certificate\nDose %1$d / %2$d\nDate: %3$s\nType: %4$s</string>
|
||||||
<string name="desc_recovery_certificate">Recovery certificate\nTested positive on %1$s</string>
|
<string name="desc_recovery_certificate">Recovery certificate\nTested positive on %1$s</string>
|
||||||
<string name="desc_unknown_certificate">Unknown certificate type</string>
|
<string name="desc_unknown_certificate">Unknown certificate type</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user