Search in sources :

Example 1 with ColorInt

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);
}
Also used : TypedValue(android.util.TypedValue) ColorInt(android.support.annotation.ColorInt)

Example 2 with ColorInt

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);
}
Also used : Paint(android.graphics.Paint) ColorInt(android.support.annotation.ColorInt)

Example 3 with ColorInt

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;
}
Also used : SuppressLint(android.annotation.SuppressLint) ColorInt(android.support.annotation.ColorInt)

Example 4 with ColorInt

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);
}
Also used : ColorInt(android.support.annotation.ColorInt) SuppressLint(android.annotation.SuppressLint)

Example 5 with ColorInt

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)));
    }
}
Also used : ColorInt(android.support.annotation.ColorInt) Resources(android.content.res.Resources) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

ColorInt (android.support.annotation.ColorInt)15 Resources (android.content.res.Resources)5 Test (org.junit.Test)5 MediumTest (android.support.test.filters.MediumTest)4 SuppressLint (android.annotation.SuppressLint)2 TypedArray (android.content.res.TypedArray)2 Paint (android.graphics.Paint)2 TestDrawable (android.support.design.testutils.TestDrawable)2 TextView (android.widget.TextView)2 Matcher (org.hamcrest.Matcher)2 Bitmap (android.graphics.Bitmap)1 NavigationViewActions.removeMenuItem (android.support.design.testutils.NavigationViewActions.removeMenuItem)1 NavigationViewActions.setIconForMenuItem (android.support.design.testutils.NavigationViewActions.setIconForMenuItem)1 UiThreadTest (android.support.test.annotation.UiThreadTest)1 SmallTest (android.support.test.filters.SmallTest)1 TypedValue (android.util.TypedValue)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 DiscoveryActivity (com.kickstarter.ui.activities.DiscoveryActivity)1