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

Large default values not working #63

Closed tvaknin closed 5 months ago

tvaknin commented 5 months ago

Setting android:defaultValue="#ff002ee3"

will result in "ff002ee":

val routeColor = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getInt("trail_recording_color", MapColors.TRAIL_RECORDING_DEFAULT.color)

The above won't work only if you click the "Default" button.

martin-stone commented 5 months ago

I don't see this -- It works as expected for me. I'll need more repro steps. (Or a pull request with a fix.)

martin-stone commented 5 months ago

The above won't work only if you click the "Default" button.

I think this means that it'll be reading your MapColors.TRAIL_RECORDING_DEFAULT.color value. Is that set correctly?

tvaknin commented 5 months ago

Hi,

TRAIL_RECORDING_DEFAULT.color is ff002ee3 and not used in case of clicking the "default" button.

This is how I configured the ColorPreference

    <com.rarepebble.colorpicker.ColorPreference
        android:defaultValue="#ff9933ff"
        android:key="trail_recording_color"
        android:summary="@string/select_record_color"
        android:title="@string/trail_color_recording"
        app:colorpicker_selectNoneButtonText="Default"
        />

then, when you click the "Default" it should take ff9933ff but

val routeColor = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getInt("trail_recording_color", MapColors.TRAIL_RECORDING_DEFAULT.color)

return ff002ee instead.

martin-stone commented 5 months ago

I don't see this issue when trying this. If you could fork the repo and get the demo app to exhibit this, then I'll take another look.

tvaknin commented 5 months ago

My apologies for the confusion. It was a problem with how I set it up.