use of android.graphics.LightingColorFilter in project Shuttle by timusus.
the class DrawableUtils method getColoredFastScrollDrawable.
/**
* @return an {@link FilterableStateListDrawable} representing the themed FastScroll thumb
*/
public static Drawable getColoredFastScrollDrawable(Context context, boolean dontTint) {
ColorFilter highlightColorFilter;
if (dontTint) {
highlightColorFilter = new LightingColorFilter(context.getResources().getColor(R.color.white), 0);
} else {
highlightColorFilter = new LightingColorFilter(ColorUtils.getAccentColor(), 0);
}
FilterableStateListDrawable stateListDrawable = new FilterableStateListDrawable();
if (ShuttleUtils.hasLollipopMR1()) {
stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, CompatUtils.getDrawableCompat(context, R.drawable.fastscroll_thumb_material), highlightColorFilter);
stateListDrawable.addState(StateSet.WILD_CARD, CompatUtils.getDrawableCompat(context, (R.drawable.fastscroll_thumb_material)), highlightColorFilter);
} else if (ShuttleUtils.hasLollipop()) {
stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, context.getResources().getDrawable(R.drawable.fastscroll_thumb_mtrl_alpha), highlightColorFilter);
stateListDrawable.addState(StateSet.WILD_CARD, CompatUtils.getDrawableCompat(context, (R.drawable.fastscroll_thumb_mtrl_alpha)), highlightColorFilter);
} else {
stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, context.getResources().getDrawable(R.drawable.fastscroll_thumb_pressed), highlightColorFilter);
stateListDrawable.addState(StateSet.WILD_CARD, CompatUtils.getDrawableCompat(context, (R.drawable.fastscroll_thumb_default)), highlightColorFilter);
}
return stateListDrawable;
}
use of android.graphics.LightingColorFilter in project Shuttle by timusus.
the class DrawableUtils method getWhiteDrawable.
/**
* Takes a drawable resource and turns it white
*
* @param baseDrawableResId the resource id of the drawable to theme
* @return a themed {@link android.graphics.drawable.Drawable}
*/
public static Drawable getWhiteDrawable(Context context, int baseDrawableResId) {
if (context == null) {
return null;
}
Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId).getConstantState().newDrawable();
ColorFilter colorFilter = new LightingColorFilter(context.getResources().getColor(R.color.white), 0);
baseDrawable.mutate().setColorFilter(colorFilter);
return baseDrawable;
}
use of android.graphics.LightingColorFilter in project Shuttle by timusus.
the class DrawableUtils method getColoredStateListDrawable.
/**
* Returns a {@link FilterableStateListDrawable}, coloring the passed in
* drawable according to the theme and the passed in highlight color
*
* @param baseDrawable the drawable to use
* @return an {@link FilterableStateListDrawable}, coloring the passed in
* drawable according to the theme and the passed in highlight color
*/
public static Drawable getColoredStateListDrawable(Context context, Drawable baseDrawable, int highlightColor) {
if (baseDrawable == null) {
return null;
}
Drawable highlightDrawable = baseDrawable.getConstantState().newDrawable();
ColorFilter baseColorFilter = new LightingColorFilter(highlightColor, 0);
ColorFilter highlightColorFilter = new LightingColorFilter(ColorUtils.getAccentColor(), 0);
FilterableStateListDrawable filterableStateListDrawable = new FilterableStateListDrawable();
filterableStateListDrawable.addState(new int[] { android.R.attr.state_pressed }, baseDrawable, highlightColorFilter);
filterableStateListDrawable.addState(StateSet.WILD_CARD, highlightDrawable, baseColorFilter);
return filterableStateListDrawable;
}
use of android.graphics.LightingColorFilter in project Shuttle by timusus.
the class DrawableUtils method getBlackDrawable.
/**
* Takes a drawable resource and turns it black
*
* @param baseDrawableResId the resource id of the drawable to theme
* @return a themed {@link android.graphics.drawable.Drawable}
*/
public static Drawable getBlackDrawable(Context context, int baseDrawableResId) {
Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId).getConstantState().newDrawable();
ColorFilter colorFilter = new LightingColorFilter(context.getResources().getColor(R.color.black), 0);
baseDrawable.mutate().setColorFilter(colorFilter);
return baseDrawable;
}
use of android.graphics.LightingColorFilter in project Shuttle by timusus.
the class DrawableUtils method getColoredStateListDrawable.
/**
* Returns a {@link FilterableStateListDrawable}, coloring the passed in
* drawable according to the theme and the passed in highlight color
*
* @param baseDrawable the drawable to use
* @return an {@link FilterableStateListDrawable}, coloring the passed in
* drawable according to the theme and the passed in highlight color
*/
public static Drawable getColoredStateListDrawable(Context context, Drawable baseDrawable) {
if (baseDrawable == null) {
return null;
}
Drawable highlightDrawable = baseDrawable.getConstantState().newDrawable();
int baseColor;
if ((ThemeUtils.getInstance().themeType == ThemeUtils.ThemeType.TYPE_DARK) || (ThemeUtils.getInstance().themeType == ThemeUtils.ThemeType.TYPE_SOLID_DARK) || (ThemeUtils.getInstance().themeType == ThemeUtils.ThemeType.TYPE_SOLID_BLACK)) {
baseColor = context.getResources().getColor(R.color.drawable_base_color_dark);
} else {
baseColor = context.getResources().getColor(R.color.drawable_base_color_light);
}
ColorFilter baseColorFilter = new LightingColorFilter(baseColor, 0);
ColorFilter highlightColorFilter = new LightingColorFilter(ColorUtils.getAccentColor(), 0);
FilterableStateListDrawable filterableStateListDrawable = new FilterableStateListDrawable();
filterableStateListDrawable.addState(new int[] { android.R.attr.state_pressed }, baseDrawable, highlightColorFilter);
filterableStateListDrawable.addState(StateSet.WILD_CARD, highlightDrawable, baseColorFilter);
return filterableStateListDrawable;
}
Aggregations