[#1359] Remove fixed US locale

* [#1359]: Use default Locale in PercentDecimal

* Intended use of Local.US

* Use default Locale in Transaction history dates

* Use default Locale in Balance widget

* Use default Locale in Send tests

* Use default Locale in WalletDisplayValues.kt
This commit is contained in:
Honza Rychnovský 2024-04-18 13:05:32 +02:00 committed by GitHub
parent cada044991
commit e92c0b613c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 11 additions and 20 deletions

View File

@ -251,6 +251,7 @@ androidComponents {
".readme",
))
// The fixed Locale.US is intended
if (variant.name.lowercase(Locale.US).contains("release")) {
variant.packaging.resources.excludes.addAll(listOf(
"**/*.kotlin_metadata",

View File

@ -33,7 +33,7 @@ class PercentDecimalExtTest {
runTest {
val parsed = PercentDecimal(1f).toPercentageWithDecimal()
assertEquals("100${MonetarySeparators.current(Locale.US).decimal}00", parsed)
assertEquals("100${MonetarySeparators.current(Locale.getDefault()).decimal}00", parsed)
}
@Test

View File

@ -16,9 +16,7 @@ fun PercentDecimal.toPercentageWithDecimal(decimalFormat: DecimalFormat = prepar
private fun preparePercentDecimalFormat(): DecimalFormat =
DecimalFormat().apply {
// TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
val monetarySeparators = MonetarySeparators.current(Locale.US)
val monetarySeparators = MonetarySeparators.current(Locale.getDefault())
val localizedPattern = "##0${monetarySeparators.decimal}00"
runCatching {
applyLocalizedPattern(localizedPattern)

View File

@ -375,8 +375,8 @@ private fun splitBalance(
): Pair<String, String> {
Twig.debug { "Balance before split: $balance, prefix: $prefix" }
@Suppress("MAGIC_CONSTANT", "MagicNumber")
val cutPosition = balance.indexOf(MonetarySeparators.current(Locale.US).decimal) + 4
@Suppress("MagicNumber")
val cutPosition = balance.indexOf(MonetarySeparators.current(Locale.getDefault()).decimal) + 4
val firstPart =
(prefix ?: "") +
balance.substring(

View File

@ -79,9 +79,7 @@ class SendViewTestSetup(
fun DefaultContent() {
val context = LocalContext.current
// TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
val monetarySeparators = MonetarySeparators.current(Locale.US)
val monetarySeparators = MonetarySeparators.current(Locale.getDefault())
val (sendStage, setSendStage) =
rememberSaveable(stateSaver = SendStage.Saver) { mutableStateOf(initialState) }

View File

@ -51,9 +51,7 @@ class SendViewIntegrationTest {
)
)
// TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
private val monetarySeparators = MonetarySeparators.current(Locale.US)
private val monetarySeparators = MonetarySeparators.current(Locale.getDefault())
// TODO [#1260]: Cover Send screens UI with tests
// TODO [#1260]: https://github.com/Electric-Coin-Company/zashi-android/issues/1260

View File

@ -98,12 +98,10 @@ private fun ComposableHistoryListPreview() {
}
}
// TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
private val dateFormat: DateFormat by lazy {
SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss",
Locale.US
Locale.getDefault()
)
}

View File

@ -39,9 +39,7 @@ data class WalletDisplayValues(
walletSnapshot.spendableBalance().toFiatCurrencyState(
null,
Locale.current.toKotlinLocale(),
// TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
MonetarySeparators.current(java.util.Locale.US)
MonetarySeparators.current(java.util.Locale.getDefault())
)
var fiatCurrencyAmountText = getFiatCurrencyRateValue(context, fiatCurrencyAmountState)

View File

@ -30,7 +30,7 @@ internal sealed class ParseResult {
completeWordList: Set<String>,
rawInput: String
): ParseResult {
// Note: This assumes the word list is English words
// Note: This assumes the word list is English words, thus the Locale.US is intended.
val trimmed = rawInput.lowercase(Locale.US).trim()
if (trimmed.isBlank()) {

View File

@ -23,7 +23,7 @@ data class TimeInfo(
fun toSupportString() =
buildString {
// Use a slightly more human friendly format instead of ISO, since this will appear in the emails that
// users see
// users see. The fixed Locale.US is intended.
val dateFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss a", Locale.US) // $NON-NLS-1$
appendLine("Current time: ${dateFormat.formatInstant(currentTime)}")