use of android.content.res.ColorStateList in project android_frameworks_base by ResurrectionRemix.
the class TextView method setTextAppearance.
/**
* Sets the text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @deprecated Use {@link #setTextAppearance(int)} instead.
*/
@Deprecated
public void setTextAppearance(Context context, @StyleRes int resId) {
final TypedArray ta = context.obtainStyledAttributes(resId, R.styleable.TextAppearance);
final int textColorHighlight = ta.getColor(R.styleable.TextAppearance_textColorHighlight, 0);
if (textColorHighlight != 0) {
setHighlightColor(textColorHighlight);
}
final ColorStateList textColor = ta.getColorStateList(R.styleable.TextAppearance_textColor);
if (textColor != null) {
setTextColor(textColor);
}
final int textSize = ta.getDimensionPixelSize(R.styleable.TextAppearance_textSize, 0);
if (textSize != 0) {
setRawTextSize(textSize);
}
final ColorStateList textColorHint = ta.getColorStateList(R.styleable.TextAppearance_textColorHint);
if (textColorHint != null) {
setHintTextColor(textColorHint);
}
final ColorStateList textColorLink = ta.getColorStateList(R.styleable.TextAppearance_textColorLink);
if (textColorLink != null) {
setLinkTextColor(textColorLink);
}
final String fontFamily = ta.getString(R.styleable.TextAppearance_fontFamily);
final int typefaceIndex = ta.getInt(R.styleable.TextAppearance_typeface, -1);
final int styleIndex = ta.getInt(R.styleable.TextAppearance_textStyle, -1);
setTypefaceFromAttrs(fontFamily, typefaceIndex, styleIndex);
final int shadowColor = ta.getInt(R.styleable.TextAppearance_shadowColor, 0);
if (shadowColor != 0) {
final float dx = ta.getFloat(R.styleable.TextAppearance_shadowDx, 0);
final float dy = ta.getFloat(R.styleable.TextAppearance_shadowDy, 0);
final float r = ta.getFloat(R.styleable.TextAppearance_shadowRadius, 0);
setShadowLayer(r, dx, dy, shadowColor);
}
if (ta.getBoolean(R.styleable.TextAppearance_textAllCaps, false)) {
setTransformationMethod(new AllCapsTransformationMethod(getContext()));
}
if (ta.hasValue(R.styleable.TextAppearance_elegantTextHeight)) {
setElegantTextHeight(ta.getBoolean(R.styleable.TextAppearance_elegantTextHeight, false));
}
if (ta.hasValue(R.styleable.TextAppearance_letterSpacing)) {
setLetterSpacing(ta.getFloat(R.styleable.TextAppearance_letterSpacing, 0));
}
if (ta.hasValue(R.styleable.TextAppearance_fontFeatureSettings)) {
setFontFeatureSettings(ta.getString(R.styleable.TextAppearance_fontFeatureSettings));
}
ta.recycle();
}
use of android.content.res.ColorStateList in project android_frameworks_base by ResurrectionRemix.
the class Switch method setSwitchTextAppearance.
/**
* Sets the switch text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @attr ref android.R.styleable#Switch_switchTextAppearance
*/
public void setSwitchTextAppearance(Context context, @StyleRes int resid) {
TypedArray appearance = context.obtainStyledAttributes(resid, com.android.internal.R.styleable.TextAppearance);
ColorStateList colors;
int ts;
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
if (colors != null) {
mTextColors = colors;
} else {
// If no color set in TextAppearance, default to the view's textColor
mTextColors = getTextColors();
}
ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
if (ts != 0) {
if (ts != mTextPaint.getTextSize()) {
mTextPaint.setTextSize(ts);
requestLayout();
}
}
int typefaceIndex, styleIndex;
typefaceIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_typeface, -1);
styleIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_textStyle, -1);
setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
boolean allCaps = appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false);
if (allCaps) {
mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext());
mSwitchTransformationMethod.setLengthChangesAllowed(true);
} else {
mSwitchTransformationMethod = null;
}
appearance.recycle();
}
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 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);
}
Aggregations