Search in sources :

Example 1 with ChooseaccentBinding

use of me.ccrama.redditslide.databinding.ChooseaccentBinding in project Slide by ccrama.

the class SettingsThemeFragment method setupSettingsThemeAccent.

private void setupSettingsThemeAccent() {
    final LinearLayout accentLayout = (LinearLayout) context.findViewById(R.id.settings_theme_accent);
    accentLayout.setOnClickListener(v -> {
        final ChooseaccentBinding chooseaccentBinding = ChooseaccentBinding.inflate(context.getLayoutInflater());
        final TextView title = chooseaccentBinding.title;
        title.setBackgroundColor(Palette.getDefaultColor());
        final LineColorPicker colorPicker = chooseaccentBinding.picker3;
        int[] arrs = new int[ColorPreferences.getNumColorsFromThemeType(0)];
        int i = 0;
        for (ColorPreferences.Theme type : ColorPreferences.Theme.values()) {
            if (type.getThemeType() == ColorPreferences.ColorThemeOptions.Dark.getValue()) {
                arrs[i] = ContextCompat.getColor(context, type.getColor());
                i++;
            }
        }
        colorPicker.setColors(arrs);
        colorPicker.setSelectedColor(ContextCompat.getColor(context, new ColorPreferences(context).getFontStyle().getColor()));
        chooseaccentBinding.ok.setOnClickListener(v1 -> {
            SettingsThemeFragment.changed = true;
            int color = colorPicker.getColor();
            ColorPreferences.Theme t = null;
            for (ColorPreferences.Theme type : ColorPreferences.Theme.values()) {
                if (ContextCompat.getColor(context, type.getColor()) == color && back == type.getThemeType()) {
                    t = type;
                    LogUtil.v("Setting to " + t.getTitle());
                    break;
                }
            }
            new ColorPreferences(context).setFontStyle(t);
            context.restartActivity();
        });
        new AlertDialog.Builder(context).setView(chooseaccentBinding.getRoot()).show();
    });
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) ChooseaccentBinding(me.ccrama.redditslide.databinding.ChooseaccentBinding) LineColorPicker(uz.shift.colorpicker.LineColorPicker)

Aggregations

LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)1 ChooseaccentBinding (me.ccrama.redditslide.databinding.ChooseaccentBinding)1 LineColorPicker (uz.shift.colorpicker.LineColorPicker)1