-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: warn user of stale exchange rates #1284
Conversation
class ExchangeRatesConfig | ||
@Inject | ||
constructor( | ||
context: Context, | ||
walletDataProvider: WalletDataProvider | ||
) : BaseConfig( | ||
context, | ||
PREFERENCES_NAME, | ||
walletDataProvider | ||
) { | ||
companion object { | ||
private const val PREFERENCES_NAME = "exchange_rates_config" | ||
val EXCHANGE_RATES_RETRIEVAL_TIME = longPreferencesKey("exchange_rates_retrieval_time") | ||
val EXCHANGE_RATES_RETRIEVAL_FAILURE = booleanPreferencesKey("exchange_rates_retrieval_error") | ||
val EXCHANGE_RATES_PREVIOUS_RETRIEVAL_TIME = longPreferencesKey("exchange_rates_previous_retrieval_time") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I was going to put these in WalletUIConfig, but that would have created a circular reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WalletUIConfig
might be better to leave for UI settings that can be changed by the user, or closely related preferences.
constructor(currencyCode: String, rate: String?, retrievalTime: Long) { | ||
this.currencyCode = currencyCode | ||
this.rate = rate | ||
this.retrievalTime = retrievalTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CTX does return a field that contains the time their servers last retrieved this particular rate.
It is possible for CTX to return rates, but they are stale.
currencyName = | ||
if (currencyCode.length == 3) { | ||
try { | ||
getCurrency().displayName | ||
} catch (x: IllegalArgumentException) { | ||
currencyCode | ||
} | ||
} else { | ||
currencyCode | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I am sure that the ktlint plugin on automatically formatted this file upon save. I have turned off this feature.
object MyTheme { | ||
val ToastBackground = Color(0xff191c1f).copy(alpha = 0.9f) | ||
|
||
val Body2Regular = TextStyle( | ||
fontSize = 14.sp, | ||
lineHeight = 20.sp, | ||
fontFamily = FontFamily.Default, // FontFamily(Font(R.font.inter)) // crashes, | ||
fontWeight = FontWeight(400), | ||
color = Color.White | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a start for a "stylesheet" file. There probably is a better way to do this, perhaps a standard way that it is done with Compose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually in JC you would set a MaterialTheme with a typography
field, however, the names of standard text styles aren't going to match with our typography sheet in Figma, so it's better to have named styles as you did here.
previousRates.clear() | ||
previousRates.addAll(exchangeRatesDao.getAll()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we save the previous rates in memory to compare with the new rates.
val storageManagerIntent = | ||
Intent( | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
StorageManager.ACTION_MANAGE_STORAGE | ||
} else { | ||
Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to get the ktlint
plugin for Android Studio to use our rules in this project?
This was another case where I was using the new ktlint plugin to reformat a file on save, which would actually change a lot in wallet
and in other modules may apply rules that we don't use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you set .editorconfig
as the baseline file in ktlint plugin settings, it should pickup our rules.
I removed ktlint plugin from the studio because after some update it broke and started to complain about everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Issue being fixed or feature implemented
Related PR's and Dependencies
Screenshots / Videos
How Has This Been Tested?
Checklist: