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

defaultValue does not work anymore on older devices #47

Closed engilyin closed 5 years ago

engilyin commented 6 years ago

I had to update com.rarepebble:colorpicker:2.3.1 to the latest com.rarepebble:colorpicker:2.4.0 due to the bug with Canvas.save().

After update I found older devices did not show the default color anymore. If I pick a new color it get worked well.

Looking into the source and debug it I think the problem is the fix which changes how the defaults are read: "Corrected onGetDefaultValue / onSetInitialValue."

In my xml I have such entry:

<com.rarepebble.colorpicker.ColorPreference
            android:defaultValue="@color/learningLanguage"
            android:key="simple_mode_learning_lang_background"
            android:title="@string/pref_colors_simple_mode_learning_lang_background" />

in colors.xml: <color name="learningLanguage">#ece7c9</color> how pref UI is inited:

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static class ColorsPreferenceFragment extends PreferenceFragment {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.xml.pref_colors);
            setHasOptionsMenu(true);

        }

Should I change my code somehow to make it read the default color or it is the bug and I have to wait for a new version?

P.S. thank you very much for this great library!

engilyin commented 6 years ago

WORKAROUND: if I put color value directly it solves the issue: android:defaultValue="#ece7c9"

martin-stone commented 6 years ago

Thanks for the bug report. I've managed to reproduce it. Looking into it.

engilyin commented 6 years ago

Thank you very much!

martin-stone commented 5 years ago

Fixed in release 2.4.1.