Search in sources :

Example 66 with RippleDrawable

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);
}
Also used : MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) MaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) ColorStateList(android.content.res.ColorStateList) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 67 with RippleDrawable

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);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 68 with RippleDrawable

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);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 69 with RippleDrawable

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;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) GridLayout(android.widget.GridLayout) TypedArray(android.content.res.TypedArray) FrameLayout(android.widget.FrameLayout) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) ColorStateList(android.content.res.ColorStateList) View(android.view.View) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 70 with RippleDrawable

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);
    }
}
Also used : RippleDrawable(android.graphics.drawable.RippleDrawable)

Aggregations

RippleDrawable (android.graphics.drawable.RippleDrawable)115 StateListDrawable (android.graphics.drawable.StateListDrawable)60 Drawable (android.graphics.drawable.Drawable)49 ColorStateList (android.content.res.ColorStateList)47 GradientDrawable (android.graphics.drawable.GradientDrawable)30 TargetApi (android.annotation.TargetApi)26 ShapeDrawable (android.graphics.drawable.ShapeDrawable)23 View (android.view.View)21 Paint (android.graphics.Paint)20 ColorDrawable (android.graphics.drawable.ColorDrawable)20 SuppressLint (android.annotation.SuppressLint)15 TextView (android.widget.TextView)15 FrameLayout (android.widget.FrameLayout)12 LayerDrawable (android.graphics.drawable.LayerDrawable)11 ImageView (android.widget.ImageView)11 RLottieDrawable (org.telegram.ui.Components.RLottieDrawable)11 CombinedDrawable (org.telegram.ui.Components.CombinedDrawable)10 ScamDrawable (org.telegram.ui.Components.ScamDrawable)10 Outline (android.graphics.Outline)9 BitmapDrawable (android.graphics.drawable.BitmapDrawable)9