Open anggrayudi opened 8 years ago
Don't know what decision @consp1racy will take, but for now you can do that setting a value via setSummary()
, at least for SeekBarPreference.
Not the same result but very similar
Hello @anggrayudi ,
app:asp_min
is a good idea, I'll do that for both seek bar preferences.
The unit thing... I think it would be better as app:asp_info
similar to Notification.contentInfo
. It would handle an arbitrary text and you could hook a seek bar listener to the preference and put value + " ms"
to it on change. It makes sense for SeekBarPreference
. For SeekBarDialogPreference
just use setSummary
. It shouldn't be a problem design-wise since you'll probably be using just one type of seek bar preference.
android:dialogMessage
is used, well, for dialog message, unfortunately it's ignored in SeekBarDialogPreference
because we're using a custom layout. But it's possible to add it. I'm going to put it above the seek bar, similar to EditTextPreference
.
@JoseGD I'd use setSummary
just for SeekBarDialogPreference
. setSummary
in SeekBarPreference
is used for the greyed title instead of regular setTitle
- at least in the sample.
Thank you both for ideas, this is totally doable.
Everything discussed above should be implemented in latest commit. If you pull the sample app you can test it if it fits your needs. Changes include:
I'm going to try to figure out if the "info" text view could be included in SeekBarDialogPreference
as well. If you find any issues let me know. I'd like to release next version within a week.
@consp1racy, I think the best design for SeekBarDialogPreference
is look like this:
The dialog must use Material Dialogs specifications as explained by Google.
The original was taken straight from AOSP 5.0 so you can't get more Material than that since MD specs are silent about seek bars. In the next version the android:dialogMessage
attribute will be honored and the SeekBarDialogPreference
dialog will look like this:
SeekBarPreference
just like SeekBarDialogPreference
will understand app:asp_min
attribute and in combination with app:asp_info
attribute could produce following results:
If you need anything special on top of what SeekBarDialogPreference
offers feel free to subclass XpSeekBarPreferenceDialogFragment
and tailor it to your own needs. You can open your new dialog fragment instead by implementing PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback
in your activity like so:
@Override
public boolean onPreferenceDisplayDialog(PreferenceFragmentCompat preferenceFragmentCompat, Preference preference) {
final String key = preference.getKey();
DialogFragment f;
if (preference instanceof SeekBarDialogPreference) {
f = MySeekBarPreferenceDialogFragment.newInstance(key);
} else {
return false;
}
f.setTargetFragment(preferenceFragmentCompat, 0);
f.show(this.getSupportFragmentManager(), key);
return true;
}
@consp1racy, that's a pretty dialog. But, where's the asp_info
and the current value for the SeekBar
? Just like SeekBarPreference
, you had better to put them on the dialog to make users know the current SeekBar
's value or position.
@anggrayudi Damn right it's a pretty dialog, that was the goal. :D
Connecting OnSeekBarChangeListener
to potential SeekBarDialogPreference.setInfo(...)
has proven to be difficult since the preference object has no link to its dialog.
Two options come to mind:
1) Subclass XpSeekBarPreferenceDialog
and setup everything inside it just as you want - mentioned in my previous comment.
2) Make a subscreen where you can use a Preference
with a title and summary do describe the screen and then as many SeekBarPreference
s as you want with subtitle and info.
Looks like seek bar preferences will have to have a asp_unit
attribute. Otherwise TalkBack will report "0-100%" when working with seek bars.
@consp1racy, when you will release the next version of this library with some fixes? I hope you can release it ASAP. Thanks
@anggrayudi What's "some fixes", please, be specific. The library is stable as I see it now.
I currently have no clear direction how to alter SeekBarDialogPreference
and SeekBarPreference
works as intended.
If you need anything else feel free to make your own preference classes. My package should be extensible enough.
@consp1racy, I mean, fixes for SeekBarDialogPreference
and SeekBarPreference
.
I don't want to repeat myself, but
@anggrayudi What's "some fixes", please, be specific.
They're working as intended as far as I can see. If you need anything else I gave you suggestions for alternative solutions and
If you need anything else feel free to make your own preference classes. My package should be extensible enough.
What more do you want?
I will not be implementing https://github.com/consp1racy/android-support-preference/issues/27#issuecomment-211017526. It looks very specialized and you can do it yourself in your app.
Potential TODOs on SeekBarDialogPreference
are these:
setInfo
on dialog fragment
Hi @consp1racy, I want to introduce you a new attribute for
SeekBarPreference
. I have edited below picture from your screenshot. Look at the preferences. Each of them had a unit. For Media preference, the unit is%
(percent), and for Vibration the unit isms
(milliseconds) which means the device will be vibrated for 200ms. I hope you can add this feature by adding the following attribute to the preference:Also, once user seek the bar, the value will be updated automatically.
I have the second request for you, i.e. by adding
app:asp_dialogContent="Some explanation."
attribute toSeekBarDialogPreference
. Adding this attribute makes a big difference betweenSeekBarPreference
andSeekBarDialogPreference
. Let's say that you have aSeekBarDialogPreference
without any explanation about it. If that's so, why don't you just useSeekBarPreference
which already had no explanation but a title? You can see the edited screenshot below:And the last request is, I want you to add
setMin(int min)
method andapp:asp_min
to this preference. We can define the minimum value for theSeekBar
. For example:The
SeekBar
had range value between 20 to 500 with unit in milliseconds.Thanks in advance. I hope you accept this idea.