use of android.support.annotation.ColorInt in project material-dialogs by afollestad.
the class CircleView method translucentColor.
@ColorInt
private static int translucentColor(int color) {
final float factor = 0.7f;
int alpha = Math.round(Color.alpha(color) * factor);
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
return Color.argb(alpha, red, green, blue);
}
use of android.support.annotation.ColorInt in project material-dialogs by afollestad.
the class ColorChooserDialog method getSelectedColor.
@ColorInt
private int getSelectedColor() {
if (colorChooserCustomFrame != null && colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
return selectedCustomColor;
}
int color = 0;
if (subIndex() > -1) {
color = colorsSub[topIndex()][subIndex()];
} else if (topIndex() > -1) {
color = colorsTop[topIndex()];
}
if (color == 0) {
int fallback = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
}
color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
}
return color;
}
use of android.support.annotation.ColorInt in project k-9 by k9mail.
the class CryptoInfoDialog method setMessageSingleLine.
private void setMessageSingleLine(@AttrRes int colorAttr, @StringRes int topTextRes, @DrawableRes int statusIconRes, @DrawableRes Integer statusDotsRes) {
@ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);
topIcon_1.setImageResource(statusIconRes);
topIcon_1.setColorFilter(color);
topText.setText(topTextRes);
if (statusDotsRes != null) {
topIcon_3.setImageResource(statusDotsRes);
topIcon_3.setColorFilter(color);
topIcon_3.setVisibility(View.VISIBLE);
} else {
topIcon_3.setVisibility(View.GONE);
}
bottomText.setVisibility(View.GONE);
bottomIconFrame.setVisibility(View.GONE);
}
use of android.support.annotation.ColorInt in project FlexibleAdapter by davideas.
the class DrawableUtils method getColorControlHighlight.
/**
* Helper to get the system default Color Control Highlight. Returns the color of the
* {@code R.attr.colorControlHighlight} attribute in the overridden style.
*
* @param context the context
* @return Default Color Control Highlight
* @since 5.0.0-b7 Created, returns the resourceId
* <br/> 5.0.0-rc1 Now returns the real color (not the resourceId)
*/
@ColorInt
public static int getColorControlHighlight(Context context) {
TypedValue outValue = new TypedValue();
// It's important to not use the android.R because this wouldn't add the overridden drawable
context.getTheme().resolveAttribute(R.attr.colorControlHighlight, outValue, true);
if (Utils.hasMarshmallow())
return context.getColor(outValue.resourceId);
else
return context.getResources().getColor(outValue.resourceId);
}
use of android.support.annotation.ColorInt in project Lightning-Browser by anthonycr.
the class ThemeUtils method getColor.
/**
* Gets the color attribute from the current theme.
*
* @param context the context to get the theme from.
* @param resource the color attribute resource.
* @return the color for the given attribute.
*/
@ColorInt
public static int getColor(@NonNull Context context, @AttrRes int resource) {
TypedArray a = context.obtainStyledAttributes(sTypedValue.data, new int[] { resource });
int color = a.getColor(0, 0);
a.recycle();
return color;
}
Aggregations