Skip to content

Commit

Permalink
don't show anything if locale from country code is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
ktiniatros committed Oct 28, 2021
1 parent 3cfacee commit a58e8d5
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 a58e8d5

Please sign in to comment.