Search in sources :

Example 1 with AllCapsTransformationMethod

use of android.text.method.AllCapsTransformationMethod 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();
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) SpannedString(android.text.SpannedString) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) AllCapsTransformationMethod(android.text.method.AllCapsTransformationMethod)

Example 2 with AllCapsTransformationMethod

use of android.text.method.AllCapsTransformationMethod 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();
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) AllCapsTransformationMethod(android.text.method.AllCapsTransformationMethod)

Example 3 with AllCapsTransformationMethod

use of android.text.method.AllCapsTransformationMethod in project android_frameworks_base by DirtyUnicorns.

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();
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) SpannedString(android.text.SpannedString) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) AllCapsTransformationMethod(android.text.method.AllCapsTransformationMethod)

Example 4 with AllCapsTransformationMethod

use of android.text.method.AllCapsTransformationMethod in project android_frameworks_base by DirtyUnicorns.

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();
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) AllCapsTransformationMethod(android.text.method.AllCapsTransformationMethod)

Example 5 with AllCapsTransformationMethod

use of android.text.method.AllCapsTransformationMethod in project android_frameworks_base by ParanoidAndroid.

the class TextView method setTextAppearance.

/**
     * Sets the text color, size, style, hint color, and highlight color
     * from the specified TextAppearance resource.
     */
public void setTextAppearance(Context context, int resid) {
    TypedArray appearance = context.obtainStyledAttributes(resid, com.android.internal.R.styleable.TextAppearance);
    int color;
    ColorStateList colors;
    int ts;
    color = appearance.getColor(com.android.internal.R.styleable.TextAppearance_textColorHighlight, 0);
    if (color != 0) {
        setHighlightColor(color);
    }
    colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
    if (colors != null) {
        setTextColor(colors);
    }
    ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
    if (ts != 0) {
        setRawTextSize(ts);
    }
    colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColorHint);
    if (colors != null) {
        setHintTextColor(colors);
    }
    colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColorLink);
    if (colors != null) {
        setLinkTextColor(colors);
    }
    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);
        setShadowLayer(r, dx, dy, shadowcolor);
    }
    if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false)) {
        setTransformationMethod(new AllCapsTransformationMethod(getContext()));
    }
    appearance.recycle();
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) SpannedString(android.text.SpannedString) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) AllCapsTransformationMethod(android.text.method.AllCapsTransformationMethod)

Aggregations

AllCapsTransformationMethod (android.text.method.AllCapsTransformationMethod)14 ColorStateList (android.content.res.ColorStateList)13 TypedArray (android.content.res.TypedArray)13 Paint (android.graphics.Paint)13 TextPaint (android.text.TextPaint)13 SpannableString (android.text.SpannableString)6 SpannedString (android.text.SpannedString)6 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 Typeface (android.graphics.Typeface)1 UserHandle (android.os.UserHandle)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1