Skip to content
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

[android] Configuration Settings refactor #572

Open
gubatron opened this issue Aug 26, 2017 · 3 comments
Open

[android] Configuration Settings refactor #572

gubatron opened this issue Aug 26, 2017 · 3 comments

Comments

@gubatron
Copy link
Collaborator

gubatron commented Aug 26, 2017

Currently adding a new configuration setting is very tedious, it should be as simple as creating an object, similar to the way it works on desktop, in a single place, something like:

public static final ConfigurationSetting GUI_TOS_ACCEPTED = 
new ConfigurationSetting(
    Boolean.class, // class of the value
    "frostwire.prefs.gui.tos_accepted", // key
    false); // default value

public static final ConfigurationSetting GUI_INTERSTITIAL_ON_EXIT_THRESHOLD =
new ConfigurationSetting(
    Float.class,
    "frostwire.prefs.gui.interstitial_on_exit_threshold",
    0.35f);

...

// Then you use those like

ConfigurationSetting.GUI_TOS_ACCEPTED.value(); // gets the value
ConfigurationSetting.GUI_TOS_ACCEPTED.set(true); // updates the setting value
ConfigurationSetting.GUI_TOS_ACCEPTED.reset(); // resets to default value

and the whole thing gets taken care of, with backwards compatibility in one spot.

CC: @votaguz in case you want to do something different this weekend (and you have the time), this would be a useful refactor and a good study case to truly learn Java Generics.

To work on this ticket read:
Constants.java
ConfigurationManager.java
ConfigurationDefaults.java

@gubatron
Copy link
Collaborator Author

I think I'll do this one in Kotlin

@votaguz
Copy link
Collaborator

votaguz commented Feb 20, 2018

@gubatron are you still thinking on doing this using Kotlin or you want to stick with Java ?

@aldenml
Copy link
Collaborator

aldenml commented Feb 20, 2018

hi @votaguz, kotlin was removed because time passed and no real need was clear. Less code in the final apk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants