Search in sources :

Example 1 with AllCapsTransformationMethod

use of org.holoeverywhere.text.AllCapsTransformationMethod in project HoloEverywhere by Prototik.

the class TextView method setTextAppearance.

public static <T extends android.widget.TextView & FontStyleProvider> void setTextAppearance(T textView, TypedArray appearance) {
    int color = appearance.getColor(R.styleable.TextAppearance_android_textColorHighlight, 0);
    if (color != 0) {
        textView.setHighlightColor(color);
    }
    ColorStateList colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor);
    if (colors != null) {
        textView.setTextColor(colors);
    }
    int ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
    if (ts != 0) {
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, ts);
    }
    colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColorHint);
    if (colors != null) {
        textView.setHintTextColor(colors);
    }
    colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColorLink);
    if (colors != null) {
        textView.setLinkTextColor(colors);
    }
    if (appearance.getBoolean(R.styleable.TextAppearance_android_textAllCaps, false)) {
        textView.setTransformationMethod(new AllCapsTransformationMethod(textView.getContext()));
    }
    Object[] font = parseFontStyle(appearance);
    textView.setFontStyle((String) font[2], (Integer) font[1] | ((Boolean) font[0] ? 0 : textView.getFontStyle()));
}
Also used : ColorStateList(android.content.res.ColorStateList) SuppressLint(android.annotation.SuppressLint) AllCapsTransformationMethod(org.holoeverywhere.text.AllCapsTransformationMethod)

Example 2 with AllCapsTransformationMethod

use of org.holoeverywhere.text.AllCapsTransformationMethod in project HoloEverywhere by Prototik.

the class Switch method setSwitchTextAppearance.

public void setSwitchTextAppearance(Context context, int resid) {
    TypedArray appearance = context.obtainStyledAttributes(resid, R.styleable.TextAppearance);
    ColorStateList colors;
    int ts;
    colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor);
    if (colors != null) {
        mTextColors = colors;
    } else {
        mTextColors = getTextColors();
    }
    ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
    if (ts != 0) {
        if (ts != mTextPaint.getTextSize()) {
            mTextPaint.setTextSize(ts);
            requestLayout();
        }
    }
    int typefaceIndex, styleIndex;
    typefaceIndex = appearance.getInt(R.styleable.TextAppearance_android_typeface, -1);
    styleIndex = appearance.getInt(R.styleable.TextAppearance_android_textStyle, -1);
    setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
    boolean allCaps = appearance.getBoolean(R.styleable.TextAppearance_android_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(org.holoeverywhere.text.AllCapsTransformationMethod)

Aggregations

ColorStateList (android.content.res.ColorStateList)2 AllCapsTransformationMethod (org.holoeverywhere.text.AllCapsTransformationMethod)2 SuppressLint (android.annotation.SuppressLint)1 TypedArray (android.content.res.TypedArray)1 Paint (android.graphics.Paint)1 TextPaint (android.text.TextPaint)1