Search in sources :

Example 1 with ColorViewButton

use of net.margaritov.preference.colorpicker.widget.ColorViewButton in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ColorPickerFragment method setUpFavoriteColorButtons.

private void setUpFavoriteColorButtons() {
    mShowFavorites = getShowFavorites();
    TypedArray ta = mResources.obtainTypedArray(R.array.color_picker_favorite_color_buttons);
    for (int i = 0; i < 4; i++) {
        int resId = ta.getResourceId(i, 0);
        int buttonNumber = i + 1;
        String tag = String.valueOf(buttonNumber);
        ColorViewButton button = (ColorViewButton) mColorPickerView.findViewById(resId);
        button.setTag(tag);
        button.setBorderColor(mBorderColor);
        button.setOnLongClickListener(this);
        if (getFavoriteButtonValue(button) != 0) {
            button.setColor(getFavoriteButtonValue(button));
            button.setOnClickListener(this);
        } else {
            button.setShowFavoriteIcon(true);
        }
    }
    ta.recycle();
    mFavoritesLayout.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            mFavoritesLayoutHeight = mFavoritesLayout.getHeight() + mResources.getDimensionPixelSize(R.dimen.color_picker_color_buttons_container_margin_bottom);
            mFavoritesLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            if (!mShowFavorites) {
                int childCount = mColorButtonsLayout.getChildCount();
                for (int i = 0; i < childCount; i++) {
                    if (i == 0) {
                        mFavoritesLayout.setAlpha(0f);
                    } else {
                        View child = mColorButtonsLayout.getChildAt(i);
                        child.setTranslationY(0 - mFavoritesLayoutHeight);
                    }
                }
            }
        }
    });
}
Also used : TypedArray(android.content.res.TypedArray) ColorViewButton(net.margaritov.preference.colorpicker.widget.ColorViewButton) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ColorPickerView(net.margaritov.preference.colorpicker.widget.ColorPickerView) View(android.view.View) ApplyColorView(net.margaritov.preference.colorpicker.widget.ApplyColorView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView)

Example 2 with ColorViewButton

use of net.margaritov.preference.colorpicker.widget.ColorViewButton in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ColorPickerFragment method setUpPaletteColorButtons.

private void setUpPaletteColorButtons() {
    TypedArray layouts = mResources.obtainTypedArray(R.array.color_picker_palette_color_buttons_layouts);
    TypedArray buttons = mResources.obtainTypedArray(R.array.color_picker_palette_color_buttons);
    TypedArray colors = mResources.obtainTypedArray(R.array.color_picker_palette);
    for (int i = 0; i < 3; i++) {
        int layoutResId = layouts.getResourceId(i, 0);
        LinearLayout layout = (LinearLayout) mColorPickerView.findViewById(layoutResId);
        TextView paletteTitle = (TextView) layout.findViewById(R.id.palette_color_buttons_title);
        int titleResId = R.string.palette_title;
        if (i == PALETTE_MATERIAL) {
            titleResId = R.string.palette_material_title;
            colors = mResources.obtainTypedArray(R.array.color_picker_material_palette);
        } else if (i == PALETTE_RGB) {
            titleResId = R.string.palette_rgb_title;
            colors = mResources.obtainTypedArray(R.array.color_picker_rgb_palette);
        }
        paletteTitle.setText(titleResId);
        for (int j = 0; j < 8; j++) {
            int buttonResId = buttons.getResourceId(j, 0);
            ColorViewButton button = (ColorViewButton) layout.findViewById(buttonResId);
            button.setColor(mResources.getColor(colors.getResourceId(j, 0)));
            button.setBorderColor(mBorderColor);
            button.setOnClickListener(this);
        }
    }
    layouts.recycle();
    buttons.recycle();
    colors.recycle();
}
Also used : TypedArray(android.content.res.TypedArray) ColorViewButton(net.margaritov.preference.colorpicker.widget.ColorViewButton) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) LinearLayout(android.widget.LinearLayout)

Example 3 with ColorViewButton

use of net.margaritov.preference.colorpicker.widget.ColorViewButton in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ColorPickerFragment method onLongClick.

@Override
public boolean onLongClick(View v) {
    ColorViewButton button = (ColorViewButton) v;
    if (!v.hasOnClickListeners()) {
        button.setOnClickListener(this);
    }
    button.setShowFavoriteIcon(false);
    button.setColor(mApplyColorAction.getColor());
    writeFavoriteButtonValue(button);
    return true;
}
Also used : ColorViewButton(net.margaritov.preference.colorpicker.widget.ColorViewButton)

Aggregations

ColorViewButton (net.margaritov.preference.colorpicker.widget.ColorViewButton)3 TypedArray (android.content.res.TypedArray)2 CheckedTextView (android.widget.CheckedTextView)2 TextView (android.widget.TextView)2 View (android.view.View)1 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)1 LinearLayout (android.widget.LinearLayout)1 ApplyColorView (net.margaritov.preference.colorpicker.widget.ApplyColorView)1 ColorPickerView (net.margaritov.preference.colorpicker.widget.ColorPickerView)1