Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated fields displaying #161

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions app/src/main/java/dgca/verifier/app/android/ViewHolderUtils.kt
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/java/dgca/verifier/app/android/model/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
Expand Down Expand Up @@ -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("")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuleValidationResultCard>()
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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,23 @@

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

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
23 changes: 4 additions & 19 deletions app/src/main/res/layout/item_recovery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,28 @@
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" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/valid_from_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Feb 26, 1998" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/valid_until_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/certificate_expiration" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/valid_until_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Feb 26, 1998" />
tools:text="Feb 26, 1998 - Feb 26, 2000" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/country_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/issuer_country" />
android:text="@string/country_of_test" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/country_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="UA" />
tools:text="Germany" />

</LinearLayout>
32 changes: 31 additions & 1 deletion app/src/main/res/layout/item_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/test_result_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/test_result" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/test_result_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="NOT DETECTED" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/date_of_collection_title"
Expand All @@ -58,6 +73,21 @@
android:layout_height="wrap_content"
tools:text="Feb 26, 1998" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/type_of_test_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/type_of_test" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/type_of_test_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Rapid immunoassay" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/country_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/layout/item_vaccination.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,34 @@
tools:background="@color/white">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/date_title"
android:id="@+id/disease_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/date_of_vaccination_title" />
android:text="@string/target_disease" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/date_value"
android:id="@+id/disease_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Feb 26, 1998" />
tools:text="COVID-19" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/disease_title"
android:id="@+id/date_title"
style="@style/TextAppearance.Dgca.CertificateTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/target_disease" />
android:text="@string/date_of_vaccination_title" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/disease_value"
android:id="@+id/date_value"
style="@style/TextAppearance.Dgca.CertificateValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="840539006" />
tools:text="Feb 26, 1998" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/country_title"
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,11 @@
<string name="standardised_given_name_title">Standardised Given Name</string>
<string name="date_of_birth_title">Date of Birth</string>
<string name="date_of_vaccination_title">Date of Vaccination</string>
<!-- <string name="dose_number_title">Dose Number</string>-->
<string name="issuer_country">Issuer Country</string>
<string name="target_disease">Target Disease</string>
<string name="date_of_test">Date of Test</string>
<!-- <string name="date_of_test_result_title">Date of Test Result</string>-->
<!-- <string name="type_of_test_title">Type of Test</string>-->
<string name="test_result_title">Test Result</string>
<string name="date_of_recovery">Date of Recovery</string>
<string name="certificate_expiration">Certificate Expiration</string>
<!-- <string name="date_of_positive_title">Date of First Positive Test</string>-->
<string name="certificate_valid_from_to">Certificate Valid From - To</string>

<string name="settings">Settings</string>
<string name="privacy_information">Privacy information</string>
Expand Down Expand Up @@ -78,4 +73,7 @@
<string name="passed_for">Passed for %1$s (see settings)</string>
<string name="open_for">Open for %1$s (see settings)</string>
<string name="failed_for">Failed for %1$s (see settings)</string>
<string name="type_of_test">Type of Test</string>
<string name="country_of_test">Country of Test</string>
<string name="test_result">Test Result</string>
</resources>