|
|
|
@ -27,7 +27,8 @@ class Preferences { |
|
|
|
ACTIVE_FILTER_ID("ActiveFilterId"), |
|
|
|
ACTIVE_FILTER_ID("ActiveFilterId"), |
|
|
|
LATEST_PURCHASE("latestPurchase"), |
|
|
|
LATEST_PURCHASE("latestPurchase"), |
|
|
|
PATCH_BREAK("patchBreaks"), |
|
|
|
PATCH_BREAK("patchBreaks"), |
|
|
|
PATCH_TRANSACTION_TYPES_NAMES("patchTransactionTypesNames") |
|
|
|
PATCH_TRANSACTION_TYPES_NAMES("patchTransactionTypesNames"), |
|
|
|
|
|
|
|
PATCH_BLINDS_FORMAT("patchBlindFormat") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
@ -84,14 +85,10 @@ class Preferences { |
|
|
|
return getString(Keys.CURRENCY_CODE, context) |
|
|
|
return getString(Keys.CURRENCY_CODE, context) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getCurrencyLocale(context : Context) : Locale? { |
|
|
|
fun getCurrencyLocale(context : Context) : Locale? { |
|
|
|
getCurrencyCode(context)?.let { currencyCode -> |
|
|
|
getCurrencyCode(context)?.let { currencyCode -> |
|
|
|
Locale.getAvailableLocales().filter { |
|
|
|
UserDefaults.availableCurrencyLocales.filter { |
|
|
|
try { |
|
|
|
Currency.getInstance(it).currencyCode == currencyCode |
|
|
|
Currency.getInstance(it).currencyCode == currencyCode |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.firstOrNull()?.let { |
|
|
|
}.firstOrNull()?.let { |
|
|
|
return it |
|
|
|
return it |
|
|
|
} |
|
|
|
} |
|
|
|
@ -137,6 +134,15 @@ class UserDefaults private constructor(context: Context) { |
|
|
|
currency = Preferences.getDefaultCurrency(context) ?: getLocaleCurrency() |
|
|
|
currency = Preferences.getDefaultCurrency(context) ?: getLocaleCurrency() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val availableCurrencyLocales = Locale.getAvailableLocales().mapNotNull { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Currency.getInstance(it) |
|
|
|
|
|
|
|
it |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the locale currency, or en_US if there |
|
|
|
* Return the locale currency, or en_US if there |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|