Search in sources :

Example 1 with OnColorSelectedListener

use of com.flask.colorpicker.OnColorSelectedListener in project Zom-Android by zom.

the class MoreFragment method showColors.

private void showColors() {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
    int selColor = settings.getInt("themeColor", -1);
    ColorPickerDialogBuilder.with(getContext()).setTitle("Choose color").initialColor(selColor).wheelType(ColorPickerView.WHEEL_TYPE.FLOWER).density(12).lightnessSliderOnly().setOnColorSelectedListener(new OnColorSelectedListener() {

        @Override
        public void onColorSelected(int selectedColor) {
        }
    }).setPositiveButton(getString(R.string.ok), new ColorPickerClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
            settings.edit().putInt("themeColor", selectedColor).commit();
            /**
             *                        int textColor = getContrastColor(selectedColor);
             *                        int bgColor = getContrastColor(textColor);
             *
             *                        settings.edit().putInt("themeColorBg",bgColor).commit();
             *                        settings.edit().putInt("themeColorText",textColor).commit();
             */
            MainActivity activity = (MainActivity) getActivity();
            activity.applyStyle();
        }
    }).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    }).build().show();
}
Also used : SharedPreferences(android.content.SharedPreferences) DialogInterface(android.content.DialogInterface) ColorPickerClickListener(com.flask.colorpicker.builder.ColorPickerClickListener) MainActivity(org.awesomeapp.messenger.MainActivity) OnColorSelectedListener(com.flask.colorpicker.OnColorSelectedListener)

Example 2 with OnColorSelectedListener

use of com.flask.colorpicker.OnColorSelectedListener in project MusicDNA by harjot-oberai.

the class SettingsFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    backBtn = (ImageView) view.findViewById(R.id.settings_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    fragTitle = (TextView) view.findViewById(R.id.settings_fragment_title);
    if (SplashActivity.tf4 != null)
        fragTitle.setTypeface(SplashActivity.tf4);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    resetSettings = (RelativeLayout) view.findViewById(R.id.reset_settings_card);
    resetSettings.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final android.app.AlertDialog alertDialog = new android.app.AlertDialog.Builder(view.getContext()).create();
            alertDialog.setTitle("Reset settings?");
            alertDialog.setMessage("This operation will reset all settings but playlist and other content will remain unchanged.");
            alertDialog.setButton(android.app.AlertDialog.BUTTON_POSITIVE, "Reset", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    resetAllSettings();
                    Toast.makeText(getContext(), "Settings have been reset", Toast.LENGTH_LONG).show();
                }
            });
            alertDialog.setButton(android.app.AlertDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            alertDialog.create();
            alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

                @Override
                public void onShow(DialogInterface arg0) {
                    alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setTextColor(HomeActivity.themeColor);
                    alertDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE).setTextColor(HomeActivity.themeColor);
                }
            });
            alertDialog.show();
        }
    });
    densitycard = (RelativeLayout) view.findViewById(R.id.density_card);
    densityText = (TextView) view.findViewById(R.id.density_value);
    densityText.setText(String.valueOf(100 - (int) (homeActivity.minAudioStrength * 100)));
    densitycard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.density_dialog);
            densitySeekbar = (SeekBar) dialog.findViewById(R.id.density_dialog_seekbar);
            densitySeekbar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(homeActivity.themeColor, PorterDuff.Mode.SRC_IN));
            densityTextDialog = (TextView) dialog.findViewById(R.id.density_dialog_value);
            densitySeekbar.setMax(100);
            densitySeekbar.setProgress(Integer.parseInt(densityText.getText().toString()));
            densityTextDialog.setText(String.valueOf(densitySeekbar.getProgress()));
            densitySeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    setHomeActivityDNADensity(progress);
                    densityTextDialog.setText(String.valueOf(progress));
                    densityText.setText(String.valueOf(progress));
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                }
            });
            dialog.show();
        }
    });
    themeCard = (RelativeLayout) view.findViewById(R.id.theme_card);
    themeColorImg = (ImageView) view.findViewById(R.id.theme_color_img);
    themeColorImg.setBackgroundColor(homeActivity.themeColor);
    themeCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog dialog = ColorPickerDialogBuilder.with(getContext()).setTitle("Choose color").initialColor(HomeActivity.themeColor).wheelType(ColorPickerView.WHEEL_TYPE.FLOWER).density(9).showColorPreview(true).lightnessSliderOnly().setOnColorSelectedListener(new OnColorSelectedListener() {

                @Override
                public void onColorSelected(int color) {
                }
            }).setPositiveButton("ok", new ColorPickerClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int color, Integer[] allColors) {
                    setHomeActivityColor(color);
                }
            }).setNegativeButton("cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).build();
            dialog.setOnShowListener(new DialogInterface.OnShowListener() {

                @Override
                public void onShow(DialogInterface dialogInterface) {
                    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(HomeActivity.themeColor);
                    dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(HomeActivity.themeColor);
                }
            });
            dialog.show();
        }
    });
    albumArtCard = (RelativeLayout) view.findViewById(R.id.album_art_card);
    albumArtToggle = (SwitchCompat) view.findViewById(R.id.album_art_toggle);
    albumArtToggle.setChecked(homeActivity.settings.isAlbumArtBackgroundEnabled());
    albumArtCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            albumArtToggle.toggle();
        }
    });
    albumArtToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setHomeActivityAlbumBg(isChecked);
        }
    });
    wifiCard = (RelativeLayout) view.findViewById(R.id.wifi_card);
    wifiToggle = (SwitchCompat) view.findViewById(R.id.wifi_stream_toggle);
    wifiToggle.setChecked(homeActivity.settings.isStreamOnlyOnWifiEnabled());
    wifiCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            wifiToggle.toggle();
        }
    });
    wifiToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setHomeActivityStreamingOnWifi(isChecked);
        }
    });
    aboutCard = (RelativeLayout) view.findViewById(R.id.about_card);
    aboutCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.onAboutClicked();
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) SeekBar(android.widget.SeekBar) DialogInterface(android.content.DialogInterface) ColorPickerDialogBuilder(com.flask.colorpicker.builder.ColorPickerDialogBuilder) ColorPickerClickListener(com.flask.colorpicker.builder.ColorPickerClickListener) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ImageView(android.widget.ImageView) ColorPickerView(com.flask.colorpicker.ColorPickerView) View(android.view.View) TextView(android.widget.TextView) OnColorSelectedListener(com.flask.colorpicker.OnColorSelectedListener) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Aggregations

DialogInterface (android.content.DialogInterface)2 OnColorSelectedListener (com.flask.colorpicker.OnColorSelectedListener)2 ColorPickerClickListener (com.flask.colorpicker.builder.ColorPickerClickListener)2 Dialog (android.app.Dialog)1 SharedPreferences (android.content.SharedPreferences)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 SeekBar (android.widget.SeekBar)1 TextView (android.widget.TextView)1 ColorPickerView (com.flask.colorpicker.ColorPickerView)1 ColorPickerDialogBuilder (com.flask.colorpicker.builder.ColorPickerDialogBuilder)1 MainActivity (org.awesomeapp.messenger.MainActivity)1