use of android.graphics.drawable.RippleDrawable in project GreenHouse by utsanjan.
the class DropdownMenuEndIconDelegate method addRippleEffectOnFilledLayout.
private void addRippleEffectOnFilledLayout(AutoCompleteTextView editText, int rippleColor, int[][] states, MaterialShapeDrawable boxBackground) {
int boxBackgroundColor = this.textInputLayout.getBoxBackgroundColor();
int pressedBackgroundColor = MaterialColors.layer(rippleColor, boxBackgroundColor, 0.1f);
int[] colors = { pressedBackgroundColor, boxBackgroundColor };
if (IS_LOLLIPOP) {
ColorStateList rippleColorStateList = new ColorStateList(states, colors);
Drawable editTextBackground = new RippleDrawable(rippleColorStateList, boxBackground, boxBackground);
ViewCompat.setBackground(editText, editTextBackground);
return;
}
MaterialShapeDrawable rippleBackground = new MaterialShapeDrawable(boxBackground.getShapeAppearanceModel());
rippleBackground.setFillColor(new ColorStateList(states, colors));
Drawable[] layers = { boxBackground, rippleBackground };
LayerDrawable editTextBackground2 = new LayerDrawable(layers);
int start = ViewCompat.getPaddingStart(editText);
int top = editText.getPaddingTop();
int end = ViewCompat.getPaddingEnd(editText);
int bottom = editText.getPaddingBottom();
ViewCompat.setBackground(editText, editTextBackground2);
ViewCompat.setPaddingRelative(editText, start, top, end, bottom);
}
use of android.graphics.drawable.RippleDrawable in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListDrawableFactory method createHeaderBackgroundDrawable.
/**
* Creates a drawable for widget header list items. This drawable supports all positions
* in {@link WidgetsListDrawableState}.
*/
Drawable createHeaderBackgroundDrawable() {
StateListDrawable stateList = new StateListDrawable();
stateList.addState(SINGLE.mStateSet, createRoundedRectDrawable(mTopBottomCornerRadius, mTopBottomCornerRadius));
stateList.addState(FIRST_EXPANDED.mStateSet, createRoundedRectDrawable(mTopBottomCornerRadius, 0));
stateList.addState(FIRST.mStateSet, createRoundedRectDrawable(mTopBottomCornerRadius, mMiddleCornerRadius));
stateList.addState(MIDDLE_EXPANDED.mStateSet, createRoundedRectDrawable(mMiddleCornerRadius, 0));
stateList.addState(MIDDLE.mStateSet, createRoundedRectDrawable(mMiddleCornerRadius, mMiddleCornerRadius));
stateList.addState(LAST.mStateSet, createRoundedRectDrawable(mMiddleCornerRadius, mTopBottomCornerRadius));
return new RippleDrawable(mRippleColor, /* content= */
stateList, /* mask= */
stateList);
}
use of android.graphics.drawable.RippleDrawable in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListDrawableFactory method createContentBackgroundDrawable.
/**
* Creates a drawable for widget content list items. This state list supports the middle and
* last states.
*/
Drawable createContentBackgroundDrawable() {
StateListDrawable stateList = new StateListDrawable();
stateList.addState(MIDDLE.mStateSet, createRoundedRectDrawable(0, mMiddleCornerRadius));
stateList.addState(LAST.mStateSet, createRoundedRectDrawable(0, mTopBottomCornerRadius));
return new RippleDrawable(mRippleColor, /* content= */
stateList, /* mask= */
stateList);
}
use of android.graphics.drawable.RippleDrawable in project PhotoNoter by yydcdut.
the class ColorChooserDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View v = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_color_chooser, null);
AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.note_dialog).setTitle(R.string.color_chooser).setCancelable(true).setView(v).create();
final TypedArray ta = getActivity().getResources().obtainTypedArray(R.array.colors);
mColors = new int[ta.length()];
for (int i = 0; i < ta.length(); i++) {
mColors[i] = ta.getColor(i, 0);
}
ta.recycle();
final GridLayout list = (GridLayout) v.findViewById(R.id.grid);
final int preselect = getArguments().getInt("preselect", -1);
for (int i = 0; i < mColors.length; i++) {
FrameLayout child = (FrameLayout) list.getChildAt(i);
child.setTag(i);
child.setOnClickListener(this);
child.getChildAt(0).setVisibility(preselect == i ? View.VISIBLE : View.GONE);
Drawable selector = createSelector(mColors[i]);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[][] states = new int[][] { new int[] { -android.R.attr.state_pressed }, new int[] { android.R.attr.state_pressed } };
int[] colors = new int[] { shiftColor(mColors[i]), mColors[i] };
ColorStateList rippleColors = new ColorStateList(states, colors);
setBackgroundCompat(child, new RippleDrawable(rippleColors, selector, null));
} else {
setBackgroundCompat(child, selector);
}
}
return dialog;
}
use of android.graphics.drawable.RippleDrawable in project LuaViewSDK by alibaba.
the class ForegroundDelegate method setupForeground.
private static void setupForeground(View view, Drawable drawable, Integer color, Integer alpha) {
if (view instanceof IForeground) {
if (color != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
if (drawable instanceof RippleDrawable) {
RippleDrawable rippleDrawable = (RippleDrawable) drawable;
rippleDrawable.setColor(ColorStateList.valueOf(color));
if (alpha != null) {
rippleDrawable.setAlpha(alpha);
}
}
}
}
((IForeground) view).setForeground(drawable);
}
}
Aggregations