Search in sources :

Example 1 with OnColorChangedListener

use of uz.shift.colorpicker.OnColorChangedListener in project LeafPic by HoraApps.

the class SettingsActivity method primaryColorPiker.

private void primaryColorPiker() {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
    final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_primary, null);
    final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary);
    final LineColorPicker colorPicker2 = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary_2);
    final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_primary_title);
    CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.cp_primary_card);
    dialogCardView.setCardBackgroundColor(getCardBackgroundColor());
    colorPicker.setColors(ColorPalette.getBaseColors(getApplicationContext()));
    for (int i : colorPicker.getColors()) for (int i2 : ColorPalette.getColors(getBaseContext(), i)) if (i2 == getPrimaryColor()) {
        colorPicker.setSelectedColor(i);
        colorPicker2.setColors(ColorPalette.getColors(getBaseContext(), i));
        colorPicker2.setSelectedColor(i2);
        break;
    }
    dialogTitle.setBackgroundColor(getPrimaryColor());
    colorPicker.setOnColorChangedListener(new OnColorChangedListener() {

        @Override
        public void onColorChanged(int c) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (isTranslucentStatusBar()) {
                    getWindow().setStatusBarColor(ColorPalette.getObscuredColor(getPrimaryColor()));
                } else
                    getWindow().setStatusBarColor(c);
            }
            toolbar.setBackgroundColor(c);
            dialogTitle.setBackgroundColor(c);
            colorPicker2.setColors(ColorPalette.getColors(getApplicationContext(), colorPicker.getColor()));
            colorPicker2.setSelectedColor(colorPicker.getColor());
        }
    });
    colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {

        @Override
        public void onColorChanged(int c) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (isTranslucentStatusBar()) {
                    getWindow().setStatusBarColor(ColorPalette.getObscuredColor(c));
                } else
                    getWindow().setStatusBarColor(c);
                if (isNavigationBarColored())
                    getWindow().setNavigationBarColor(c);
                else
                    getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
            }
            toolbar.setBackgroundColor(c);
            dialogTitle.setBackgroundColor(c);
        }
    });
    dialogBuilder.setView(dialogLayout);
    dialogBuilder.setNeutralButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (isTranslucentStatusBar()) {
                    getWindow().setStatusBarColor(ColorPalette.getObscuredColor(getPrimaryColor()));
                } else
                    getWindow().setStatusBarColor(getPrimaryColor());
            }
            toolbar.setBackgroundColor(getPrimaryColor());
            dialog.cancel();
        }
    });
    dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            SP.putInt(getString(R.string.preference_primary_color), colorPicker2.getColor());
            updateTheme();
            setNavBarColor();
            setScrollViewColor(scr);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (isTranslucentStatusBar()) {
                    getWindow().setStatusBarColor(ColorPalette.getObscuredColor(getPrimaryColor()));
                } else {
                    getWindow().setStatusBarColor(getPrimaryColor());
                }
            }
        }
    });
    dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                if (isTranslucentStatusBar()) {
                    getWindow().setStatusBarColor(ColorPalette.getObscuredColor(getPrimaryColor()));
                } else
                    getWindow().setStatusBarColor(getPrimaryColor());
                if (isNavigationBarColored())
                    getWindow().setNavigationBarColor(getPrimaryColor());
                else
                    getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
            }
            toolbar.setBackgroundColor(getPrimaryColor());
        }
    });
    dialogBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) CardView(android.support.v7.widget.CardView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) LineColorPicker(uz.shift.colorpicker.LineColorPicker) OnColorChangedListener(uz.shift.colorpicker.OnColorChangedListener) TextView(android.widget.TextView)

Example 2 with OnColorChangedListener

use of uz.shift.colorpicker.OnColorChangedListener in project LeafPic by HoraApps.

the class SettingsActivity method accentColorPiker.

private void accentColorPiker() {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
    final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_accent, null);
    final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
    final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_accent_title);
    CardView cv = (CardView) dialogLayout.findViewById(R.id.cp_accent_card);
    cv.setCardBackgroundColor(getCardBackgroundColor());
    colorPicker.setColors(ColorPalette.getAccentColors(getApplicationContext()));
    colorPicker.setSelectedColor(getAccentColor());
    dialogTitle.setBackgroundColor(getAccentColor());
    colorPicker.setOnColorChangedListener(new OnColorChangedListener() {

        @Override
        public void onColorChanged(int c) {
            dialogTitle.setBackgroundColor(c);
            updateViewswithAccentColor(colorPicker.getColor());
        }
    });
    dialogBuilder.setView(dialogLayout);
    dialogBuilder.setNeutralButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            updateViewswithAccentColor(getAccentColor());
        }
    });
    dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            SP.putInt(getString(R.string.preference_accent_color), colorPicker.getColor());
            updateTheme();
            updateViewswithAccentColor(getAccentColor());
        }
    });
    dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            updateViewswithAccentColor(getAccentColor());
        }
    });
    dialogBuilder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) CardView(android.support.v7.widget.CardView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) LineColorPicker(uz.shift.colorpicker.LineColorPicker) OnColorChangedListener(uz.shift.colorpicker.OnColorChangedListener) TextView(android.widget.TextView)

Aggregations

DialogInterface (android.content.DialogInterface)2 AlertDialog (android.support.v7.app.AlertDialog)2 CardView (android.support.v7.widget.CardView)2 View (android.view.View)2 ScrollView (android.widget.ScrollView)2 TextView (android.widget.TextView)2 IconicsImageView (com.mikepenz.iconics.view.IconicsImageView)2 LineColorPicker (uz.shift.colorpicker.LineColorPicker)2 OnColorChangedListener (uz.shift.colorpicker.OnColorChangedListener)2