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);
}
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);
}
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;
}
}
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);
}
}
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);
}
}
Aggregations