diff options
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | api/system-current.txt | 3 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 122 |
3 files changed, 64 insertions, 64 deletions
diff --git a/api/current.txt b/api/current.txt index 1d1095b..8e6a04e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39763,7 +39763,8 @@ package android.widget { method public final void setText(char[], int, int); method public final void setText(int); method public final void setText(int, android.widget.TextView.BufferType); - method public void setTextAppearance(android.content.Context, int); + method public void setTextAppearance(int); + method public deprecated void setTextAppearance(android.content.Context, int); method public void setTextColor(int); method public void setTextColor(android.content.res.ColorStateList); method public void setTextIsSelectable(boolean); diff --git a/api/system-current.txt b/api/system-current.txt index 56de32a..d5910f0 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42231,7 +42231,8 @@ package android.widget { method public final void setText(char[], int, int); method public final void setText(int); method public final void setText(int, android.widget.TextView.BufferType); - method public void setTextAppearance(android.content.Context, int); + method public void setTextAppearance(int); + method public deprecated void setTextAppearance(android.content.Context, int); method public void setTextColor(int); method public void setTextColor(android.content.res.ColorStateList); method public void setTextIsSelectable(boolean); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 447e9ac..2768dae 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -2644,94 +2644,92 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } /** + * Sets the text appearance from the specified style resource. + * <p> + * Use a framework-defined {@code TextAppearance} style like + * {@link android.R.style#TextAppearance_Material_Body1 @android:style/TextAppearance.Material.Body1} + * or see {@link android.R.styleable#TextAppearance TextAppearance} for the + * set of attributes that can be used in a custom style. + * + * @param resId the resource identifier of the style to apply + * @attr ref android.R.styleable#TextView_textAppearance + */ + @SuppressWarnings("deprecation") + public void setTextAppearance(@StyleRes int resId) { + setTextAppearance(mContext, resId); + } + + /** * Sets the text color, size, style, hint color, and highlight color * from the specified TextAppearance resource. + * + * @deprecated Use {@link #setTextAppearance(int)} instead. */ - public void setTextAppearance(Context context, @StyleRes int resid) { - TypedArray appearance = - context.obtainStyledAttributes(resid, - com.android.internal.R.styleable.TextAppearance); - - int color; - ColorStateList colors; - int ts; + @Deprecated + public void setTextAppearance(Context context, @StyleRes int resId) { + final TypedArray ta = context.obtainStyledAttributes(resId, R.styleable.TextAppearance); - color = appearance.getColor( - com.android.internal.R.styleable.TextAppearance_textColorHighlight, 0); - if (color != 0) { - setHighlightColor(color); + final int textColorHighlight = ta.getColor( + R.styleable.TextAppearance_textColorHighlight, 0); + if (textColorHighlight != 0) { + setHighlightColor(textColorHighlight); } - colors = appearance.getColorStateList(com.android.internal.R.styleable. - TextAppearance_textColor); - if (colors != null) { - setTextColor(colors); + final ColorStateList textColor = ta.getColorStateList(R.styleable.TextAppearance_textColor); + if (textColor != null) { + setTextColor(textColor); } - ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable. - TextAppearance_textSize, 0); - if (ts != 0) { - setRawTextSize(ts); + final int textSize = ta.getDimensionPixelSize(R.styleable.TextAppearance_textSize, 0); + if (textSize != 0) { + setRawTextSize(textSize); } - colors = appearance.getColorStateList(com.android.internal.R.styleable. - TextAppearance_textColorHint); - if (colors != null) { - setHintTextColor(colors); + final ColorStateList textColorHint = ta.getColorStateList( + R.styleable.TextAppearance_textColorHint); + if (textColorHint != null) { + setHintTextColor(textColorHint); } - colors = appearance.getColorStateList(com.android.internal.R.styleable. - TextAppearance_textColorLink); - if (colors != null) { - setLinkTextColor(colors); + final ColorStateList textColorLink = ta.getColorStateList( + R.styleable.TextAppearance_textColorLink); + if (textColorLink != null) { + setLinkTextColor(textColorLink); } - String familyName; - int typefaceIndex, styleIndex; - - familyName = appearance.getString(com.android.internal.R.styleable. - TextAppearance_fontFamily); - typefaceIndex = appearance.getInt(com.android.internal.R.styleable. - TextAppearance_typeface, -1); - styleIndex = appearance.getInt(com.android.internal.R.styleable. - TextAppearance_textStyle, -1); - - setTypefaceFromAttrs(familyName, typefaceIndex, styleIndex); - - final int shadowcolor = appearance.getInt( - com.android.internal.R.styleable.TextAppearance_shadowColor, 0); - if (shadowcolor != 0) { - final float dx = appearance.getFloat( - com.android.internal.R.styleable.TextAppearance_shadowDx, 0); - final float dy = appearance.getFloat( - com.android.internal.R.styleable.TextAppearance_shadowDy, 0); - final float r = appearance.getFloat( - com.android.internal.R.styleable.TextAppearance_shadowRadius, 0); + 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); - setShadowLayer(r, dx, dy, shadowcolor); + 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 (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, - false)) { + if (ta.getBoolean(R.styleable.TextAppearance_textAllCaps, false)) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } - if (appearance.hasValue(com.android.internal.R.styleable.TextAppearance_elegantTextHeight)) { - setElegantTextHeight(appearance.getBoolean( - com.android.internal.R.styleable.TextAppearance_elegantTextHeight, false)); + if (ta.hasValue(R.styleable.TextAppearance_elegantTextHeight)) { + setElegantTextHeight(ta.getBoolean( + R.styleable.TextAppearance_elegantTextHeight, false)); } - if (appearance.hasValue(com.android.internal.R.styleable.TextAppearance_letterSpacing)) { - setLetterSpacing(appearance.getFloat( - com.android.internal.R.styleable.TextAppearance_letterSpacing, 0)); + if (ta.hasValue(R.styleable.TextAppearance_letterSpacing)) { + setLetterSpacing(ta.getFloat( + R.styleable.TextAppearance_letterSpacing, 0)); } - if (appearance.hasValue(com.android.internal.R.styleable.TextAppearance_fontFeatureSettings)) { - setFontFeatureSettings(appearance.getString( - com.android.internal.R.styleable.TextAppearance_fontFeatureSettings)); + if (ta.hasValue(R.styleable.TextAppearance_fontFeatureSettings)) { + setFontFeatureSettings(ta.getString( + R.styleable.TextAppearance_fontFeatureSettings)); } - appearance.recycle(); + ta.recycle(); } /** |