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

Define summaries depending on current value #24

Closed
markusressel opened this issue Jan 9, 2018 · 4 comments
Closed

Define summaries depending on current value #24

markusressel opened this issue Jan 9, 2018 · 4 comments
Assignees
Labels

Comments

@markusressel
Copy link

Hi there,

I really like your work so far. There is something about the material design specs that I don't know how to implement with this library:

image

I would love to see this implemented in the library if it hasn't already as imo the current implementation does not math the specification.

To implement this myself I currently need to do a lot of boilerplate code in the activity that changes the description based on preference value changes. It would be great if there was a way to specify what summaries should be shown for the different Preference types f.ex. using a string with placeholders or something similar that is filled by this library without having to do any boilerplate on the activity side.

@markusressel
Copy link
Author

Here is another example of the design spec:

image

Source: https://material.io/guidelines/patterns/settings.html#settings-labels-secondary-text

@michael-rapp michael-rapp self-assigned this Jan 10, 2018
@michael-rapp
Copy link
Owner

michael-rapp commented Jan 10, 2018

I am glad that you like the library. It is correct that the library does not provide the functionality you are describing. This is because the library does only provide an activity where preferences can be placed in (the standard preferences as provided by the Android SDK or those provided by 3rd party libraries), but does not add additional functionality to them besides adjusting their appearance (a little bit). Therefore the feature you are requesting is out of scope of this library.

I usually use this library together with another library of mine. It is called AndroidMaterialPreferences. Said library allows to display the current value of a preference as its summary by specifying the XML attribute custom:showValueAsSummary="true". However this causes the value of the preference to be shown as it is, e.g. if there is a ListPreference with the values "5 minutes", "10 minutes" and "20 minutes" one of these strings is shown exactly as it is. For example, it is not possible to display "After 10 minutes of inactivity". If you think that it would be useful to be able to use placeholder texts such as "After %s of inactivity" as summaries, please open a feature request for the library "AndroidMaterialPreferences". I am willing to add such feature. However, if you want to display more complex summaries that are not directly related to the current value, even with such feature provided, it will still be necessary to write "boilerplate" code to achieve this.

@michael-rapp
Copy link
Owner

michael-rapp commented Jan 10, 2018

By the way: Even with the Android SDK's standard CheckBoxPreference and SwitchPreference the XML attributes android:summaryOn and android:summaryOff can be used to specify texts that should be shown depending on whether the preference is checked or not. You don't need a third party library for this. Only if you want to do display the values of other preferences as their summary, you need an additional library.

https://developer.android.com/reference/android/preference/CheckBoxPreference.html
https://developer.android.com/reference/android/preference/SwitchPreference.html

@markusressel
Copy link
Author

Thanks for the explanation.

I wanted to check out your other library anyway so thats good. I will do that create a new issue there if it makes sense to do so.

I did know about the checkbox preferences' "on" and "off" attributes, they just are not sufficient for other preference types (as you know too).

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

No branches or pull requests

2 participants