skydoves / ColorPickerPreference

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

How to clear or delete saved preference? #1

Closed ashishkumart closed 6 years ago

ashishkumart commented 6 years ago

How can I clear the saved preference as I need to clear it after log out and need to set default colour for new user.

skydoves commented 6 years ago

It's not exist of clear methods. but you can set default color like this:

ColorPickerSharedPreferencesManager preferencesManager = new ColorPickerSharedPreferencesManager(mContext);
preferencesManager.putInteger("YOUR_COLORPICKER_NAME" + ColorPickerSharedPreferencesManager.COLOR, Color.WHITE);

and just call

colorPickerView.selectCenter();
ashishkumart commented 6 years ago

Thank you for replying :). If I can't clear preference then it's creation is useless. Can you tell me how to set a colour to ColorPickerView? I will manage it by app's preference if I could set a colour to it. Its setting white colour as default. I need to setup custom colour.

Please suggest.

skydoves commented 6 years ago

I think it seems to need clear saved preferences and set a color to ColorPickerView methods. I will add it soon. :) Thank you for your Issue!

skydoves commented 6 years ago

it released at v1.0.3! You can set saved color manually and clear all of saved data using the following methods. But you must invoke setPreferenceName method before using them.

set saved color manually

colorPickerView.setSavedColor(YOUR_COLOR);

clear all of preferences

colorPickerView.clearSavedData();
ashishkumart commented 6 years ago

Many thanks @skydoves. I just want to confirm would this method (colorPickerView.setSavedColor(YOUR_COLOR);) put the pointer to the colour location on the picker?

skydoves commented 6 years ago

not yet. I think it seems to need an algorithm like finding the color position from an image. for example the following image,

palettebar

what is the best position for red color? or how to handle if not founded red color from an image?

So I'm thinking what is the best algorithm for choosing a color from images.