Search in sources :

Example 46 with Drawable

use of android.graphics.drawable.Drawable in project Shuttle by timusus.

the class ThemeUtils method themeContextualActionBar.

public static void themeContextualActionBar(Activity activity) {
    if (activity != null) {
        View v = activity.findViewById(R.id.action_mode_bar);
        if (v != null) {
            Drawable bottom = CompatUtils.getDrawableCompat(activity, R.drawable.abc_cab_background_top_mtrl_alpha);
            if (bottom != null) {
                bottom.setColorFilter(ColorUtils.getAccentColor(), PorterDuff.Mode.SRC_ATOP);
            }
            Drawable background = new ColorDrawable(ColorUtils.getPrimaryColorDark(activity));
            LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { background, bottom });
            v.setBackgroundDrawable(layerDrawable);
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) HmsView(com.doomonafireball.betterpickers.hmspicker.HmsView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView)

Example 47 with Drawable

use of android.graphics.drawable.Drawable in project Shuttle by timusus.

the class ThemeUtils method themeActionBar.

@SuppressLint("NewApi")
public static Drawable themeActionBar(AppCompatActivity activity) {
    if (activity == null) {
        return null;
    }
    if (ShuttleUtils.hasLollipop()) {
        Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
        if (bitmap != null) {
            ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bitmap, ColorUtils.getPrimaryColor());
            activity.setTaskDescription(td);
            bitmap.recycle();
        }
    }
    if (ThemeUtils.getInstance().themeType == ThemeType.TYPE_LIGHT || ThemeUtils.getInstance().themeType == ThemeType.TYPE_DARK) {
        activity.getSupportActionBar().setBackgroundDrawable(DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.ab_transparent)));
    }
    if (activity instanceof MainActivity || isActionBarSolid(activity)) {
        ActionBar actionBar = activity.getSupportActionBar();
        Drawable actionBarDrawable = DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.action_bar_bg));
        actionBar.setBackgroundDrawable(actionBarDrawable);
        return actionBarDrawable;
    }
    return null;
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ActivityManager(android.app.ActivityManager) ActionBar(android.support.v7.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 48 with Drawable

use of android.graphics.drawable.Drawable 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 49 with Drawable

use of android.graphics.drawable.Drawable 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 50 with Drawable

use of android.graphics.drawable.Drawable 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

Drawable (android.graphics.drawable.Drawable)2742 BitmapDrawable (android.graphics.drawable.BitmapDrawable)527 View (android.view.View)316 ColorDrawable (android.graphics.drawable.ColorDrawable)283 Bitmap (android.graphics.Bitmap)244 ImageView (android.widget.ImageView)232 TextView (android.widget.TextView)220 Paint (android.graphics.Paint)213 LayerDrawable (android.graphics.drawable.LayerDrawable)212 Rect (android.graphics.Rect)204 StateListDrawable (android.graphics.drawable.StateListDrawable)152 Resources (android.content.res.Resources)143 AnimationDrawable (android.graphics.drawable.AnimationDrawable)137 PackageManager (android.content.pm.PackageManager)127 Context (android.content.Context)126 TypedArray (android.content.res.TypedArray)115 ClipDrawable (android.graphics.drawable.ClipDrawable)108 ViewGroup (android.view.ViewGroup)100 Test (org.junit.Test)100 ShapeDrawable (android.graphics.drawable.ShapeDrawable)94