martin-stone / hsv-alpha-color-picker-android

A color picker and a color preference for use in Android applications.
Apache License 2.0
290 stars 60 forks source link

Extension for showAlpha(false) #12

Closed MFlisar closed 8 years ago

MFlisar commented 8 years ago

It would be nice to add a function like showHexAlpha(boolean) as well to allow/disallow alpha values in the hex field as well. I would like to hide the alpha bar AND disallow alpha values in the hex field as well...

martin-stone commented 8 years ago

Good idea. Do you think it should show eight digits and enforce the first "ff" or just show six digits? (Eight digits with enforced "ff" could make the color more reliably copy-pastable between apps.)

Maybe if showAlpha(false), the hex field should just do this anyway, without an extra setting.

MFlisar commented 8 years ago

Probably this should be the default behaviour when showAlpha(false) but for backwards compatibilty maybe not? That's up to you, but from my point of view (not regarding backwards compatibility) it should be like that by default

I personally would say, that the field should only show 6 digits. If you copy the field, you only copy 6 digits. When pasting, you may first check if the color is valid and afterwards remove the alphe value from it so that it's possible to paste 6 digit colors as well as 8 digit colors (and maybe even 3 digit colors?). Simple parsing the color and check if it's a valid color, and afterwards just remove the alpha (like following: String.format("#%06X", 0xFFFFFF & color)), that would be my suggestion

martin-stone commented 8 years ago

Fixed in version 1.5.0. You simply get six digits when showAlpha(false). If you paste an eight digit color it will ignore the alpha digits. I've not bothered with three digit colors.