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

Request: SeekBarDialogPreference.setInfo(...) + realtime listener support #27

Open
anggrayudi opened this issue Apr 14, 2016 · 12 comments

Comments

@anggrayudi
Copy link

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 is ms (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:

<SeekBarPreference
    android:key="vibrate_duration"
    app:asp_preferenceUnit="ms"
    ... />

Also, once user seek the bar, the value will be updated automatically.

unit pref


I have the second request for you, i.e. by adding app:asp_dialogContent="Some explanation." attribute to SeekBarDialogPreference. Adding this attribute makes a big difference between SeekBarPreference and SeekBarDialogPreference. Let's say that you have a SeekBarDialogPreference without any explanation about it. If that's so, why don't you just use SeekBarPreference which already had no explanation but a title? You can see the edited screenshot below:

<SeekBarDialogPreference
    android:key="custom_volume"
    app:asp_dialogContent="This is an explanation."
    ... />

dialog explanation pref

And the last request is, I want you to add setMin(int min) method and app:asp_min to this preference. We can define the minimum value for the SeekBar. For example:

<SeekBarPreference
    android:max="500"
    app:asp_min="20"
    app:asp_preferenceUnit="ms"
    ... />

The SeekBar had range value between 20 to 500 with unit in milliseconds.


Thanks in advance. I hope you accept this idea.

@JoseGD
Copy link

JoseGD commented Apr 14, 2016

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

@consp1racy
Copy link
Owner

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.

@consp1racy
Copy link
Owner

consp1racy commented Apr 15, 2016

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:

  • SeekBar*Preference support app:asp_min attribute
  • Better aligned CheckBox and Switch widgets to 16dp right keyline
  • Using native Switch on API >= 21: supports animation on toggle, may change back any time!
  • Better aligned SeekBar in SeekBar*Preference
  • SeekBarPreference supports app:asp_info attribute for arbitrary short text info such as numeric value
  • SeekBarDialogPreference dialog never has title icon
  • SeekBarDialogPreference dialog supports android:dialogMessage

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.

@anggrayudi
Copy link
Author

anggrayudi commented Apr 17, 2016

@consp1racy, I think the best design for SeekBarDialogPreference is look like this:

seekbardialogpreference

The dialog must use Material Dialogs specifications as explained by Google.

@consp1racy
Copy link
Owner

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:

image

SeekBarPreference just like SeekBarDialogPreference will understand app:asp_min attribute and in combination with app:asp_info attribute could produce following results:

image image

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;
}

@anggrayudi
Copy link
Author

anggrayudi commented Apr 17, 2016

@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.

@consp1racy
Copy link
Owner

@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 SeekBarPreferences as you want with subtitle and info.

@consp1racy
Copy link
Owner

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 consp1racy reopened this Apr 18, 2016
@anggrayudi
Copy link
Author

@consp1racy, when you will release the next version of this library with some fixes? I hope you can release it ASAP. Thanks

@consp1racy
Copy link
Owner

@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.

@anggrayudi
Copy link
Author

@consp1racy, I mean, fixes for SeekBarDialogPreference and SeekBarPreference.

@consp1racy
Copy link
Owner

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 #27 (comment). It looks very specialized and you can do it yourself in your app.

Potential TODOs on SeekBarDialogPreference are these:

  • Report precise value via TalkBack; possibly via setInfo on dialog fragment

@consp1racy consp1racy changed the title Request: New attribute to SeekBarPreference Request: SeekBarDialogPreference.setInfo(...) + realtime listener support Dec 14, 2016
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