Search in sources :

Example 1 with ColorPickerClickListener

use of com.flask.colorpicker.builder.ColorPickerClickListener 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

Dialog (android.app.Dialog)1 DialogInterface (android.content.DialogInterface)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 OnColorSelectedListener (com.flask.colorpicker.OnColorSelectedListener)1 ColorPickerClickListener (com.flask.colorpicker.builder.ColorPickerClickListener)1 ColorPickerDialogBuilder (com.flask.colorpicker.builder.ColorPickerDialogBuilder)1