dhaval2404 / colorpicker Goto Github PK
View Code? Open in Web Editor NEW🎨 Color Picker Library for Android
License: Apache License 2.0
🎨 Color Picker Library for Android
License: Apache License 2.0
What About java? it not support java? any java code?
Hello I was trying to use the ColorPicker, but when the app is running and the Dialog is opening the app crash with the following error:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/databinding/DataBinderMapperImpl;
at androidx.databinding.DataBindingUtil.(DataBindingUtil.java:32)
at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:95)
at com.github.dhaval2404.colorpicker.adapter.MaterialColorPickerAdapter.bindAdapter(MaterialColorPickerAdapter.kt:48)
at com.github.dhaval2404.colorpicker.adapter.MaterialColorPickerAdapter.onCreateViewHolder(MaterialColorPickerAdapter.kt:57)
at com.github.dhaval2404.colorpicker.adapter.MaterialColorPickerAdapter.onCreateViewHolder(MaterialColorPickerAdapter.kt:20)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at com.google.android.flexbox.FlexboxLayoutManager.getFlexItemAt(FlexboxLayoutManager.java:456)
at com.google.android.flexbox.FlexboxLayoutManager.getReorderedFlexItemAt(FlexboxLayoutManager.java:474)
at com.google.android.flexbox.FlexboxHelper.calculateFlexLines(FlexboxHelper.java:427)
at com.google.android.flexbox.FlexboxHelper.calculateHorizontalFlexLines(FlexboxHelper.java:247)
at com.google.android.flexbox.FlexboxLayoutManager.updateFlexLines(FlexboxLayoutManager.java:953)
at com.google.android.flexbox.FlexboxLayoutManager.onLayoutChildren(FlexboxLayoutManager.java:729)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3540)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19762)
at androidx.appcompat.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:134)
at androidx.appcompat.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:64)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19762)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:690)
at android.view.View.measure(View.java:19762)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2315)
while using ColorPicker, there is an error which says : cannot access Function2 on .setOnColorListener(new ColorListener())
*frgmnts\ColorPickerFragment.java:94: error: cannot access Function2
.setColorListener(new ColorListener() {
^
class file for kotlin.jvm.functions.Function2 not found
implementation from Github repo.
Gradle version: 4.2.1
Currently positive and negative button text color is dependent on colorAccent.
Need to add an option to change the positive and negative button text color
In README.md there's a typo. Well, actually several. "SQUARE" is misspelled as "SQAURE" in the example Code.
MinSdkVersion dk 21? sorry we cant use it .. what about all other 50% users?
Hello,
I´m using ColorPicker, but I don't find how with ColorPicker Dialog choose dark colors like grey or Black. Are there any parameters to set this tones ?
I get a crash when trying to show a MaterialColorPickerDialog:
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter color
at com.github.dhaval2404.colorpicker.util.ColorUtil.isDarkColor(Unknown Source:2)
at com.github.dhaval2404.colorpicker.adapter.MaterialColorPickerAdapter.<init>(MaterialColorPickerAdapter.kt:28)
at com.github.dhaval2404.colorpicker.MaterialColorPickerDialog.show(MaterialColorPickerDialog.kt:326)
at com.github.dhaval2404.colorpicker.MaterialColorPickerDialog$Builder.show(MaterialColorPickerDialog.kt:289)
val defaultColors = resources.getStringArray(R.array.clothingColors)
MaterialColorPickerDialog.Builder(requireContext())
.setTitle("Choose color")
.setColorShape(ColorShape.CIRCLE)
.setColorSwatch(ColorSwatch._300)
.setColors(defaultColors)
.setDefaultColor(R.color.tomato)
.setColorListener { color, hex -> }
.show()
arrays.xml
<resources>
<array name="clothingColors">
<item>@color/tomato</item>
<item>@color/tangerine</item>
<item>@color/banana</item>
<item>@color/basil</item>
<item>@color/sage</item>
<item>@color/peacock</item>
<item>@color/blueberry</item>
<item>@color/lavender</item>
<item>@color/grape</item>
<item>@color/flamingo</item>
<item>@color/graphite</item>
</array>
</resources>
AppTheme: Theme.MaterialComponents.DayNight.NoActionBar
Tested on Android 11 and 12
Gradle implementation 'com.github.dhaval2404:colorpicker:2.0'
30
Was wondering if there was a way to change dialog background color and title color to a desired color, I didn't seem to find a way to do it easily.
as you see from below image, since I have android:textColor
set to white manually in my theme it causes issues here, would love to have the option to change the dialog background/title color manually.
Also, the setTickColorPerCard(true)
doesn't seem to do what it's supposed to do for me, stays white on all colors.
Apologies for the hassle.
Hey,
your BottomSheetDialog seems to not have edge-to-egde support. Could you please add this feature to your library?
If I have both implementations of FlexBox
and your ColorPicker
(like below) :
implementation 'com.github.Dhaval2404:ColorPicker:2.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
I get this error when I run the project :
Execution failed for task ':app:checkDebugDuplicateClasses'.`
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.google.android.flexbox.AlignContent found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.AlignItems found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.AlignSelf found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexContainer found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexDirection found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexItem found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexLine found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexWrap found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxHelper found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxHelper$1 found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxHelper$FlexLinesResult found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxHelper$Order found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxItemDecoration found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayout found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayout$DividerMode found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayout$LayoutParams found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayout$LayoutParams$1 found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$1 found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$AnchorInfo found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$LayoutParams found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$LayoutParams$1 found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$LayoutState found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$SavedState found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.FlexboxLayoutManager$SavedState$1 found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Duplicate class com.google.android.flexbox.JustifyContent found in modules jetified-flexbox-2.0.1-runtime (com.google.android:flexbox:2.0.1) and jetified-flexbox-3.0.0-runtime (com.google.android.flexbox:flexbox:3.0.0)
Need some help on what to do please.
On Android TV you do not see the colors selected as you move with the remote. It is a simple fix to add a selected state
Android TV
When I try to build my project, theres this error:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.google.android:flexbox:2.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/google/android/flexbox/2.0.1/flexbox-2.0.1.pom
- https://repo.maven.apache.org/maven2/com/google/android/flexbox/2.0.1/flexbox-2.0.1.pom
- https://jitpack.io/com/google/android/flexbox/2.0.1/flexbox-2.0.1.pom
Required by:
project :app > com.github.Dhaval2404:ColorPicker:v2.0
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I think it's because I don't use the repository "jcenter()" anymore (it's deprecated).
In https://stackoverflow.com/questions/53709146/failed-to-resolve-com-google-androidflexbox1-1-0 theres a similar problem.
They fixed it by using the dependency
com.google.android.flexbox:flexbox:3.0.0
instead of
com.google.android:flexbox:2.0.1
It would be nice if this project could also use mavenCentral() instead of jcenter() and try to Update this
@Dhaval2404 do you think you could test this?
Add a helper method to allow the creator of a dialog to run some code when the dialog is dismissed.
ColorPicker
ColorPickerDialog
.Builder(requireActivity())
.setDismissListener { // Proposed method
// Handle Dismiss Event
}
.show()
MaterialColorPicker
MaterialColorPickerDialog
.Builder(this)
.setDismissListener { // Proposed method
// Handle Dismiss Event
}
.show()
Credit: @Surendar7 #12
new ColorPickerDialog
.Builder(this)
.setTitle("Pick Theme")
.setColorShape(ColorShape.SQAURE)
.setDefaultColor(mDefaultColor)
.setColorListener(new ColorListener() {
@OverRide
public void onColorSelected(int color, https://github.com/NotNull String colorHex) {
// Handle Color Selection
}
})
.show();
showing error Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
My color list has both White and Black colors. The selection color is always white in both cases, so if white is selected the icon checked is not visible. Can you check for each color and change the icon checked color accordingly?
Having a dismiss listener will also be helpful.
Hello I was trying to use the ColorPicker, but when the app is running and the Dialog is opening the app crash with the following error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: xxxx.xxxxxx.xxxx.xxxx, PID: 4848
android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.github.dhaval2404.colorpicker.ColorPickerDialog.show(ColorPickerDialog.kt:202)
at com.github.dhaval2404.colorpicker.ColorPickerDialog$Builder.show(ColorPickerDialog.kt:186)
at com.mundocrativo.javier.twitter.ui.design.DesignFragment.showColorPicker(DesignFragment.kt:47)
at com.mundocrativo.javier.twitter.ui.design.DesignFragment$onCreateView$1.onClick(DesignFragment.kt:25)
It looks that there are a dependency that is not compatible. I´m opening a newproject in android studio and the only dependency that I use is this color picker.
I´m using Android Studio 3.5.
This is the dependencies in the gradle file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'com.github.dhaval2404:colorpicker:1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
most of the developer need minimum api 16 .. There is no reason for create this library for minimum 21???
After switched to Maven Central I receive:
Could not find com.github.dhaval2404:colorpicker:2.0.
Hello!
Can you please add an ability to select color straight on tapping the color card without a necessity to press Ok button ?
Thanks a lot!
Great library
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.