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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations