Just another color picker for Android
Java
Switch branches/tags
Nothing to show
Clone or download
dmfs move ColorPickerActivity to a separate module.
Upgrade Gradle & Gradle plugin.
Fix theme.
Latest commit a5f737b Dec 12, 2017
Permalink
Failed to load latest commit information.
app move ColorPickerActivity to a separate module. Dec 12, 2017
colorpicker-activity move ColorPickerActivity to a separate module. Dec 12, 2017
colorpicker move ColorPickerActivity to a separate module. Dec 12, 2017
demo move ColorPickerActivity to a separate module. Dec 12, 2017
gradle/wrapper move ColorPickerActivity to a separate module. Dec 12, 2017
screenshots
.gitignore remove spaces from .gitignore to exclude build and gradle directories Apr 22, 2015
LICENSE change license to Apache2 May 9, 2014
NOTICE change license to Apache2 May 9, 2014
README.md move ColorPickerActivity to a separate module. Dec 12, 2017
build.gradle move ColorPickerActivity to a separate module. Dec 12, 2017
gradlew
gradlew.bat AndroidStudio migration Apr 22, 2015
settings.gradle move ColorPickerActivity to a separate module. Dec 12, 2017

README.md

color-picker

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.

Requirements

Example code

Use as a dialog

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
		}

Use via Intent

Alternatively you can use the picker via Intent. To do so just include the following dependency

implementation "com.github.dmfs.color-picker:colorpicker-activity:1.1"

and call the dialog like:

		ColorPickerActivity.start(context, CODE_PICK_COLOR);

This will call an intent with the action org.openintents.action.PICK_COLOR allowing the user to use his preferred color picker (if it supports the Open Intent).

In onActivityResult(int, int, Intent) you can get the picked color like this:

		@Override
		protected void onActivityResult(int code, int result, Intent data)
		{
			if (result == RESULT_OK && code == CODE_PICK_COLOR)
			{
				Integer color = ColorPickerActivity.getColor(data);
			}
		}

Screen shots

TODO

  • fix landscape mode on smaller screens
  • fix selected/focused backgrounds
  • allow to customize color shapes
  • allow to preselect a specific color
  • add support for other fragment types, like hex input or color wheels

License

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