diff --git a/app/src/main/java/dgca/verifier/app/android/ViewHolderUtils.kt b/app/src/main/java/dgca/verifier/app/android/ViewHolderUtils.kt new file mode 100644 index 00000000..521699f6 --- /dev/null +++ b/app/src/main/java/dgca/verifier/app/android/ViewHolderUtils.kt @@ -0,0 +1,56 @@ +/* + * ---license-start + * eu-digital-green-certificates / dgca-verifier-app-android + * --- + * Copyright (C) 2021 T-Systems International GmbH and all other contributors + * --- + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ---license-end + * + * Created by osarapulov on 7/22/21 8:42 PM + */ + +package dgca.verifier.app.android + +import android.view.View +import android.widget.TextView +import java.util.* + + +fun String.bindCountryWith(countryTitleView: View, countryValueView: TextView) { + val issuerCountry = + if (this.isNotBlank()) Locale("", this).displayCountry else "" + issuerCountry.apply { + if (this.isNotBlank()) { + countryValueView.text = this + View.VISIBLE + } else { + View.GONE + }.apply { + countryTitleView.visibility = this + countryValueView.visibility = this + } + } +} + +fun String.bindText(titleView: View, valueView: TextView) = apply { + if (this.isNotBlank()) { + valueView.text = this + View.VISIBLE + } else { + View.GONE + }.apply { + titleView.visibility = this + valueView.visibility = this + } +} \ No newline at end of file diff --git a/app/src/main/java/dgca/verifier/app/android/model/CertificateModel.kt b/app/src/main/java/dgca/verifier/app/android/model/CertificateModel.kt index e99e99cf..43d8d668 100644 --- a/app/src/main/java/dgca/verifier/app/android/model/CertificateModel.kt +++ b/app/src/main/java/dgca/verifier/app/android/model/CertificateModel.kt @@ -77,7 +77,7 @@ data class VaccinationModel( data class TestModel( override val disease: DiseaseType, - val typeOfTest: String, + val typeOfTest: TypeOfTest, val testName: String?, val testNameAndManufacturer: String?, val dateTimeOfCollection: String, @@ -100,6 +100,12 @@ enum class DiseaseType(val value: String) { UNDEFINED("UNDEFINED") } +enum class TypeOfTest(val value: String) { + NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION("Nucleic acid amplification with probe detection"), + RAPID_IMMUNOASSAY("Rapid immunoassay"), + UNDEFINED("") +} + data class RecoveryModel( override val disease: DiseaseType, val dateOfFirstPositiveTest: String, diff --git a/app/src/main/java/dgca/verifier/app/android/model/Mapper.kt b/app/src/main/java/dgca/verifier/app/android/model/Mapper.kt index 856f792d..a2026cc0 100644 --- a/app/src/main/java/dgca/verifier/app/android/model/Mapper.kt +++ b/app/src/main/java/dgca/verifier/app/android/model/Mapper.kt @@ -49,7 +49,7 @@ fun RecoveryStatement.toRecoveryModel(): RecoveryModel { fun Test.toTestModel(): TestModel { return TestModel( disease = disease.toDiseaseCode().toDiseaseType(), - typeOfTest = typeOfTest, + typeOfTest = typeOfTest.toTypeOfTestCode().toTypeOfTest(), testName = testName, testNameAndManufacturer = testNameAndManufacturer, dateTimeOfCollection = dateTimeOfCollection, @@ -75,6 +75,12 @@ fun DiseaseCode.toDiseaseType(): DiseaseType = when (this) { else -> DiseaseType.UNDEFINED } +fun TypeOfTestCode.toTypeOfTest(): TypeOfTest = when (this) { + TypeOfTestCode.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION -> TypeOfTest.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION + TypeOfTestCode.RAPID_IMMUNOASSAY -> TypeOfTest.RAPID_IMMUNOASSAY + else -> TypeOfTest.UNDEFINED +} + fun Vaccination.toVaccinationModel(): VaccinationModel { return VaccinationModel( disease = disease.toDiseaseCode().toDiseaseType(), @@ -104,7 +110,19 @@ fun String.toDiseaseCode(): DiseaseCode = when (this) { else -> DiseaseCode.UNDEFINED } +fun String.toTypeOfTestCode(): TypeOfTestCode = when (this) { + TypeOfTestCode.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION.value -> TypeOfTestCode.NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION + TypeOfTestCode.RAPID_IMMUNOASSAY.value -> TypeOfTestCode.RAPID_IMMUNOASSAY + else -> TypeOfTestCode.UNDEFINED +} + enum class DiseaseCode(val value: String) { COVID_19("840539006"), UNDEFINED("") +} + +enum class TypeOfTestCode(val value: String) { + NUCLEIC_ACID_AMPLIFICATION_WITH_PROBE_DETECTION("LP6464-4"), + RAPID_IMMUNOASSAY("LP217198-3"), + UNDEFINED("") } \ No newline at end of file diff --git a/app/src/main/java/dgca/verifier/app/android/verification/VerificationDialogFragment.kt b/app/src/main/java/dgca/verifier/app/android/verification/VerificationDialogFragment.kt index 20e141c7..2aee7126 100644 --- a/app/src/main/java/dgca/verifier/app/android/verification/VerificationDialogFragment.kt +++ b/app/src/main/java/dgca/verifier/app/android/verification/VerificationDialogFragment.kt @@ -123,21 +123,6 @@ class VerificationDialogFragment : BottomSheetDialogFragment() { binding.personFullName.text = certificateModel.getFullName() toggleButton(certificateModel) - - // TODO remove before release - if (verificationData.getGeneralResult() == GeneralVerificationResult.SUCCESS) { - val ruleValidationResultCards = mutableListOf() - val context = requireContext() - binding.rulesList.visibility = View.VISIBLE - viewModel.validationResults.value?.forEach { validationResult -> - ruleValidationResultCards.add( - validationResult.toRuleValidationResultCard(context) - ) - } - binding.rulesList.adapter = - RuleValidationResultsAdapter(layoutInflater, ruleValidationResultCards) - } - if (verificationData.getGeneralResult() != GeneralVerificationResult.FAILED) { showUserData(certificateModel) diff --git a/app/src/main/java/dgca/verifier/app/android/verification/certs/RecoveryViewHolder.kt b/app/src/main/java/dgca/verifier/app/android/verification/certs/RecoveryViewHolder.kt index 1e5f6103..77cecfa0 100644 --- a/app/src/main/java/dgca/verifier/app/android/verification/certs/RecoveryViewHolder.kt +++ b/app/src/main/java/dgca/verifier/app/android/verification/certs/RecoveryViewHolder.kt @@ -24,22 +24,23 @@ package dgca.verifier.app.android.verification.certs import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import dgca.verifier.app.android.FORMATTED_YEAR_MONTH_DAY -import dgca.verifier.app.android.YEAR_MONTH_DAY +import dgca.verifier.app.android.* import dgca.verifier.app.android.databinding.ItemRecoveryBinding import dgca.verifier.app.android.model.RecoveryModel -import dgca.verifier.app.android.parseFromTo class RecoveryViewHolder(private val binding: ItemRecoveryBinding) : RecyclerView.ViewHolder(binding.root) { fun bind(data: RecoveryModel) { - binding.diseaseValue.text = data.disease.value - binding.validFromValue.text = + data.disease.value.bindText(binding.diseaseTitle, binding.diseaseValue) + val validFrom = data.certificateValidFrom.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY) - binding.validUntilValue.text = + val validTo = data.certificateValidUntil.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY) - binding.countryValue.text = data.countryOfVaccination + val validFromTo = + if (validFrom.isNotBlank() && validTo.isNotBlank()) "$validFrom - $validTo" else "" + validFromTo.bindText(binding.validFromTitle, binding.validFromValue) + data.countryOfVaccination.bindCountryWith(binding.countryTitle, binding.countryValue) } companion object { diff --git a/app/src/main/java/dgca/verifier/app/android/verification/certs/TestViewHolder.kt b/app/src/main/java/dgca/verifier/app/android/verification/certs/TestViewHolder.kt index 992dbeec..839ae332 100644 --- a/app/src/main/java/dgca/verifier/app/android/verification/certs/TestViewHolder.kt +++ b/app/src/main/java/dgca/verifier/app/android/verification/certs/TestViewHolder.kt @@ -22,9 +22,10 @@ package dgca.verifier.app.android.verification.certs -import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView +import dgca.verifier.app.android.bindCountryWith +import dgca.verifier.app.android.bindText import dgca.verifier.app.android.databinding.ItemTestBinding import dgca.verifier.app.android.model.TestModel import dgca.verifier.app.android.toFormattedDateTime @@ -32,14 +33,12 @@ import dgca.verifier.app.android.toFormattedDateTime class TestViewHolder(private val binding: ItemTestBinding) : RecyclerView.ViewHolder(binding.root) { fun bind(data: TestModel) { - val dateOfCollectionString: String? = - data.dateTimeOfCollection.toFormattedDateTime()?.apply { - binding.dateOfCollectionValue.text = this - } - binding.dateOfCollectionValue.visibility = - if (dateOfCollectionString?.isNotEmpty() == true) View.VISIBLE else View.GONE - binding.diseaseValue.text = data.disease.value - binding.countryValue.text = data.countryOfVaccination + data.disease.value.bindText(binding.diseaseTitle, binding.diseaseValue) + data.resultType.value.bindText(binding.testResultTitle, binding.testResultValue) + (data.dateTimeOfCollection.toFormattedDateTime() + ?: "").bindText(binding.dateOfCollectionTitle, binding.dateOfCollectionValue) + data.typeOfTest.value.bindText(binding.typeOfTestTitle, binding.typeOfTestValue) + data.countryOfVaccination.bindCountryWith(binding.countryTitle, binding.countryValue) } companion object { diff --git a/app/src/main/java/dgca/verifier/app/android/verification/certs/VaccinationViewHolder.kt b/app/src/main/java/dgca/verifier/app/android/verification/certs/VaccinationViewHolder.kt index ebcc2fa7..737c9e48 100644 --- a/app/src/main/java/dgca/verifier/app/android/verification/certs/VaccinationViewHolder.kt +++ b/app/src/main/java/dgca/verifier/app/android/verification/certs/VaccinationViewHolder.kt @@ -26,6 +26,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import dgca.verifier.app.android.FORMATTED_YEAR_MONTH_DAY import dgca.verifier.app.android.YEAR_MONTH_DAY +import dgca.verifier.app.android.bindCountryWith import dgca.verifier.app.android.databinding.ItemVaccinationBinding import dgca.verifier.app.android.model.VaccinationModel import dgca.verifier.app.android.parseFromTo @@ -37,7 +38,7 @@ class VaccinationViewHolder(private val binding: ItemVaccinationBinding) : binding.dateValue.text = data.dateOfVaccination.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY) binding.diseaseValue.text = data.disease.value - binding.countryValue.text = data.countryOfVaccination + data.countryOfVaccination.bindCountryWith(binding.countryTitle, binding.countryValue) } companion object { diff --git a/app/src/main/res/layout/item_recovery.xml b/app/src/main/res/layout/item_recovery.xml index b1091a2e..8ef61df3 100644 --- a/app/src/main/res/layout/item_recovery.xml +++ b/app/src/main/res/layout/item_recovery.xml @@ -49,29 +49,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:text="@string/date_of_recovery" /> + android:text="@string/certificate_valid_from_to" /> - - - - + tools:text="Feb 26, 1998 - Feb 26, 2000" /> + android:text="@string/country_of_test" /> + tools:text="Germany" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_test.xml b/app/src/main/res/layout/item_test.xml index a27b51c0..0e0379f8 100644 --- a/app/src/main/res/layout/item_test.xml +++ b/app/src/main/res/layout/item_test.xml @@ -41,7 +41,22 @@ style="@style/TextAppearance.Dgca.CertificateValue" android:layout_width="match_parent" android:layout_height="wrap_content" - tools:text="840539006" /> + tools:text="COVID-19" /> + + + + + + + + + android:text="@string/target_disease" /> + tools:text="COVID-19" /> + android:text="@string/date_of_vaccination_title" /> + tools:text="Feb 26, 1998" /> Standardised Given Name Date of Birth Date of Vaccination - Issuer Country Target Disease Date of Test - - Test Result - Date of Recovery - Certificate Expiration - + Certificate Valid From - To Settings Privacy information @@ -78,4 +73,7 @@ Passed for %1$s (see settings) Open for %1$s (see settings) Failed for %1$s (see settings) + Type of Test + Country of Test + Test Result