SeslColorPickerDialog

A dialog that shows a SeslColorPicker.

This dialog allows users to select a color using various methods, including a spectrum view, RGB/HSV input fields, and an eyedropper tool. It provides options to set an initial color, recently used colors, and toggle the visibility of an opacity bar.

The dialog can be configured to use an eyedropper tool by providing an image via setOnBitmapSetListener. When an image is set, the eyedropper tool becomes visible, allowing users to pick colors directly from the image. If no image is provided, or if it's set to null, the eyedropper tool is hidden, and a "last used color slot" might be shown instead, depending on the SeslColorPicker configuration.

The selected color can be retrieved through the OnColorSetListener interface, which is invoked when the user confirms their selection.

Example usage:


SeslColorPickerDialog colorPickerDialog = new SeslColorPickerDialog(
    context,
    new SeslColorPickerDialog.OnColorSetListener() {
        
        public void onColorSet(int color) {
            // Handle the selected color
        }
    },
    initialColor, // Optional: set an initial color
    recentlyUsedColors, // Optional: provide an array of recently used colors
    true // Optional: show the opacity bar
);

// To use the eyedropper with an image:
colorPickerDialog.setOnBitmapSetListener(new SeslColorPickerDialog.OnBitmapSetListener() {
    
    public Bitmap onBitmapSet() {
        // Return the Bitmap to be used by the eyedropper
        // For example, load from resources:
        // return BitmapFactory.decodeResource(getResources(), R.drawable.my_image);
        return yourBitmap;
    }
});

colorPickerDialog.show();

Note: To use the eye dropper tool, you must declare androidx.picker.eyeDropper.SeslEyeDropperActivity in your app's AndroidManifest.xml:

<activity android:name="androidx.picker.eyeDropper.SeslEyeDropperActivity"
          android:exported="false" />

See also

Constructors

Link copied to clipboard
constructor(@NonNull context: @NonNull Context, @Nullable listener: @Nullable SeslColorPickerDialog.OnColorSetListener)
constructor(@NonNull context: @NonNull Context, @Nullable listener: @Nullable SeslColorPickerDialog.OnColorSetListener, currentColor: Int)
constructor(@NonNull context: @NonNull Context, @Nullable listener: @Nullable SeslColorPickerDialog.OnColorSetListener, recentlyUsedColors: Array<Int>)
constructor(@NonNull context: @NonNull Context, @Nullable onColorSetListener: @Nullable SeslColorPickerDialog.OnColorSetListener, currentColor: Int, recentlyUsedColors: Array<Int>, showOpacityBar: Boolean)

Types

Link copied to clipboard
Link copied to clipboard
Interface used to indicate that the user has finished selecting a color.

Functions

Link copied to clipboard
open fun disableEyeDropper(disable: Boolean)
Disables or enables the eye dropper tool.
Link copied to clipboard
@NonNull
open fun getColorPicker(): @NonNull SeslColorPicker
Returns the SeslColorPicker instance used by this dialog.
Link copied to clipboard
open fun getMode(): Int
Retrieves the current mode of the color picker.
Link copied to clipboard
open fun onClick(dialog: DialogInterface, whichButton: Int)
Link copied to clipboard
open fun onRestoreInstanceState(@NonNull savedInstanceState: @NonNull Bundle)
Link copied to clipboard
@NonNull
open fun onSaveInstanceState(): @NonNull Bundle
Link copied to clipboard
open fun setMode(mode: Int)
Sets the display mode of the color picker.
Link copied to clipboard
open fun setNewColor(@Nullable newColor: @Nullable Integer)
Sets the new color in the color picker.
Link copied to clipboard
open fun setOnBitmapSetListener(@Nullable listener: @Nullable SeslColorPickerDialog.OnBitmapSetListener)
Sets a listener to provide a Bitmap for the eye dropper tool.
Link copied to clipboard
Sets the color picker to only show the spectrum mode.
Link copied to clipboard
Sets whether the transparency control (opacity bar) is enabled in the color picker.