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);
}
}
}
}
});
}
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();
}
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;
}
Aggregations