Skip to content

Commit

Permalink
Merge pull request #799 from minvws/2114-leave-flag-empty-if-no-valid…
Browse files Browse the repository at this point in the history
…-country-is-provided

don't show anything if locale from country code is not valid
  • Loading branch information
ktiniatros authored Oct 28, 2021
2 parents 3cfacee + a58e8d5 commit de4f510
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ val Locale.flagEmoji: String
get() {
val firstLetter = Character.codePointAt(country, 0) - 0x41 + 0x1F1E6
val secondLetter = Character.codePointAt(country, 1) - 0x41 + 0x1F1E6
return String(Character.toChars(firstLetter)) + String(Character.toChars(secondLetter))

// check if the locale created by the country code provided
// is valid. if it is not, we leave it empty
return try {
isO3Country
String(Character.toChars(firstLetter)) + String(Character.toChars(secondLetter))
} catch (exception: MissingResourceException) {
""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ class ScanResultPersonalDetailsFragment :
binding.personalDetailsBirthdate.setContent(personalDetails.birthDay)
if (testResultAttributes.isInternationalDCC()) {
binding.internationalDescription.visibility = View.VISIBLE
val dccLocale = Locale("", testResultAttributes.issuerCountryCode)
val text = getString(
R.string.scan_result_valid_international_scanned,
Locale("", testResultAttributes.issuerCountryCode).flagEmoji
dccLocale.flagEmoji
)
binding.internationalDescription.text = increasedSizeFlagEmoji(text)
if (dccLocale.flagEmoji.isNotEmpty()) {
binding.internationalDescription.text = increasedSizeFlagEmoji(text)
}
}
}

Expand Down

0 comments on commit de4f510

Please sign in to comment.