AnderWeb / discreteSeekBar

Apache License 2.0
2.11k stars 400 forks source link

Added option for stepped values and ability to set track color programmatically #27

Open jamie94bc opened 9 years ago

AnderWeb commented 9 years ago

Originally, the mKeyProgressIncrement var was only used for keyboard tracking, and it's modified here. So if you set a manual step of 2 and then initiate a keyboard tracking event, the mStep var will be modified and we'll loose the specified value.

I think the proper way of doing this would need two separate variables for keyboard tracking (that the lib may need to modify for speed) and the touch tracking step.

jamie94bc commented 9 years ago

Ah yes, you're right with the keyboard increment.

jamie94bc commented 9 years ago

How's this? :smile:

AnderWeb commented 9 years ago

Also, for the programmatic color modification, we should use the same approach than the other methods. Also we should add set***Color methods receiving a ColorStateList too, just in case.

It would be better to remove the color commit from this original PR and open a different issue.

jamie94bc commented 9 years ago

The setTrackColor method uses the same approach as the existing setScrubberColor method?

AnderWeb commented 9 years ago

Oh, yes, didn't see that. We should add @AOrobator to that issue too, as he made the previous changes.

Ok, just leave the setTrackColor commit there and I'll add a new Issue to improve them.

AOrobator commented 9 years ago

@jamie94bc Can't you already set the track color programmatically? I made that change and am currently using it in an app I'm working on.

See DiscreteSeekBar.setScrubberColor(int), it has the same behavior. I think setTrackColor is a better name for it though, as it's a lot clearer with regards to what the function does. Maybe we deprecate setScrubberColor?

@AnderWeb What do you mean by same approach? What's the standard you want to set for changing a color?

jamie94bc commented 9 years ago

@AOrobator no, the scrubber color is the "filled" part of the track, dependent on the current value.

scrubber

AnderWeb commented 9 years ago

Currently, all the drawables inherit from org.adw.library.widgets.discreteseekbar.internal.drawable.StateDrawable. This drawable uses a ColorStateList for the coloring (so devs can use different colors for pressed/focused/disabled/whatever). I was thinking on providing two setters for each component:

-setXXXColor(ColorStateList colorStateList)

This one would just set the ColorStateList to the drawable.

-setXXXColor(int color)

This one would work setting the drawable ColorStateList with ColorStateList.valueOf(color)

So no ColorFilters would be needed.