Search in sources :

Example 41 with ColorFilter

use of android.graphics.ColorFilter in project Shuttle by timusus.

the class DrawableUtils method getColoredStateListDrawableWithThemeColor.

/**
     * Returns a {@link FilterableStateListDrawable}, coloring the passed in
     * drawable according to the theme and the passed in highlight color
     *
     * @param baseDrawableResId the drawable to use
     * @return an {@link FilterableStateListDrawable}, coloring the passed in
     * drawable according to the theme and the passed in highlight color
     */
public static Drawable getColoredStateListDrawableWithThemeColor(Context context, int baseDrawableResId, @ThemeUtils.ThemeColor int color) {
    if (context == null) {
        return null;
    }
    Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId);
    Drawable highlightDrawable = baseDrawable.getConstantState().newDrawable();
    int baseColor;
    if (color == ThemeUtils.WHITE) {
        baseColor = context.getResources().getColor(R.color.drawable_base_color_dark);
    } else {
        baseColor = context.getResources().getColor(R.color.drawable_base_color_light);
    }
    ColorFilter baseColorFilter = new LightingColorFilter(baseColor, 0);
    int accentColor = ColorUtils.getAccentColor();
    if (accentColor == ColorUtils.getPrimaryColor()) {
        accentColor = Color.WHITE;
    }
    ColorFilter highlightColorFilter = new LightingColorFilter(accentColor, 0);
    FilterableStateListDrawable filterableStateListDrawable = new FilterableStateListDrawable();
    filterableStateListDrawable.addState(new int[] { android.R.attr.state_pressed }, baseDrawable, highlightColorFilter);
    filterableStateListDrawable.addState(StateSet.WILD_CARD, highlightDrawable, baseColorFilter);
    return filterableStateListDrawable;
}
Also used : FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Example 42 with ColorFilter

use of android.graphics.ColorFilter in project Shuttle by timusus.

the class DrawableUtils method getColoredDrawable.

/**
     * Takes a drawable and applies the passed in color to it
     *
     * @param baseDrawable the drawable to theme
     * @return a themed {@link android.graphics.drawable.Drawable}
     */
public static Drawable getColoredDrawable(Drawable baseDrawable, int color) {
    if (baseDrawable == null) {
        return null;
    }
    ColorFilter colorFilter = new LightingColorFilter(color, 0);
    baseDrawable.mutate().setColorFilter(colorFilter);
    return baseDrawable;
}
Also used : ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LightingColorFilter(android.graphics.LightingColorFilter)

Example 43 with ColorFilter

use of android.graphics.ColorFilter in project Shuttle by timusus.

the class DrawableUtils method getColoredDrawable.

/**
     * Takes a drawable resource and applies the current theme highlight color to it
     *
     * @param baseDrawableResId the resource id of the drawable to theme
     * @return a themed {@link android.graphics.drawable.Drawable}
     */
public static Drawable getColoredDrawable(Context context, int baseDrawableResId) {
    Drawable baseDrawable = context.getResources().getDrawable(baseDrawableResId).getConstantState().newDrawable();
    ColorFilter highlightColorFilter = new LightingColorFilter(ColorUtils.getPrimaryColor(), 0);
    baseDrawable.mutate().setColorFilter(highlightColorFilter);
    return baseDrawable;
}
Also used : ColorFilter(android.graphics.ColorFilter) LightingColorFilter(android.graphics.LightingColorFilter) LayerDrawable(android.graphics.drawable.LayerDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) LightingColorFilter(android.graphics.LightingColorFilter)

Example 44 with ColorFilter

use of android.graphics.ColorFilter in project HomeMirror by HannahMitt.

the class MirrorActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mirror);
    mConfigSettings = new ConfigurationSettings(this);
    AlarmReceiver.startMirrorUpdates(this);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mBirthdayText = (TextView) findViewById(R.id.birthday_text);
    mDayText = (TextView) findViewById(R.id.day_text);
    mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
    mHelloText = (TextView) findViewById(R.id.hello_text);
    mWaterPlants = findViewById(R.id.water_plants);
    mGroceryList = findViewById(R.id.grocery_list);
    mBikeTodayText = (TextView) findViewById(R.id.can_bike);
    mStockText = (TextView) findViewById(R.id.stock_text);
    mMoodText = (TextView) findViewById(R.id.mood_text);
    mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
    mNewsHeadline = (TextView) findViewById(R.id.news_headline);
    mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
    mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
    mCountdownText = (TextView) findViewById(R.id.countdown_text);
    if (mConfigSettings.invertXKCD()) {
        //Negative of XKCD image
        float[] colorMatrixNegative = { //red
        -1.0f, //red
        0, //red
        0, //red
        0, //red
        255, //green
        0, //green
        -1.0f, //green
        0, //green
        0, //green
        255, //blue
        0, //blue
        0, //blue
        -1.0f, //blue
        0, //blue
        255, //alpha
        0, //alpha
        0, //alpha
        0, //alpha
        1.0f, //alpha
        0 };
        ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
        // not inverting for now
        mXKCDImage.setColorFilter(colorFilterNegative);
    }
    setViewState();
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorFilter(android.graphics.ColorFilter) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ConfigurationSettings(com.morristaedt.mirror.configuration.ConfigurationSettings) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar)

Example 45 with ColorFilter

use of android.graphics.ColorFilter in project AndroidChromium by JackyAndroid.

the class CardUnmaskPrompt method setInputError.

/**
     * Sets the error message on the cvc input.
     * @param message The error message to show, or null if the error state should be cleared.
     */
private void setInputError(String message) {
    mErrorMessage.setText(message);
    mErrorMessage.setVisibility(message == null ? View.GONE : View.VISIBLE);
    // Announcing twice in a row may cancel the first announcement.
    if (message != null) {
        mErrorMessage.announceForAccessibility(message);
    }
    // draw the TextInput.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return;
    ColorFilter filter = null;
    if (message != null) {
        filter = new PorterDuffColorFilter(ApiCompatibilityUtils.getColor(mDialog.getContext().getResources(), R.color.input_underline_error_color), PorterDuff.Mode.SRC_IN);
    }
    // TODO(estade): it would be nicer if the error were specific enough to tell us which input
    // was invalid.
    updateColorForInput(mCardUnmaskInput, filter);
    updateColorForInput(mMonthInput, filter);
    updateColorForInput(mYearInput, filter);
}
Also used : ColorFilter(android.graphics.ColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter)

Aggregations

ColorFilter (android.graphics.ColorFilter)50 LightingColorFilter (android.graphics.LightingColorFilter)21 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)17 Drawable (android.graphics.drawable.Drawable)17 Paint (android.graphics.Paint)14 FilterableStateListDrawable (com.simplecity.amp_library.ui.views.FilterableStateListDrawable)14 LayerDrawable (android.graphics.drawable.LayerDrawable)12 Path (android.graphics.Path)5 RectF (android.graphics.RectF)5 Test (org.junit.Test)5 Bitmap (android.graphics.Bitmap)4 Canvas (android.graphics.Canvas)4 Rect (android.graphics.Rect)3 Shader (android.graphics.Shader)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 StateListDrawable (android.graphics.drawable.StateListDrawable)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 FilterableStateListDrawable (com.bilibili.magicasakura.drawables.FilterableStateListDrawable)2