Use all system locales to determine default currencies

This commit is contained in:
MM20
2026-08-11 21:47:44 +02:00
parent c255894f3b
commit 057de087e9
2 changed files with 28 additions and 11 deletions

View File

@@ -90,7 +90,20 @@ class CurrencyConverter(
}.toMutableList()
val ownCurrencySymbols = preferredCurrencies.ifEmpty {
listOf(JCurrency.getInstance(Locale.getDefault()).currencyCode ?: "USD")
val defaultCurrencySymbols = mutableListOf<String>()
val localeList = context.resources.configuration.locales
for (i in 0 until localeList.size()) {
val locale = localeList[i]
val currency = try {
JCurrency.getInstance(locale)
} catch (_: IllegalArgumentException) {
null
}
if (currency != null) {
defaultCurrencySymbols.add(currency.currencyCode)
}
}
defaultCurrencySymbols.distinct()
}
val topCurrencies = ownCurrencySymbols + topCurrencies