attenzione / android-colorpickerpreference Goto Github PK
View Code? Open in Web Editor NEWColorPickerPreference for android to create color picker in preferences. Project created as Library
License: Apache License 2.0
ColorPickerPreference for android to create color picker in preferences. Project created as Library
License: Apache License 2.0
I have found a workaround that finishes the settings activity and restarts it. But is there a reason why in ColoPickerPreference the setImageBitmap(getPreviewBitmap()) does not reflect the change when a new color is selected?
If screen is rotated the preview box has the newly selected color.
ICS and Jellybean have this same effect.
Unsupported major.minor version 52.0
Today get this error in
MyPath\AndroidStudioProjects\MyApp\app\libs\ColorPickerPreference\ColorPickerPreference\build.gradle
before everything worked fine
In some devices(OS: 6.0.1, Galaxy A7), error occurs.
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1310)
at android.graphics.Canvas.drawBitmap(Canvas.java:1445)
at net.margaritov.preference.colorpicker.AlphaPatternDrawable.draw(AlphaPatternDrawable.java:57)
at net.margaritov.preference.colorpicker.ColorPickerPanelView.onDraw(ColorPickerPanelView.java:86)
at android.view.View.draw(View.java:17526)
at android.view.View.updateDisplayListIfDirty(View.java:16519)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3910)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3890)
at android.view.View.updateDisplayListIfDirty(View.java:16479)
at android.view.View.draw(View.java:17295)
at android.view.ViewGroup.drawChild(ViewGroup.java:3926)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3716)
at android.view.View.updateDisplayListIfDirty(View.java:16514)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3910)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3890)
at android.view.View.updateDisplayListIfDirty(View.java:16479)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3910)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3890)
at android.view.View.updateDisplayListIfDirty(View.java:16479)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3910)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3890)
at android.view.View.updateDisplayListIfDirty(View.java:16479)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:325)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:331)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:366)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3234)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3033)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2615)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1528)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7530)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:622)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7329)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
In the comment of the class it says:
A preference type that allows a user to choose a time
but I'm pretty sure what I can see the user can choose a color not a time
Please change comment to:
A preference type that allows a user to choose a color
If I delete jcenter
(deprecated) repository from my build.gradle
, add mavenCentral
and add implementation 'net.margaritov.preference.colorpicker.ColorPickerPreference:ColorPickerPreference:1.0.0'
I got the following error:
Failed to resolve: net.margaritov.preference.colorpicker.ColorPickerPreference:ColorPickerPreference:1.0.0
Program type already present: net.margaritov.preference.colorpicker.BuildConfig
这个问题该如何解决
Could you clarify the license? Can I use it in closed-source apps?
The sample activity to showcase the library capabilities (ColorPickerPreference/src/main/java/net/margaritov/preference/colorpicker/Test.java
) and the manifest file where it is declared (ColorPickerPreference/src/main/AndroidManifest.xml
) are placed alongside the library sources.
Since settings.gradle has include ':app', ':ColorPickerPreference'
, that manifest is merged with the main manifest of the app using the library.
As a result, an app that uses the library with the directory tree laid out here ends up with two launcher activities and two icons in the app drawer.
The workaround is commenting the entire <application>
tag in the manifest, but it would be great to see the sample activity being placed in a different directory not being seen by Gradle - a usual practice in library code.
This is the best implementation I've seen so far, congratulations!
It would be great if you could make the alpha slider optional (in the dialog and preference) for apps that do not need alpha support.
One more request: could you make the widget that appears at the left of the preference label (the color "button") into a color button that can be used in other contexts (outside of preferences)? I'd like to use it in my layouts.
Thanks!
* Where:
Script 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' line: 1
* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'com.github.dcendents.android-maven' not found.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating script.
at ...
at build_4bt5nm20qbc9qf92rw9f04bxy.run(/xxx/ColorPickerPreference/ColorPickerPreference/build.gradle:50)
at ...
at installv1_7fnondwfez6ilvn50dvvmy5zv.run(https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle:1)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 154 more
https://github.com/dcendents/android-maven-gradle-plugin says that it is abandoned
When "orientation" and "screenSize" is defined in Activity's configChanges and screen is rotated at Android 4.0+, some parts of view is disappeared. For example, AndroidManifest is following.
If "screenSize" is deleted from configChanges, it works properly.
Please look at the following screenshot which some part of view is disappeared.
ColorPickerDialog line 44; isn't it meant to be public?
at least on Android 2.3 i got incorrect dialog width with a little bit free space on the right side.
Looked at source, it's seems that android doesn't measure latest width of root LinearLayout.
All children width (summary) is lower than dialog actual width.
need help :)
I've tested this library on Android 1.6, and it seems to work fine. So you can probably change your min sdk to 4 :)
(Note, I tested the one on jcenter: com.robbypond:android-ColorPickerPreference:1.11.1)
downloas
Obviously you renamed your package name from com.att.preference.colorpicker to net.margaritov.preference.colorpicker, however you still have many references to the old package name within your code and xml files making the colorpicker crash.
Will it possible to add a EditText field in the dialog so the user can enter a RRGGBB or AARRGGBB code directly ?
What would be even better would be to be able to enter also A / R / G / B as 0-255 values like in this image : http://obibb.files.wordpress.com/2010/06/pn-color.png
java.lang.ClassCastException: net.margaritov.preference.colorpicker.ColorPickerPreference cannot be cast to android.support.v7.preference.Preference
any chance to migrate the code to the new appcompat preference ?
Default values with transparency, starting with one or two zeroes, break the color parsing and then crash the app.
I didn't look too deep into the issue, but
#00000000
and #01000000
become #0
and #1000000
respectively for example.I am testing your code in LG optimas running on Android2.2
I am getting forse close error while opening your test activity.
Here is my logcat
01-06 11:36:15.379: W/dalvikvm(11949): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
01-06 11:36:15.419: E/AndroidRuntime(11949): FATAL EXCEPTION: main
01-06 11:36:15.419: E/AndroidRuntime(11949): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.margaritov.preference.colorpicker/net.margaritov.preference.colorpicker.Test}: android.view.InflateException: Binary XML file line #24: Error inflating class java.lang.reflect.Constructor
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.os.Looper.loop(Looper.java:123)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-06 11:36:15.419: E/AndroidRuntime(11949): at java.lang.reflect.Method.invokeNative(Native Method)
01-06 11:36:15.419: E/AndroidRuntime(11949): at java.lang.reflect.Method.invoke(Method.java:521)
01-06 11:36:15.419: E/AndroidRuntime(11949): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-06 11:36:15.419: E/AndroidRuntime(11949): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-06 11:36:15.419: E/AndroidRuntime(11949): at dalvik.system.NativeStart.main(Native Method)
01-06 11:36:15.419: E/AndroidRuntime(11949): Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class java.lang.reflect.Constructor
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.createItem(GenericInflater.java:397)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.inflate(GenericInflater.java:326)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:262)
01-06 11:36:15.419: E/AndroidRuntime(11949): at net.margaritov.preference.colorpicker.Test.onCreate(Test.java:31)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-06 11:36:15.419: E/AndroidRuntime(11949): ... 11 more
01-06 11:36:15.419: E/AndroidRuntime(11949): Caused by: java.lang.reflect.InvocationTargetException
01-06 11:36:15.419: E/AndroidRuntime(11949): at net.margaritov.preference.colorpicker.ColorPickerPreference.(ColorPickerPreference.java:56)
01-06 11:36:15.419: E/AndroidRuntime(11949): at java.lang.reflect.Constructor.constructNative(Native Method)
01-06 11:36:15.419: E/AndroidRuntime(11949): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.GenericInflater.createItem(GenericInflater.java:383)
01-06 11:36:15.419: E/AndroidRuntime(11949): ... 21 more
01-06 11:36:15.419: E/AndroidRuntime(11949): Caused by: android.content.res.Resources$NotFoundException: File #0000FF from drawable resource ID #0x0: .xml extension required
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.content.res.Resources.loadColorStateList(Resources.java:1824)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.content.res.TypedArray.getColor(TypedArray.java:319)
01-06 11:36:15.419: E/AndroidRuntime(11949): at net.margaritov.preference.colorpicker.ColorPickerPreference.onGetDefaultValue(ColorPickerPreference.java:67)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.Preference.(Preference.java:240)
01-06 11:36:15.419: E/AndroidRuntime(11949): at android.preference.Preference.(Preference.java:271)
01-06 11:36:15.419: E/AndroidRuntime(11949): ... 25 more
If I usually use model.setColor(Color.BLUE); how would I use this instead? I've seen it used in a number of live wallpapers, I would just like to know how to do it. Thank you.
I've tried to modify the dialog theming but it doesn't works. I changed ColorPickerDialog constructor and now it works
public ColorPickerDialog(Context context, int initialColor) {
super(context, R.style.MyTheme);
There is no R files under gen/.
How i can solve this?
Only the colorwheel is shown...
Hello,
I have been using your ColorPicker in one of my projects and it's by far the best out there. Thank you very much!
I have noticed a little problem and I wanted to offer you a solution I programmed into my project.
There is a little kink in setting the color in attr defaultValue. If you set a color as actual integer, then it works fine, but if you set it as reference to resources, f.e. @color/someColor, you always get 0 in shared preferences. You also can't get it to set defaultValue using hex string.
Both problems are fixed by using this inside onGetDefaultValue method:
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
int colorInt;
String mHexDefaultValue = a.getString(index);
if (mHexDefaultValue != null) {
colorInt = convertToColorInt(mHexDefaultValue);
return colorInt;
} else {
return a.getColor(index, Color.BLACK);
}
}
I have tested repeatedly and now it sets the actual integer value if you use either proper hex string (6 or 8 chars) or reference to resource color.
If you find this useful, feel free to include.
Thank you again for your great work,
Anna
Hi,
this files are no longer available:
Error:A problem occurred configuring project ':app'.
Could not find android-ColorPickerPreference.jar (com.github.attenzione:android-ColorPickerPreference:e3aa301016).
Searched in the following locations:
https://jitpack.io/com/github/attenzione/android-ColorPickerPreference/e3aa301016/android-ColorPickerPreference-e3aa301016.jar
Please fix this. Thank you very much!
Please use the following attribute for view EditText hex_val to prevent wrong chars in hex input:
android:digits="0123456789ABCDEF"
When using this for my app, running the color picker dialog in QVGA/LDPI results in a partially cut off dialog window. I resolved this by hiding the title of the dialog on init.
requestWindowFeature(Window.FEATURE_NO_TITLE);
Not sure if anyone else will run into this issue.
Likely my problem, but spent days on it.
The color preference works perfectly. It correctly reads the default color and displays it on the setting screen.
However, the statement in my code:
preferredcolour = mysharedPreferences.getInt("mechanism_color",R.integer.COLOR_Fuchsia);
Doesn't work properly unless I have manually selected a color. The preview screen shows Fuchsia but the code above returns a color very close to (but not exactly) black. Once I have set a color by hand, it works as expected. To recreate the problem, I have to delete the application from my phone so a new Preference file is re-created.
It is as if the Preference file is not being updated with the correct color value until after I have changed the color preference.
I don't know if its me or the code (very likely me), I have spent days seeing the same problem, can't even figure out a workaround, can anybody give me any idea how to fix it?
The caption of the color picker should be the title, not 'Color Picker'.
Since the color picker already has a default value, there should be a button to restore the default value.
The 'Press on color to apply' string should be parameterizable in order to provide a localized string.
Great work though, thanks.
Hey, I want to use this preference for my Android project. Unfortunately, the previews don't look quite right on ICS, they seem to have a bit of a checkered pattern on their sides.
Here's a screenshot.
This is the code I'm using:
<net.margaritov.preference.colorpicker.ColorPickerPreference
android:defaultValue="#ff2525"
android:dependency="sync_events"
android:key="event_color"
android:title="@string/calendar_color" />
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.