Search in sources :

Example 6 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 7 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 8 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 9 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 10 with ColorInt

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

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