use of android.support.design.widget.TextInputEditText in project Shuttle by timusus.
the class TintHelper method setTintAuto.
@SuppressWarnings("deprecation")
@SuppressLint("PrivateResource")
static void setTintAuto(@NonNull final View view, @ColorInt final int color, boolean background, final boolean isDark) {
if (!background) {
if (view instanceof RadioButton) {
setTint((RadioButton) view, color, isDark);
} else if (view instanceof SeekBar) {
setTint((SeekBar) view, color, isDark);
} else if (view instanceof ProgressBar) {
setTint((ProgressBar) view, color);
} else if (view instanceof EditText) {
setTint((EditText) view, color, isDark);
} else if (view instanceof CheckBox) {
setTint((CheckBox) view, color, isDark);
} else if (view instanceof ImageView) {
setTint((ImageView) view, color);
} else if (view instanceof Switch) {
setTint((Switch) view, color, isDark);
} else if (view instanceof SwitchCompat) {
setTint((SwitchCompat) view, color, isDark);
} else {
background = true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !background && view.getBackground() instanceof RippleDrawable) {
// Ripples for the above views (e.g. when you tap and hold a switch or checkbox)
RippleDrawable rd = (RippleDrawable) view.getBackground();
final int unchecked = ContextCompat.getColor(view.getContext(), isDark ? R.color.ripple_material_dark : R.color.ripple_material_light);
final int checked = Util.adjustAlpha(color, 0.4f);
final ColorStateList sl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_activated, -android.R.attr.state_checked }, new int[] { android.R.attr.state_activated }, new int[] { android.R.attr.state_checked } }, new int[] { unchecked, checked, checked });
rd.setColor(sl);
}
}
if (background) {
// Need to tint the background of a view
if (view instanceof FloatingActionButton || view instanceof Button) {
setTintSelector(view, color, false, isDark);
} else if (view.getBackground() != null) {
Drawable drawable = view.getBackground();
if (drawable != null) {
if (view instanceof TextInputEditText) {
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
} else {
drawable = createTintedDrawable(drawable, color);
Util.setBackgroundCompat(view, drawable);
}
}
}
}
}
Aggregations