use of androidx.annotation.ColorInt in project k-9 by k9mail.
the class CryptoInfoDialog method setMessageSingleLine.
private void setMessageSingleLine(@AttrRes int colorAttr, @StringRes int titleTextRes, @StringRes Integer descTextRes, @DrawableRes int statusIconRes) {
@ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);
statusIcon.setImageResource(statusIconRes);
statusIcon.setColorFilter(color);
titleText.setText(titleTextRes);
if (descTextRes != null) {
descriptionText.setText(descTextRes);
descriptionText.setVisibility(View.VISIBLE);
} else {
descriptionText.setVisibility(View.GONE);
}
}
use of androidx.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;
}
use of androidx.annotation.ColorInt in project AntennaPod by AntennaPod.
the class Timeline method colorToHtml.
private String colorToHtml(Context context, int colorAttr) {
TypedArray res = context.getTheme().obtainStyledAttributes(new int[] { colorAttr });
@ColorInt int col = res.getColor(0, 0);
final String color = "rgba(" + Color.red(col) + "," + Color.green(col) + "," + Color.blue(col) + "," + (Color.alpha(col) / 255.0) + ")";
res.recycle();
return color;
}
use of androidx.annotation.ColorInt in project Conversations by siacs.
the class StylingHelper method makeKeywordOpaque.
private static void makeKeywordOpaque(final Editable editable, int start, int end, @ColorInt int fallbackTextColor) {
QuoteSpan[] quoteSpans = editable.getSpans(start, end, QuoteSpan.class);
@ColorInt int textColor = quoteSpans.length > 0 ? quoteSpans[0].getColor() : fallbackTextColor;
@ColorInt int keywordColor = transformColor(textColor);
editable.setSpan(new ForegroundColorSpan(keywordColor), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
use of androidx.annotation.ColorInt in project FlexibleAdapter by davideas.
the class DrawableUtils method getColorControlHighlight.
/**
* Helper method to get the <i>system (or overridden)</i> default {@code colorControlHighlight}.
* Returns the color of the {@code R.attr.colorControlHighlight} of the style attribute.
*
* @param context the context
* @return Default Color Control Highlight
* @since 1.0.0-b1
*/
@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 (FlexibleUtils.hasMarshmallow()) {
return context.getColor(outValue.resourceId);
} else {
return context.getResources().getColor(outValue.resourceId);
}
}
Aggregations