Repository navigation
fix: stuck currency code & cleanup obsolete currencies - #1187
Conversation
| val sharedPreferences = context.getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE) | ||
| val currentValue = sharedPreferences.getString(WalletUIConfig.SELECTED_CURRENCY.name, null) | ||
| currentValue?.let { | ||
| val fixedValue = CurrencyInfo.getUpdatedCurrency(CurrencyInfo.getOtherName(currentValue)) | ||
| sharedPreferences.edit().putString(WalletUIConfig.SELECTED_CURRENCY.name, fixedValue).apply() | ||
| } | ||
| // The database might have obsolete currencies as well | ||
| exchangeRates.cleanupObsoleteCurrencies() |
There was a problem hiding this comment.
This will run once on migration and ensure we never have obsolete currency names in the datastore.
This way, we don't have to call getOtherName or getUpdatedCurrency every time.
| fun setCurrentCurrencySymbolWithCode(currencyCode: String): String? { | ||
| var currentLocale = Locale("", "") | ||
| var currentCurrencySymbol: String? = "" | ||
| when (currencyCode.lowercase()) { |
There was a problem hiding this comment.
Was this method unnecessary or handled by standard android functions?
There was a problem hiding this comment.
This was only used in the old EnterAmountFragment to figure out where the Dash symbol should go; we use isCurrencyFirst for it now which makes use of Androids NumberFormat.
HashEngineering
left a comment
There was a problem hiding this comment.
Looks great. Before merging, I want final confirmation from the CTX team about their server status.
| val tradesRequest = TradesRequest( | ||
| valueToConvert.toFormattedStringNoCode(), | ||
| userPreference.exchangeCurrencyCode!!, | ||
| walletUIConfig.get(WalletUIConfig.SELECTED_CURRENCY) ?: Constants.USD_CURRENCY, |
There was a problem hiding this comment.
Should this be DEFAULT_EXCHANGE_CURRENCY ?
When the user opens Receive screen, the currency code is set, and changing it from the settings won't have an effect until relaunch.
Additionally, we need to filter out obsolete currencies and not save them in the database.
Issue being fixed or feature implemented
Configurationto theWalletUIConfigdatastore.Related PR's and Dependencies
Screenshots / Videos
How Has This Been Tested?
Checklist: