Open justinmuller opened 10 years ago
I must admit I did not predict a multi-language support, but what you claim sure presents a valid suggestion (in case we would want to change language in-app and on fly).
give-me-coinsMonitoringApp/src/give_me_coins/dashboard/GMCPoolService.java
Defining the keys of
SharedPreferences
in string resource files, such as this is problematic for a couple of reasons:1) A string value may be updated in
strings.xml
to change the text on the UI, inadvertently breaking the retrieval of previously specified preferences. For example, if the text "Show LTC" were changed to "Update LTC" then the previously specified preference would not be loaded because the call here would resolve tosharedPref.getBoolean("Update LTC")
instead ofsharedPref.getBoolean("Show LTC")
2) This pattern does not aid multi-language support. For example, if a French user (with their device locale set to fr) begins using the app today, their LTC preference is set via
editor.putBoolean("Show LTC", boolean)
. If we later include French translations (someone contributesres/values-fr/strings.xml
) and push out an update, the updated code will attempt to retrieve that preference viasharedPref.getBoolean("Afficher LTC")
. Thus, after an update it might looks like the preferences where lost to a user with a non-English locale.One possible solutions is to hardcode the keys in the code (or introduce constants)