use of android.graphics.ColorFilter 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 android.graphics.ColorFilter in project Shuttle by timusus.
the class DrawableUtils method getColoredDrawable.
/**
* Takes a drawable and applies the passed in color to it
*
* @param baseDrawable the drawable to theme
* @return a themed {@link android.graphics.drawable.Drawable}
*/
public static Drawable getColoredDrawable(Drawable baseDrawable, int color) {
if (baseDrawable == null) {
return null;
}
ColorFilter colorFilter = new LightingColorFilter(color, 0);
baseDrawable.mutate().setColorFilter(colorFilter);
return baseDrawable;
}
use of android.graphics.ColorFilter in project Shuttle by timusus.
the class DrawableUtils method getColoredDrawable.
/**
* Takes a drawable resource and applies the current theme highlight color to it
*
* @param baseDrawableResId the resource id of the drawable to theme
* @return a themed {@link android.graphics.drawable.Drawable}
*/
public static Drawable getColoredDrawable(Context context, int baseDrawableResId) {
Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId).getConstantState().newDrawable();
ColorFilter highlightColorFilter = new LightingColorFilter(ColorUtils.getPrimaryColor(), 0);
baseDrawable.mutate().setColorFilter(highlightColorFilter);
return baseDrawable;
}
use of android.graphics.ColorFilter in project HomeMirror by HannahMitt.
the class MirrorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mirror);
mConfigSettings = new ConfigurationSettings(this);
AlarmReceiver.startMirrorUpdates(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mBirthdayText = (TextView) findViewById(R.id.birthday_text);
mDayText = (TextView) findViewById(R.id.day_text);
mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
mHelloText = (TextView) findViewById(R.id.hello_text);
mWaterPlants = findViewById(R.id.water_plants);
mGroceryList = findViewById(R.id.grocery_list);
mBikeTodayText = (TextView) findViewById(R.id.can_bike);
mStockText = (TextView) findViewById(R.id.stock_text);
mMoodText = (TextView) findViewById(R.id.mood_text);
mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
mNewsHeadline = (TextView) findViewById(R.id.news_headline);
mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
mCountdownText = (TextView) findViewById(R.id.countdown_text);
if (mConfigSettings.invertXKCD()) {
//Negative of XKCD image
float[] colorMatrixNegative = { //red
-1.0f, //red
0, //red
0, //red
0, //red
255, //green
0, //green
-1.0f, //green
0, //green
0, //green
255, //blue
0, //blue
0, //blue
-1.0f, //blue
0, //blue
255, //alpha
0, //alpha
0, //alpha
0, //alpha
1.0f, //alpha
0 };
ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
// not inverting for now
mXKCDImage.setColorFilter(colorFilterNegative);
}
setViewState();
}
use of android.graphics.ColorFilter in project AndroidChromium by JackyAndroid.
the class CardUnmaskPrompt method setInputError.
/**
* Sets the error message on the cvc input.
* @param message The error message to show, or null if the error state should be cleared.
*/
private void setInputError(String message) {
mErrorMessage.setText(message);
mErrorMessage.setVisibility(message == null ? View.GONE : View.VISIBLE);
// Announcing twice in a row may cancel the first announcement.
if (message != null) {
mErrorMessage.announceForAccessibility(message);
}
// draw the TextInput.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return;
ColorFilter filter = null;
if (message != null) {
filter = new PorterDuffColorFilter(ApiCompatibilityUtils.getColor(mDialog.getContext().getResources(), R.color.input_underline_error_color), PorterDuff.Mode.SRC_IN);
}
// TODO(estade): it would be nicer if the error were specific enough to tell us which input
// was invalid.
updateColorForInput(mCardUnmaskInput, filter);
updateColorForInput(mMonthInput, filter);
updateColorForInput(mYearInput, filter);
}
Aggregations