skydoves / ColorPickerPreference

🎨 A library that lets you implement ColorPicker, ColorPickerDialog, ColorPickerPreference.
Apache License 2.0
480 stars 51 forks source link

app:default_color not working as expected #17

Closed tobiaswicker closed 4 years ago

tobiaswicker commented 5 years ago

Bug: Neither the picker nor any of the sliders reflect the app:default_color set in xml.

Example preference.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <PreferenceCategory
        app:title="@string/overlay_category_title"
        app:iconSpaceReserved="false">

        <com.skydoves.colorpickerpreference.ColorPickerPreference
            app:key="color_background"
            app:title="@string/color_background"
            app:preference_dialog_title="@string/color_background"
            app:preference_dialog_positive="@string/confirm"
            app:preference_dialog_negative="@string/cancel"
            app:preference_palette="@drawable/palette"
            app:preference_selector="@drawable/wheel"
            app:default_color="@color/default_overlay_background"
            app:actionMode="always"
            app:preferenceName="color_background"
            app:iconSpaceReserved="false" />

    </PreferenceCategory>

</androidx.preference.PreferenceScreen>

Value of @color/default_overlay_background is #4CAF50.

Expected Behavior:

The hue picker as well as the alpha and brightness sliders should take into account the default_color if there is no preference available for the SharedPreferences key.

skydoves commented 4 years ago

Released in the new version 2.0.4.