ColorPickerView icon indicating copy to clipboard operation
ColorPickerView copied to clipboard

The ColorPickerDialog is not supporting an initialColor and a FlagView

Open juliswer opened this issue 2 years ago • 3 comments

Overview

Bug: As in the ColorPickerView component, I'd expect to have the same options on the ColorPickerDialog. What do I mean with the same options? Im talking about the method .setInitialColor() and the ability to set a flagView as well.

Do you have some solution to set an initial color in a ColorPickerDialog?

juliswer avatar Aug 17 '23 18:08 juliswer

Hey @juliswer, have you ever tried the way below?

ColorPickerView colorPickerView = builder.getColorPickerView();
colorPickerView.setFlagView(new CustomFlag(this, R.layout.layout_flag)); // sets a custom flagView
colorPickerView. setInitialColor(..)

skydoves avatar Oct 02 '23 14:10 skydoves

hey @skydoves. Yes, i did. The issue is that the code you provided me with is referred to a ColorPickerView, but I'm using a ColorPickerDialog.

This ColorPickerDIalog is not allowing the same methods (setInitialColor & setFlagView) than the ColorPickerView.

this is my implementation:

val colorPickerDialog = ColorPickerDialog.Builder(context, R.style.ColorPickerDialog)
            .setTitle("Pick a Color")
            .setPreferenceName("ColorPickerDialog")
            .setPositiveButton("Apply",
                ColorEnvelopeListener { envelope, _ ->
                    // beauty color
                })
            .setNegativeButton(
                "Cancel"
            ) { dialogInterface, _ -> dialogInterface.dismiss() }
            .setNeutralButton("Delete color") { _, _ -> deleteColor(colorPosition) }
            .attachAlphaSlideBar(false)
            .attachBrightnessSlideBar(true)
            .setBottomSpace(12)
            .show()

juliswer avatar Oct 04 '23 21:10 juliswer

@juliswer You can extend the class and use something like this

public Builder setDefaultColor(int code) {
    if (getColorPickerView() != null) {
        getColorPickerView().setInitialColor(code);
    }
    return this;
}

floyder avatar Jun 27 '24 19:06 floyder