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 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 material-components-android by material-components.
the class NavigationViewTest method testTextColor.
@Test
public void testTextColor() {
// Open our drawer
onView(withId(R.id.drawer_layout)).perform(openDrawer(GravityCompat.START));
final Resources res = activityTestRule.getActivity().getResources();
@ColorInt final int defaultTextColor = ResourcesCompat.getColor(res, R.color.emerald_text, null);
// Check the default text color of the menu items in our NavigationView
for (int i = 0; i < MENU_CONTENT_ITEM_IDS.length; i++) {
onView(allOf(withText(mMenuStringContent.get(MENU_CONTENT_ITEM_IDS[i])), isDescendantOfA(withId(R.id.start_drawer)))).check(matches(withTextColor(defaultTextColor)));
}
// Set a new text color on our NavigationView
onView(withId(R.id.start_drawer)).perform(setItemTextColor(ResourcesCompat.getColorStateList(res, R.color.color_state_list_lilac, null)));
// And check that all the menu items have the new color
@ColorInt final int newTextColor = ResourcesCompat.getColor(res, R.color.lilac_default, null);
for (int i = 0; i < MENU_CONTENT_ITEM_IDS.length; i++) {
onView(allOf(withText(mMenuStringContent.get(MENU_CONTENT_ITEM_IDS[i])), isDescendantOfA(withId(R.id.start_drawer)))).check(matches(withTextColor(newTextColor)));
}
}
Aggregations