Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.dmfs:color-picker:1.3'
}
dependencies {
implementation("com.github.dmfs:color-picker:1.3")
}
<dependency>
<groupId>com.github.dmfs</groupId>
<artifactId>color-picker</artifactId>
<version>1.3</version>
</dependency>
libraryDependencies += "com.github.dmfs" % "color-picker" % "1.3"
:dependencies [[com.github.dmfs/color-picker "1.3"]]
Just another color picker for Android
This is a nice and simple color picker for Android. It allows to show any number of different palettes with any (reasonable) number of colors. Palettes can be stored in an array or generated on the fly.
To show the dialog, just get an instance, add a number of palettes and call the show method.
ColorPickerDialogFragment d = new ColorPickerDialogFragment();
// set the palettes
d.setPalettes(new AbstractPalette[]
{
ArrayPalette.fromResources(this, "basecolors", R.string.base_palette_name, R.array.base_palette_colors, R.array.base_palette_color_names),
new FactoryPalette("rainbow", "Rainbow", ColorFactory.RAINBOW, 16)
});
d.show(getSupportFragmentManager(), tag);
The calling activity or fragment should implement ColorPickerDialogFragment.ColorDialogResultListener to get the result like:
@Override
public void onColorChanged(int color, String colorName, String paletteName)
{
// do something with color
}
@Override
public void onColorDialogCancelled()
{
// handle cancelled color picker dialog
}

Copyright (c) dmfs GmbH 2018, licensed under Apache 2 (see LICENSE).