Add currency converter symbol aliases (i.e. € for EUR)

This commit is contained in:
MM20
2024-05-18 13:01:37 +02:00
parent 8054f6e5c4
commit 32276934bb
2 changed files with 102 additions and 6 deletions
@@ -59,7 +59,10 @@ class CurrencyConverter(
override suspend fun convert(context: Context, fromUnit: String, value: Double, toUnit: String?): UnitConverter {
val values = repository.convertCurrency(fromUnit, value, toUnit).map {
val fromIsoCode = repository.resolveAlias(fromUnit)
val toIsoCode = toUnit?.let { repository.resolveAlias(it) }
val values = repository.convertCurrency(fromIsoCode, value, toIsoCode).map {
UnitValue(it.second, it.first, formatName(it.first, it.second), formatValue(it.first, it.second))
}.toMutableList()
@@ -82,8 +85,8 @@ class CurrencyConverter(
values.add(0, ownCurrency)
}
val inputValue = UnitValue(value, fromUnit, formatName(fromUnit, value), formatValue(fromUnit, value))
val lastUpdate = repository.getLastUpdate(fromUnit)
val inputValue = UnitValue(value, fromIsoCode, formatName(fromIsoCode, value), formatValue(fromIsoCode, value))
val lastUpdate = repository.getLastUpdate(fromIsoCode)
return CurrencyUnitConverter(dimension, inputValue, values, lastUpdate)
}
}