use of android.graphics.drawable.InsetDrawable in project SublimePicker by vikramkakkar.
the class SUtils method createButtonShape.
// Base button shape
private static Drawable createButtonShape(Context context, int color) {
// Translation of Lollipop's xml button-bg definition to Java
int paddingH = context.getResources().getDimensionPixelSize(R.dimen.button_padding_horizontal_material);
int paddingV = context.getResources().getDimensionPixelSize(R.dimen.button_padding_vertical_material);
int insetH = context.getResources().getDimensionPixelSize(R.dimen.button_inset_horizontal_material);
int insetV = context.getResources().getDimensionPixelSize(R.dimen.button_inset_vertical_material);
float[] outerRadii = new float[8];
Arrays.fill(outerRadii, CORNER_RADIUS);
RoundRectShape r = new RoundRectShape(outerRadii, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(r);
shapeDrawable.getPaint().setColor(color);
shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);
return new InsetDrawable(shapeDrawable, insetH, insetV, insetH, insetV);
}
use of android.graphics.drawable.InsetDrawable in project wire-android by wireapp.
the class AddPhoneNumberPreferenceDialogFragment method clearColorFilter.
// from TextInputLayout
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearColorFilter(@NonNull Drawable drawable) {
drawable.clearColorFilter();
if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) {
// children manually
if (drawable instanceof InsetDrawable) {
clearColorFilter(((InsetDrawable) drawable).getDrawable());
} else if (drawable instanceof DrawableWrapper) {
clearColorFilter(((DrawableWrapper) drawable).getWrappedDrawable());
} else if (drawable instanceof DrawableContainer) {
final DrawableContainer container = (DrawableContainer) drawable;
final DrawableContainer.DrawableContainerState state = (DrawableContainer.DrawableContainerState) container.getConstantState();
if (state != null) {
for (int i = 0, count = state.getChildCount(); i < count; i++) {
clearColorFilter(state.getChild(i));
}
}
}
}
}
Aggregations