Search in sources :

Example 1 with ColorPickerView

use of com.rarepebble.colorpicker.ColorPickerView in project AnyMemo by helloworld1.

the class SettingsScreen method showColorPickerDialog.

private void showColorPickerDialog() {
    final int spinnerPos = colorSpinner.getSelectedItemPosition();
    Integer currentColor = colors.get(spinnerPos);
    final int defaultTextColor = ContextCompat.getColor(this, android.R.color.primary_text_dark);
    final int defaultBackgroundColor = ContextCompat.getColor(this, android.R.color.background_dark);
    final ColorPickerView colorPickerView = new ColorPickerView(this);
    colorPickerView.showAlpha(false);
    if (currentColor != null) {
        colorPickerView.setColor(currentColor);
    } else if (spinnerPos == QUESTION_TEXT_SPINNER_POS || spinnerPos == ANSWER_TEXT_SPINNER_POS) {
        colorPickerView.setColor(defaultTextColor);
    } else if (spinnerPos == QUESTION_BACKGROUND_SPINNER_POS || spinnerPos == ANSWER_BACKGROUND_SPINNER_POS) {
        colorPickerView.setColor(defaultBackgroundColor);
    }
    new AlertDialog.Builder(this).setTitle(R.string.color_button_text).setView(colorPickerView).setPositiveButton(R.string.ok_text, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            colorButton.setTextColor(colorPickerView.getColor());
            colors.set(spinnerPos, colorPickerView.getColor());
        }
    }).create().show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView)

Example 2 with ColorPickerView

use of com.rarepebble.colorpicker.ColorPickerView in project collect by opendatakit.

the class DrawActivity method setColor.

private void setColor(View view) {
    if (view.getVisibility() == View.VISIBLE) {
        fabActions.performClick();
        final ColorPickerView picker = new ColorPickerView(this);
        picker.setColor(drawView.getColor());
        picker.showAlpha(false);
        picker.showHex(false);
        MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this);
        builder.setView(picker).setPositiveButton(R.string.ok, (dialog, which) -> drawView.setColor(picker.getColor())).show();
    }
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) KeyEvent(android.view.KeyEvent) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Uri(android.net.Uri) WindowManager(android.view.WindowManager) IconMenuListAdapter(org.odk.collect.android.adapters.IconMenuListAdapter) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DialogUtils(org.odk.collect.android.utilities.DialogUtils) ImmutableList(com.google.common.collect.ImmutableList) DrawView(org.odk.collect.android.views.DrawView) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) ActivityInfo(android.content.pm.ActivityInfo) R(org.odk.collect.android.R) View(android.view.View) ImageFileUtils(org.odk.collect.android.utilities.ImageFileUtils) Canvas(android.graphics.Canvas) AnimationUtils(org.odk.collect.android.utilities.AnimationUtils) AdapterView(android.widget.AdapterView) IconMenuItem(org.odk.collect.android.adapters.model.IconMenuItem) CardView(androidx.cardview.widget.CardView) FileOutputStream(java.io.FileOutputStream) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) Timber(timber.log.Timber) List(java.util.List) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) ListView(android.widget.ListView) Activity(android.app.Activity) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView)

Example 3 with ColorPickerView

use of com.rarepebble.colorpicker.ColorPickerView in project WhatsappExtensions by suraj0208.

the class ColorChooserActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_color_chooser);
    Bundle bundle = getIntent().getExtras();
    if (bundle == null) {
        Toast.makeText(getApplicationContext(), R.string.internal_error, Toast.LENGTH_SHORT).show();
        finish();
    }
    final String which = bundle.getString("groupOrIndividual");
    if (which == null) {
        Toast.makeText(getApplicationContext(), R.string.internal_error, Toast.LENGTH_SHORT).show();
        finish();
    }
    SharedPreferences sharedPreferences = Utils.getSharedPreferences(this);
    final ColorPickerView picker = (ColorPickerView) findViewById(R.id.colorPicker);
    picker.setColor(sharedPreferences.getInt(which, Color.GRAY));
    findViewById(R.id.btnColorChooserCancel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ColorChooserActivity.this.finish();
        }
    });
    findViewById(R.id.btnColorChooserOk).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            updateHighlightColor(which, picker.getColor());
            ColorChooserActivity.this.finish();
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) View(android.view.View) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView)

Aggregations

ColorPickerView (com.rarepebble.colorpicker.ColorPickerView)3 Bundle (android.os.Bundle)2 View (android.view.View)2 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1 ActivityInfo (android.content.pm.ActivityInfo)1 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Uri (android.net.Uri)1 KeyEvent (android.view.KeyEvent)1 WindowManager (android.view.WindowManager)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 CardView (androidx.cardview.widget.CardView)1 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)1