Giter Club home page Giter Club logo

hsv-alpha-color-picker-android's People

Contributors

julianeggers avatar martin-stone avatar mflisar avatar ravidsrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hsv-alpha-color-picker-android's Issues

Question: Use of Enter key to confirm HEX colour change

Hi,

Is there any way to turn of/use a function which will enable the use of Enter key on the keyboard to confirm HEX colour change?

As when the user starts to enter HEX colour value the Buttons on the colour picker are covered by keyboard, so to confirm the colour change user need to minimise the keyboard and then press OK button.

If the keyboard is open it would be logical to use Enter to confirm the colour change.

Happy to help with testing.

Cheers

vulterey

Screenshot_20200610-122148

Cannot acquire colors when called setPickerCount(n); where n>1

When trying to set multiple colors by using ColorPickerDialogBuilder, for instance: text color and background color, I cannot acquire set colors.

.setPositiveButton("ok", new ColorPickerClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
                       //how to get chosen colors?
                }
})

I can get selectedColor, but how to know which index is that? Is that 1st color, 2nd etc.

Migrate to AndroidX

As I understand https://developer.android.com/guide/topics/ui/settings.html we should use AndroidX libraries for new development.

@martin-stone Having your Color Picker as an internal project ( see #51 (comment) ) I realized that before starting to write my new Custom preference I must migrate your component first :-)

And I did this. One day - and it works! Please feel free to integrate these changes into your repository, see this commit with full code of Preferences migration to AndroidX: andstatus/todoagenda@27cce2c

@martin-stone Thank you once again for the beautiful Color Picker.

Way to place color picker in custom dialog

First off love the library but we're working on an app that requires the color picker to be placed in a custom dialog. The dialog's layout is being inflated from an xml file. We have tried to add the view programatically as well and add the view via XML but the HueViewSat.java file throws a null pointer. The alpha and saturation views show up fine but the rest of the color picker fails to draw correctly< (old and current color, color selection view, etc.) We would like to stay away from using the library using the colorPreference method as well. Is there a current work around for this? Also the color picker is being placed on a LinearLayout with a ScrollView attached.

Below is our stack trace.
java.lang.NullPointerException
at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1269)
at android.graphics.Canvas.drawBitmap(Canvas.java:1404)
at com.rarepebble.colorpicker.HueSatView.onDraw_Original(HueSatView.java:162)
at com.rarepebble.colorpicker.HueSatView.onDraw(HueSatView.java)
at android.view.View.draw(View.java:16178)
at android.view.View.draw(View.java:16090)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16088)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16088)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16088)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16088)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16181)
at android.widget.ScrollView.draw(ScrollView.java:1712)
at android.view.View.draw(View.java:16090)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16088)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16181)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:431)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:428)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:511)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:499)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:499)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:611)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:608)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:365)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:608)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:630)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:643)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:585)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:580)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Thanks in advance for the help!

When creating ColorPreference programmatically defaultValue not works

I'm creating preference screen programmatically and I'm putting a ColorPrefrence inside it in this way:

ColorPreference pref= new ColorPreference(getActivity(),null);
pref.setTitle("Color");
pref.setKey("pref_color");
pref.setDefaultValue("#000000"); // or Color.WHITE

The problem is that until I change the color the thumbail isn't shown, because in method onSetInitialValue() of ColorPreference defaultValue is loaded right but not used as argument into setColor(). Programmatically there'isnt a way to set the defaultColor. Isn't it?

@Override
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
	setColor(restorePersistedValue ? getColor() : defaultColor);
}

Dark Theme how to implement

Hi,

I am trying to use your color picker in the preference screen, but I cannot make it apear in Dark version as it shown in the demo app. Is there any extra setting which I miss to add to my root_preferences.xml file?

Kind Regards

Adam

Impossible to use the library on android P

The method int save(int) in Canvas has been removed with a couple of constants. You need to replace the int save(int) method with a call of int save(), the version without parameters. At the moment the library is totally broken.

Delay and out of view in landscape

First of all, thanks for the project.
I am using your project library in my app. There is a delay in opening the picker view after tapping ( I am using your colorpicker in alertdialog). In Alertdialog, I have managed to change its layout from portrait to landscape without destroying the activity (via dialog dismiss and re create), but the view in landscape (whether its created for the 1st time or recreated) goes out of view at bottom.
Only the view of main color arc selector goes out a few dps, rest alpha selector and sat selector are fine.
I can send you a snapshot if it helps you.

Set Thump Position

Thank you for your helpful solution. I have a question regarding positioning the thump. I've inflated the view but I can't set the thump on 100. I tried xml:
android:progress="100"
but it didn't work.
Can you please provide me with a solution?

Here's my code:

edittextcolortext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LayoutInflater layoutInflaterco = LayoutInflater.from(MainActivity.this);
                final View promptViewco = layoutInflaterco.inflate(R.layout.cpicker, null);
                AlertDialog.Builder builderco = new AlertDialog.Builder(MainActivity.this);
                builderco.setView(promptViewco);

                final EditText colorpickeret = (EditText) promptViewco.findViewById(com.rarepebble.colorpicker.R.id.hexEdit);
                builderco.setPositiveButton(getString(R.string.savedialogyes), new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        // Do nothing but close the dialog

                    }
                });

                builderco.setCancelable(false)
                        .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, final int id) {
                                String s = "#"+colorpickeret.getText().toString();
                                textsample.setTextColor(Color.parseColor(s));
                            }
                        });

                builderco.setNegativeButton(getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });

                // create an alert dialog
                AlertDialog alertco = builderco.create();
                alertco.show();

            }
        });

Hi Greate Tool. How to fix this issue, xml file not rendering.

java.lang.NoClassDefFoundError: com/rarepebble/colorpicker/R$styleable
at com.rarepebble.colorpicker.ColorPreference.(ColorPreference.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at android.preference.GenericInflater.createItem(GenericInflater.java:385)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:432)
at android.preference.GenericInflater.rInflate(GenericInflater.java:483)
at android.preference.GenericInflater.rInflate(GenericInflater.java:495)
at android.preference.GenericInflater.inflate(GenericInflater.java:327)
at android.preference.Preference_Delegate.inflatePreference(Preference_Delegate.java:60)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:220)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Thumbnail color not refreshed

Step to reproduce:

  1. Open activity with a settings fragment
  2. Go home
  3. Change the preference color via intent/broadcast receiver
  4. Come back home

The thumbnail shows the old color. Restarting the activity fix the problem. It would be great to have a public method to refresh/invalidate the thumbnail color.

Color changed listener

I think, this would be nice... Sadly, the observable color is private and has no getter nor does the ColorPickerView have a function to forward an custom color observable...

Change the colorPrimary

Hello, i want to change the colorPrimary with the ColorPicker (values/styles.xml) . This is posible? If yes, can you explain me a little? Actually i have this system in my MainActivity.java and choose the theme via PreferenceScreen

`final boolean Orange = Theme.getInstance(this).setTheme().equals("Orange");

boolean mCreatingActivity = true;
if (!mCreatingActivity) {
if (Orange)
setTheme(R.style.Orange);`

Thumbnail color doesn't update

We're using a couple of ColorPreference in a PreferenceFragment, the XMLfor the fragment is as follows;

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <com.rarepebble.colorpicker.ColorPreference
        android:key="text_color"
        android:title="@string/text_color_title"
        app:colorpicker_showHex="false" />

    <com.rarepebble.colorpicker.ColorPreference
        android:key="background_color"
        android:title="@string/background_color_title"
        app:colorpicker_showHex="false" />

</PreferenceScreen>

When changing the text_color preference, the onPreferenceChange listener is fired, however, the thumbnail does not update, regardless of whether setColor() is called or not on the changing preference within the listener.

When changing the background_color preference, the thumbnail updates correctly.

Summary text problem

It seems impossible to set a summary text for your color preference. I'm using api 23.

jcenter()

Hi Martin,

Is there any chance you will migrate repository from jcenter to mavenCentral soon?

Kind Regards
Adam

ColorPreference: read from disk on UI thead

Hello

Please see this StrictMode report

D/StrictMode: StrictMode policy violation; ~duration=116 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65599 violation=2
    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1440)
    at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
    at java.io.File.exists(File.java:807)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:572)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:563)
    at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:519)
    at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:714)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:368)
    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
    at android.preference.PreferenceManager.getSharedPreferences(PreferenceManager.java:510)
    at android.preference.Preference.getSharedPreferences(Preference.java:1204)
    at com.rarepebble.colorpicker.ColorPreference.getPersistedIntDefaultOrNull(ColorPreference.java:120)
    at com.rarepebble.colorpicker.ColorPreference.onBindView(ColorPreference.java:71)

Thanks

Edit: after some investigation, I see that this is how Preferences are generally designed to work.
But as an improvement, you may omit using getSharedPreferences() in case isPersistent() is false.

In my case I do not store this color under the default storage provided by the Preference, so I would like to have the ability to disable this behavior with isPersistent flag.

Non-SharedPreference based projects

I don't know that much in android.preference package so here is the error

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.content.SharedPreferences.contains(java.lang.String)' on a null object reference
        at com.rarepebble.colorpicker.ColorPreference.getPersistedIntDefaultOrNull(ColorPreference.java:162)
        at com.rarepebble.colorpicker.ColorPreference.getColor(ColorPreference.java:234)
        at com.rarepebble.colorpicker.ColorPreference.onSetInitialValue(ColorPreference.java:123)
        at androidx.preference.Preference.dispatchSetInitialValue(Preference.java:1576)
        at androidx.preference.Preference.onAttachedToHierarchy(Preference.java:1311)
        at androidx.preference.Preference.onAttachedToHierarchy(Preference.java:1326)
        at androidx.preference.PreferenceGroup.addPreference(PreferenceGroup.java:249)
        at androidx.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:170)
        at androidx.preference.PreferenceInflater.rInflate(PreferenceInflater.java:345)
        at androidx.preference.PreferenceInflater.rInflate(PreferenceInflater.java:346)
        at androidx.preference.PreferenceInflater.inflate(PreferenceInflater.java:157)
        at androidx.preference.PreferenceInflater.inflate(PreferenceInflater.java:109)
        at androidx.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:216)
        at androidx.preference.PreferenceFragmentCompat.setPreferencesFromResource(PreferenceFragmentCompat.java:377)
        at lsafer.edgeseek.fragment.EdgeDataFragment.onCreatePreferences(EdgeDataFragment.java:49)
        at androidx.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:160)
        at lsafer.edgeseek.fragment.EdgeDataFragment.onCreate(EdgeDataFragment.java:43)
        at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
        at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
        at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1255)
        at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1138)
        at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:136)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1989)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1947)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2629)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2577)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1433)
        at android.app.Activity.performStart(Activity.java:7980)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3578)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2220)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8016)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

public constructor for ObservableColor

I am trying to use the individual views directly in my own custom layout. However, I am unable to make an ObservableColor to link them together because the constructor is package-private. ("cannot be accessed from outside package") Could the constructor be made public for this use-case?

Delay >1 second when opening preference

Great lib! There could be a performance problem somewhere. On my Nexus 7 (pretty fast device) with Android 6.0.1 it takes more than one second to open the colorpicker preference after the tap on the setting.

Extension for showAlpha(false)

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...

Problem getting color

Hi, I am doing something wrong - how can I get already selected color code from preference screen, in my fragment class? Could not find in examples.

Broken layout on small screen

Hi,
thanks for the beautifull color picker preference.
Unfortunately it is not working well for small screen.
See the attached screenshot from the Color Picker Demo.
The ValueView is shown partially and the AlphaView and the EditText are not shown at all.
device-2015-09-26-103505

support API level 7

Hi,

is there a specific reason you only support api lvl 11 ?

I am looking for a picker that can be used in the android.support.v7.preference.Preference that also works for API level 7.

Thanks in advance and great work

getColor() doesn't always return latest value

I've been battling this problem I've been having and it seemed to me that something was wrong in my code, but according to the debugger it appears to be within this library.

I am using the latest version of this library (v2.3.0) and I have tried different targetSdk, compileSdk and Support Library revisions to no avail.

I have a ColorPreference on which I am calling setOnPreferenceChangeListener, and within that code I call...

Integer gradientEndColorValue = ((ColorPreference) findPreference("gradient_end_color")).getColor();

...so that I can then compare the value of gradientEndColorValue to another Integer color value.

But, according to the debugger, when I press "OK" on the dialog, the onPreferenceChangeListener is called, but getColor() returns the previous value, since SharedPreferences hasn't written the new value to the store yet since SharedPreferences.Editor.apply() is asynchronous.

I believe this library reads from SharedPreferences when calling getColor() in the following lines of code: ColorPreference.java#L119-L123

Would it be possible to store the current value in a variable so that getColor() returns the latest latest value, something like Android's ListPreference?

If you would like any debugger information, then I am happy to share it. Thank you!

OnPreferenceChangeListener is not called

The OnPreferenceChangeListener is not triggered when a color is selected.

My current work around is to implement SharedPreferences.OnSharedPreferenceChangeListener in my PreferenceFragment and check the returned key.

Set selected color

Is that somehow possible? I don't want to set the start color but rather the manually selected color. So I can combine this view with a handful of fix colors, that update the selected color of the view if I click them so that the user can afterwards adjust that color (mainly the alpha).

I want to combine this color picker with the default palette colors...

Alpha and Color scroller do not work in a ViewPager

In a ViewPager, I can't use the color picker view, as it does not correctly consume the touch events and the pager underneath catches the touches and starts scrolling.

The main view is handling the touches correctly and consumes them completely.

PreferenceManager.setDefaultValues not picking default values

Hi, this is a great library for Android Color picker with alpha and hex display options. Tons of thanks for such a wonderful library.

While using it in one of my apps, in settings.xml i provide a value for app:colorpicker_defaultColor.
Also in my Launcher Activity i am initializing preferences values from their defaults as PreferenceManager.setDefaultValues(this, R.xml.settings, false);

It seems PreferenceManager is not setting the default values for com.rarepebble.colorpicker.ColorPreference. Kindly confirm, am i missing something.

Thanks & Regards

No Buttons in DialogFragment

I am trying to use HSV-Alpha within a support-v4 DialogFragment. I am able to instantiate the dialog and inflate the view correctly but I have no positive/negative buttons and no "no color" button. It makes no difference whether I am in portrait or landscape mode. I don't believe the buttons are falling off the bottom of the visible area, either. If I take away hex and alpha the dialog height shrinks accordingly but I still see no buttons. I also installed on a physical device with more screen real estate than the emulator and they don't show there either despite having a sizable percentage of screen available outside the dialog fragment. Both the emulator and phone are running Lollipop (5.0.1 and 5.1). My code is nearly verbatim copy/paste from the "Usage" section.

Compatibility upto API 14

Excellent library, it's just what I needed but can you make your library backward compatible to API 14, moreover my project supports API 14.

Waiting for it.

Soft keyboard popups by default

Great lib. However in Android 6 the soft keyboard popups when opening com.rarepebble.colorpicker.ColorPreference as the hex field is gaining focus. Is there a way to avoid keyboard?

ClassCastException when migrating from EditTextPreference

When replacing an EditTextPreference:

<EditTextPreference
    android:defaultValue="@color/my_default_color"
    android:key="my_bgcolor"
    android:selectAllOnFocus="true"
    android:singleLine="true"
    android:title="@string/my_color_title"/>

with ColorPreference:

<com.rarepebble.colorpicker.ColorPreference
    android:key="my_bgcolor"
    android:title="@string/my_color_title"
    android:defaultValue="@color/my_default_color"/>

I receive this exception upon opening the preference page:

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
  at android.app.SharedPreferencesImpl.getInt(SharedPreferencesImpl.java:239)
  at android.preference.Preference.getPersistedInt(Preference.java:1559)
  at com.rarepebble.colorpicker.ColorPreference.getPersistedIntDefaultOrNull(ColorPreference.java:120)
  at com.rarepebble.colorpicker.ColorPreference.getColor(ColorPreference.java:199)
  at com.rarepebble.colorpicker.ColorPreference.onSetInitialValue(ColorPreference.java:104)
  at android.preference.Preference.dispatchSetInitialValue(Preference.java:1376)
  ...

The android:key="my_bgcolor" seems to store a dynamic type of String for EditTextPreference, which ColorPreference tries to cast into Integer.

A workaround is to rename the key or uninstall the app.

defaultValue does not work anymore on older devices

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!

Color Preference Preview Shape

Could we possibly have a more material like preview for the preference? I hate the square design and feel a circle design would be more attractive.

Setting color with low brightness leads to different colors

When setting the color picker to a low brightness (<=0.01) the hue and sat values of the ObservableColor start to change.

For example calling:
colorPickerView.setColor(Color.HSVToColor(new float[]{80f, 0.6f, 0.01f}));
Leads to Hue: 60.0, Sat: 0.5, Bri: 0.007843138 from the color observer.

Lowering the brightness even more results to completely different hue and sat results:
Setting Hue: 80, Sat: 0.6, Bri: 0 leads to Hue: 0, Sat: 0, Bri: 0.

This issue is caused by:
Color.colorToHSV(color, hsv); (ObservableColor:93)
Somehow the Color library is not able to work properly with low brightness values.

Possible solution:
Introduce new method setColor(hue, sat, bri) to ColorPickerView that does not rely on the color library?

resize the thumbnail in setting page

Is it possible to resize the color picker thumbnail in the setting page?
for instance, make it the same size as the checkbox or make it a small circle.
thanks

Support for AppCompat preferences

Hello,

I am using com.android.support:preference-v7:23.4.0 to implement the preferences screen in my app. Even if I'll set the min SDK to 11, I'll get an error when trying to use your Color Picker:
com.rarepebble.colorpicker.ColorPreference cannot be cast to android.support.v7.preference.Preference

Is there anything I can do to use it in my app?

Thanks!

modification of the demo app

Dear Mr. martin-stone
I found your library mentioned in https://ourcodeworld.com/articles/read/932/top-10-best-android-color-picker-libraries.
I was playing with it and I did a modification of the demo app to be capable of being call from another application via Intent+startActivityForResult
so the demo is and application in its own capable of receiving "request" and give back the color number.
The modifications are not so big, adding a Done button, add the intent-filter to the manifest and the Intent response in the MainActivity.
I guess is good idea to put this "demo" (now an app in its own) in the Play Store (and it continues to be a valid demo for your library). If you also thinks it is a good idea send me an email and I'll forward you the zip file with your modified project
Regards (daniel.calcoen at gmail.com)

Default button sets a wrong color 888888

Using colorpicker 2.4.2 with Android 7 device.

<de.myapp.ColorPickerPref
                android:defaultValue="#000000"
                android:key="appLauncherTextColor"
                android:summary="Select app label color"
                android:title="Launcher Text Color"
                app:colorpicker_selectNoneButtonText="Default"
                app:colorpicker_showAlpha="false" />

Pressing the Default button in the colorpicker dialog box leads to showing 888888 as selected color and the thumbnail on the pref list is colored darkgray.

Expect setting color to 000000.

Actually colorpicker is still passing the correct value #000000 back to settings. However the view in the colorpicker dialog box and pref list is misleading.

Adding ColorPickerView causes significant animation lag when starting an activity using makeSceneTransitionAnimation

My app uses ActivityOptionsCompat.makeSceneTransitionAnimation() to animate the transition between clicking a card in a RecyclerView to an activity which may or may not contain ColorPickerView depending on the card that's been clicked on. The view has a default visibility of GONE and is set to VISIBLE in OnCreate when required, but this appears to cause a huge amount of lag in the transition animation.

Example: https://goo.gl/photos/G9ansCwnEVZq9P9q6

More than happy to provide any code or other information.

rendering problem in android studio

java.lang.NoClassDefFoundError: com/rarepebble/colorpicker/R$styleable
at com.rarepebble.colorpicker.ColorPreference.(ColorPreference.java:43)
at sun.reflect.GeneratedConstructorAccessor2174.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at android.preference.GenericInflater.createItem(GenericInflater.java:385)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:432)
at android.preference.GenericInflater.rInflate(GenericInflater.java:483)
at android.preference.GenericInflater.rInflate(GenericInflater.java:495)
at android.preference.GenericInflater.inflate(GenericInflater.java:327)
at android.preference.Preference_Delegate.inflatePreference(Preference_Delegate.java:64)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:410)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:322)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:511)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:499)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:499)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:611)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:608)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:363)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:608)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:630)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:643)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:585)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:580)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

String cannot be cast to Integer (incorrect library usage?)

When I try to load preferences in my app, I keep getting the error "java.lang.RuntimeException: Unable to start activity ComponentInfo{.......MyPreferencesActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)"

In my activityMain I default the sharedPreference for a key value (upon first launch of the app):
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt("go_circle_colour_pref_key",Integer.parseInt("0x00ff00"));

In my preferences.xml, I have:
<com.rarepebble.colorpicker.ColorPreference android:key="go_circle_colour_pref_key" android:title="@string/goColour" app:colorpicker_showAlpha="true" />

I have tried:

  • putting default colours in the preferences.xml, e.g.
    <!--android:defaultValue="#f00"-->

  • editor.putInt("go_circle_colour_pref_key",Integer.parseInt("0x00ff00"));

  • editor.putInt("go_circle_colour_pref_key",0x00ff00);

  • editor.putInt("go_circle_colour_pref_key",Color.parseColor("#00ff00");

  • editor.putString("go_circle_colour_pref_key","#00ff00";

  • editor.putString("go_circle_colour_pref_key","#0f0";

  • editor.putString("go_circle_colour_pref_key","0x00ff00";

If I give the color-picker preference in xml a key that doesn't actually get used (initialised in activityMain), then the colour picker works OK. I seem to be initialising the key incorrectly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.