Search in sources :

Example 6 with FilterableStateListDrawable

use of com.simplecity.amp_library.ui.views.FilterableStateListDrawable in project Shuttle by timusus.

the class DrawableUtils method getColoredStateListDrawableWithThemeType.

/**
     * Returns a {@link FilterableStateListDrawable}, coloring the passed in
     * drawable according to the theme and the passed in highlight color
     *
     * @param baseDrawableResId 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 getColoredStateListDrawableWithThemeType(Context context, int baseDrawableResId, @ThemeUtils.ThemeType int themeType) {
    Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId);
    Drawable highlightDrawable = baseDrawable.getConstantState().newDrawable();
    int baseColor;
    if ((themeType == ThemeUtils.ThemeType.TYPE_DARK) || (themeType == ThemeUtils.ThemeType.TYPE_SOLID_DARK) || (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.getPrimaryColor(), 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 7 with FilterableStateListDrawable

use of com.simplecity.amp_library.ui.views.FilterableStateListDrawable 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 baseDrawableResId 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, int baseDrawableResId) {
    Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId);
    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)

Example 8 with FilterableStateListDrawable

use of com.simplecity.amp_library.ui.views.FilterableStateListDrawable in project Shuttle by timusus.

the class DrawableUtils method getColoredStateListDrawableWithThemeColor.

/**
     * 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 getColoredStateListDrawableWithThemeColor(Context context, Drawable baseDrawable, @ThemeUtils.ThemeColor int color) {
    if (baseDrawable == null) {
        return null;
    }
    Drawable highlightDrawable = baseDrawable.getConstantState().newDrawable();
    int baseColor;
    if (color == ThemeUtils.WHITE) {
        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);
    int accentColor = ColorUtils.getAccentColor();
    if (accentColor == ColorUtils.getPrimaryColor()) {
        accentColor = Color.WHITE;
    }
    ColorFilter highlightColorFilter = new LightingColorFilter(accentColor, 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 FilterableStateListDrawable

use of com.simplecity.amp_library.ui.views.FilterableStateListDrawable in project Shuttle by timusus.

the class DrawableUtils method getColoredStateListDrawableWithThemeColor.

/**
     * Returns a {@link FilterableStateListDrawable}, coloring the passed in
     * drawable according to the theme and the passed in highlight color
     *
     * @param baseDrawableResId 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 getColoredStateListDrawableWithThemeColor(Context context, int baseDrawableResId, @ThemeUtils.ThemeColor int color) {
    if (context == null) {
        return null;
    }
    Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId);
    Drawable highlightDrawable = baseDrawable.getConstantState().newDrawable();
    int baseColor;
    if (color == ThemeUtils.WHITE) {
        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);
    int accentColor = ColorUtils.getAccentColor();
    if (accentColor == ColorUtils.getPrimaryColor()) {
        accentColor = Color.WHITE;
    }
    ColorFilter highlightColorFilter = new LightingColorFilter(accentColor, 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 10 with FilterableStateListDrawable

use of com.simplecity.amp_library.ui.views.FilterableStateListDrawable in project Shuttle by timusus.

the class DrawableUtils method getSwitchTrackDrawable.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Drawable getSwitchTrackDrawable(Context context) {
    // if (ShuttleUtils.hasAndroidLPreview()) {
    //Todo: Add color states (need method to determine accent color)
    Drawable offState = context.getResources().getDrawable(R.drawable.switch_track_mtrl_alpha);
    offState.setAlpha(1);
    Drawable onState = context.getResources().getDrawable(R.drawable.switch_track_mtrl_alpha);
    onState.setAlpha(1);
    Drawable otherState = context.getResources().getDrawable(R.drawable.switch_track_mtrl_alpha);
    offState.setAlpha(1);
    FilterableStateListDrawable filterableStateListDrawable = new FilterableStateListDrawable();
    filterableStateListDrawable.addState(new int[] { -android.R.attr.enabled }, offState, null);
    filterableStateListDrawable.addState(new int[] { android.R.attr.state_checked }, onState, null);
    filterableStateListDrawable.addState(StateSet.WILD_CARD, otherState, null);
    //Todo: Make filterableStateListDrawable take alpha values for individual drawables
    filterableStateListDrawable.setAlpha(255 / 3);
    return filterableStateListDrawable;
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) TargetApi(android.annotation.TargetApi)

Aggregations

FilterableStateListDrawable (com.simplecity.amp_library.ui.views.FilterableStateListDrawable)10 ColorFilter (android.graphics.ColorFilter)9 LightingColorFilter (android.graphics.LightingColorFilter)9 Drawable (android.graphics.drawable.Drawable)8 LayerDrawable (android.graphics.drawable.LayerDrawable)8 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)1 AppCompatEditText (android.support.v7.widget.AppCompatEditText)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 HmsView (com.doomonafireball.betterpickers.hmspicker.HmsView)1 Field (java.lang.reflect.Field)1