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" />