or-dvir / EasySettings

A library for easily creating and adding settings (AKA preferences) to your android app
Apache License 2.0
95 stars 18 forks source link

Linked settings #11

Open Koxx3 opened 4 years ago

Koxx3 commented 4 years ago

Hello, first, thanks for this library. It makes settings management much easier ! I'd like to link settings. For example :

I'd liked to gray/disable setting2 if setting1 is not enabled.

How can I do that ? I found nothing in the example or the documentation.

Thanks

or-dvir commented 4 years ago

you mean in the ui, like in this picture? (couldn't directly post it for some reason). so when the user enables "data roaming", "preferred network type" also becomes enabled?

if thats the case, unfortunately you'll have to do this yourself. This library is about storing and accessing values (settings) saved in SharedPreferences. it is not possible in android to enable/disable a value saved in SharedPreferences. the idea is for you, the developer, to have your app act differently depending on the value saved in one (or more) such preferences.

so for example you could do something like this for the example above (very simplified pseudo code):

//this code should probably be in the `settings` activity/fragment
View networkType = findViewById(R.id.preferredNetworkType)
networkType.setEnabled(getValue(dataRoaming))

if that is not what you meant, please clarify (i'll leave this issue open).

Koxx3 commented 4 years ago

hello, thanks for your reply. yes, this is exactly what i meant 😅 i'll try to do it myself then 😁

Koxx3 commented 4 years ago

how can i find the view id since they are created by easysettings ?

or-dvir commented 4 years ago

the view is the one in your activity/fragment you want to disable. so if we go with the same image as before, it would be the 2 TextViews

image