Search in sources :

Example 71 with ColorStateList

use of android.content.res.ColorStateList in project android_frameworks_base by ResurrectionRemix.

the class RippleDrawable method updateStateFromTypedArray.

/**
     * Initializes the constant state from the values in the typed array.
     */
private void updateStateFromTypedArray(@NonNull TypedArray a) throws XmlPullParserException {
    final RippleState state = mState;
    // Account for any configuration changes.
    state.mChangingConfigurations |= a.getChangingConfigurations();
    // Extract the theme attributes, if any.
    state.mTouchThemeAttrs = a.extractThemeAttrs();
    final ColorStateList color = a.getColorStateList(R.styleable.RippleDrawable_color);
    if (color != null) {
        mState.mColor = color;
    }
    mState.mMaxRadius = a.getDimensionPixelSize(R.styleable.RippleDrawable_radius, mState.mMaxRadius);
}
Also used : ColorStateList(android.content.res.ColorStateList)

Example 72 with ColorStateList

use of android.content.res.ColorStateList in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ImportanceSeekBarPreference method applyAutoUi.

private void applyAutoUi(ImageView autoButton) {
    mSeekBar.setEnabled(!mAutoOn);
    final float alpha = mAutoOn ? mInactiveSliderAlpha : mActiveSliderAlpha;
    final ColorStateList starTint = mAutoOn ? mActiveSliderTint : mInactiveSliderTint;
    Drawable icon = autoButton.getDrawable().mutate();
    icon.setTintList(starTint);
    autoButton.setImageDrawable(icon);
    mSeekBar.setAlpha(alpha);
    if (mAutoOn) {
        setImportance(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT);
        mSummary = getImportanceSummary(NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED);
    }
    mSummaryTextView.setText(mSummary);
}
Also used : Drawable(android.graphics.drawable.Drawable) ColorStateList(android.content.res.ColorStateList)

Example 73 with ColorStateList

use of android.content.res.ColorStateList in project android_frameworks_base by ResurrectionRemix.

the class NinePatchDrawable method updateStateFromTypedArray.

/**
     * Updates the constant state from the values in the typed array.
     */
private void updateStateFromTypedArray(@NonNull TypedArray a) throws XmlPullParserException {
    final Resources r = a.getResources();
    final NinePatchState state = mNinePatchState;
    // Account for any configuration changes.
    state.mChangingConfigurations |= a.getChangingConfigurations();
    // Extract the theme attributes, if any.
    state.mThemeAttrs = a.extractThemeAttrs();
    state.mDither = a.getBoolean(R.styleable.NinePatchDrawable_dither, state.mDither);
    final int srcResId = a.getResourceId(R.styleable.NinePatchDrawable_src, 0);
    if (srcResId != 0) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inDither = !state.mDither;
        options.inScreenDensity = r.getDisplayMetrics().noncompatDensityDpi;
        final Rect padding = new Rect();
        final Rect opticalInsets = new Rect();
        Bitmap bitmap = null;
        try {
            final TypedValue value = new TypedValue();
            final InputStream is = r.openRawResource(srcResId, value);
            bitmap = BitmapFactory.decodeResourceStream(r, value, is, padding, options);
            is.close();
        } catch (IOException e) {
        // Ignore
        }
        if (bitmap == null) {
            throw new XmlPullParserException(a.getPositionDescription() + ": <nine-patch> requires a valid src attribute");
        } else if (bitmap.getNinePatchChunk() == null) {
            throw new XmlPullParserException(a.getPositionDescription() + ": <nine-patch> requires a valid 9-patch source image");
        }
        bitmap.getOpticalInsets(opticalInsets);
        state.mNinePatch = new NinePatch(bitmap, bitmap.getNinePatchChunk());
        state.mPadding = padding;
        state.mOpticalInsets = Insets.of(opticalInsets);
    }
    state.mAutoMirrored = a.getBoolean(R.styleable.NinePatchDrawable_autoMirrored, state.mAutoMirrored);
    state.mBaseAlpha = a.getFloat(R.styleable.NinePatchDrawable_alpha, state.mBaseAlpha);
    final int tintMode = a.getInt(R.styleable.NinePatchDrawable_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = Drawable.parseTintMode(tintMode, Mode.SRC_IN);
    }
    final ColorStateList tint = a.getColorStateList(R.styleable.NinePatchDrawable_tint);
    if (tint != null) {
        state.mTint = tint;
    }
}
Also used : Rect(android.graphics.Rect) InputStream(java.io.InputStream) NinePatch(android.graphics.NinePatch) ColorStateList(android.content.res.ColorStateList) IOException(java.io.IOException) Paint(android.graphics.Paint) Bitmap(android.graphics.Bitmap) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) Resources(android.content.res.Resources) BitmapFactory(android.graphics.BitmapFactory) TypedValue(android.util.TypedValue)

Example 74 with ColorStateList

use of android.content.res.ColorStateList in project UltimateAndroid by cymcsg.

the class CalendarGridView method setDayTextColor.

public void setDayTextColor(int resId) {
    for (int i = 0; i < getChildCount(); i++) {
        ColorStateList colors = getResources().getColorStateList(resId);
        ((CalendarRowView) getChildAt(i)).setCellTextColor(colors);
    }
}
Also used : ColorStateList(android.content.res.ColorStateList) Paint(android.graphics.Paint)

Example 75 with ColorStateList

use of android.content.res.ColorStateList in project Douya by DreaminginCodeZH.

the class TintHelper method onPanelMenuCreated.

public static void onPanelMenuCreated(int featureId, Menu menu, AppCompatActivity activity) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        Context context = activity.getSupportActionBar().getThemedContext();
        ColorStateList menuTintList = ViewUtils.getColorStateListFromAttrRes(R.attr.colorControlNormal, context);
        int popupThemeResId = ViewUtils.getResIdFromAttrRes(R.attr.popupTheme, 0, context);
        ColorStateList subMenuTintList;
        if (popupThemeResId != 0) {
            Context popupContext = new ContextThemeWrapper(context, popupThemeResId);
            subMenuTintList = ViewUtils.getColorStateListFromAttrRes(R.attr.colorControlNormal, popupContext);
        } else {
            subMenuTintList = menuTintList;
        }
        tintMenuItemIcon(menu, menuTintList, subMenuTintList);
    }
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) ColorStateList(android.content.res.ColorStateList)

Aggregations

ColorStateList (android.content.res.ColorStateList)280 Paint (android.graphics.Paint)90 TypedArray (android.content.res.TypedArray)76 Drawable (android.graphics.drawable.Drawable)48 TextPaint (android.text.TextPaint)42 Resources (android.content.res.Resources)25 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)22 TypedValue (android.util.TypedValue)21 TextView (android.widget.TextView)19 Context (android.content.Context)18 SuppressLint (android.annotation.SuppressLint)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)13 AllCapsTransformationMethod (android.text.method.AllCapsTransformationMethod)13 RippleDrawable (android.graphics.drawable.RippleDrawable)12 StateListDrawable (android.graphics.drawable.StateListDrawable)12 View (android.view.View)12 Nullable (android.annotation.Nullable)10 Bitmap (android.graphics.Bitmap)10 TextAppearanceSpan (android.text.style.TextAppearanceSpan)9 PorterDuff (android.graphics.PorterDuff)8