Search in sources :

Example 6 with LightingColorFilter

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;
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LightingColorFilter(android.graphics.LightingColorFilter)

Example 7 with LightingColorFilter

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;
}
Also used : ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Example 8 with LightingColorFilter

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;
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Example 9 with LightingColorFilter

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;
}
Also used : ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Example 10 with LightingColorFilter

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;
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Aggregations

LightingColorFilter (android.graphics.LightingColorFilter)32 ColorFilter (android.graphics.ColorFilter)20 Drawable (android.graphics.drawable.Drawable)18 LayerDrawable (android.graphics.drawable.LayerDrawable)17 FilterableStateListDrawable (com.simplecity.amp_library.ui.views.FilterableStateListDrawable)16 ImageView (android.widget.ImageView)5 View (android.view.View)4 Canvas (android.graphics.Canvas)3 TextView (android.widget.TextView)3 Bitmap (android.graphics.Bitmap)2 SearchView (android.support.v7.widget.SearchView)2 LayoutInflater (android.view.LayoutInflater)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Rect (android.graphics.Rect)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1