From 1b33c32fddbd8ca3b92ba1b3504bcc3ec13ee095 Mon Sep 17 00:00:00 2001 From: Evgeny Shishkin Date: Mon, 9 Nov 2015 18:20:25 +0300 Subject: [PATCH] Implementation of `RobotoTextAppearanceSpan`. Close #43 --- .../style/RobotoTextAppearanceSpan.java | 157 ++++++++++++++++++ .../style/RobotoTypefaceSpan.java | 20 ++- ...iewUtils.java => RobotoTypefaceUtils.java} | 43 ++--- .../widget/RobotoAutoCompleteTextView.java | 6 +- .../robototextview/widget/RobotoButton.java | 6 +- .../robototextview/widget/RobotoCheckBox.java | 6 +- .../widget/RobotoCheckedTextView.java | 6 +- .../widget/RobotoChronometer.java | 6 +- .../widget/RobotoCompoundButton.java | 6 +- .../widget/RobotoDigitalClock.java | 4 +- .../robototextview/widget/RobotoEditText.java | 6 +- .../widget/RobotoExtractEditText.java | 6 +- .../RobotoMultiAutoCompleteTextView.java | 6 +- .../widget/RobotoRadioButton.java | 6 +- .../robototextview/widget/RobotoSwitch.java | 6 +- .../widget/RobotoTextClock.java | 6 +- .../robototextview/widget/RobotoTextView.java | 6 +- .../widget/RobotoToggleButton.java | 6 +- 18 files changed, 239 insertions(+), 69 deletions(-) create mode 100644 robototextview/src/main/java/com/devspark/robototextview/style/RobotoTextAppearanceSpan.java rename robototextview/src/main/java/com/devspark/robototextview/util/{RobotoTextViewUtils.java => RobotoTypefaceUtils.java} (61%) diff --git a/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTextAppearanceSpan.java b/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTextAppearanceSpan.java new file mode 100644 index 0000000..f5bc2d0 --- /dev/null +++ b/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTextAppearanceSpan.java @@ -0,0 +1,157 @@ +package com.devspark.robototextview.style; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; +import android.graphics.Typeface; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.text.TextPaint; +import android.text.style.MetricAffectingSpan; +import android.util.Log; +import android.util.SparseIntArray; + +import com.devspark.robototextview.R; +import com.devspark.robototextview.util.RobotoTypefaceManager; +import com.devspark.robototextview.util.RobotoTypefaceUtils; + +/** + * Sets the text color, size and typeface to match a TextAppearance resource. + */ +public class RobotoTextAppearanceSpan extends MetricAffectingSpan { + private static final int[] TEXT_ATTRS = new int[]{ + android.R.attr.textSize, android.R.attr.textColor, android.R.attr.textColorLink}; + + private final Typeface mTypeface; + private final int mTextSize; + private final ColorStateList mTextColor; + private final ColorStateList mTextColorLink; + + /** + * Uses the specified TextAppearance resource to determine the + * text appearance. The appearance should be, for example, + * android.R.style.TextAppearance_Small. + */ + public RobotoTextAppearanceSpan(Context context, int appearance) { + this(context, appearance, -1); + } + + /** + * Uses the specified TextAppearance resource to determine the + * text appearance, and the specified text color resource + * to determine the color. The appearance should be, + * for example, android.R.style.TextAppearance_Small, + * and the colorList should be, for example, + * android.R.styleable.Theme_textColorPrimary. + */ + public RobotoTextAppearanceSpan(Context context, int appearance, int colorList) { + TypedArray a = context.obtainStyledAttributes(appearance, R.styleable.RobotoTextView); + mTypeface = RobotoTypefaceUtils.typefaceFromAttrs(context, a); + a.recycle(); + + ColorStateList textColor; + + a = context.obtainStyledAttributes(appearance, TEXT_ATTRS); + SparseIntArray attrsIndexes = textAttrsIndexes(); + + textColor = a.getColorStateList(attrsIndexes.get(android.R.attr.textColor)); + mTextColorLink = a.getColorStateList(attrsIndexes.get(android.R.attr.textColorLink)); + mTextSize = a.getDimensionPixelSize(attrsIndexes.get(android.R.attr.textSize), -1); + + a.recycle(); + + if (colorList >= 0) { + a = context.obtainStyledAttributes(themeResId(context), TEXT_ATTRS); + textColor = a.getColorStateList(colorList); + a.recycle(); + } + + mTextColor = textColor; + } + + /** + * Makes text be drawn with the specified typeface, size and colors. + */ + public RobotoTextAppearanceSpan(Context context, int typefaceId, int size, + ColorStateList color, ColorStateList linkColor) { + mTypeface = RobotoTypefaceManager.obtainTypeface(context, typefaceId); + mTextSize = size; + mTextColor = color; + mTextColorLink = linkColor; + } + + private int themeResId(Context context) { + try { + String packageName = context.getPackageName(); + PackageInfo packageInfo = context.getPackageManager() + .getPackageInfo(packageName, PackageManager.GET_META_DATA); + return packageInfo.applicationInfo.theme; + } catch (PackageManager.NameNotFoundException e) { + Log.w(getClass().getSimpleName(), e); + } + return -1; + } + + private SparseIntArray textAttrsIndexes() { + SparseIntArray indexes = new SparseIntArray(TEXT_ATTRS.length); + for (int i = 0; i < TEXT_ATTRS.length; i++) { + indexes.put(TEXT_ATTRS[i], i); + } + return indexes; + } + + /** + * Returns the typeface specified by this span. + */ + @NonNull + public Typeface getTypeface() { + return mTypeface; + } + + /** + * Returns the text size specified by this span, or -1 + * if it does not specify one. + */ + public int getTextSize() { + return mTextSize; + } + + /** + * Returns the text color specified by this span, or null + * if it does not specify one. + */ + @Nullable + public ColorStateList getTextColor() { + return mTextColor; + } + + /** + * Returns the link color specified by this span, or null + * if it does not specify one. + */ + @Nullable + public ColorStateList getLinkTextColor() { + return mTextColorLink; + } + + @Override + public void updateDrawState(TextPaint tp) { + updateMeasureState(tp); + if (mTextColor != null) { + tp.setColor(mTextColor.getColorForState(tp.drawableState, 0)); + } + if (mTextColorLink != null) { + tp.linkColor = mTextColorLink.getColorForState(tp.drawableState, 0); + } + } + + @Override + public void updateMeasureState(TextPaint tp) { + RobotoTypefaceUtils.setup(tp, mTypeface); + if (mTextSize > 0) { + tp.setTextSize(mTextSize); + } + } +} \ No newline at end of file diff --git a/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTypefaceSpan.java b/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTypefaceSpan.java index 39c6f6f..d48f5a0 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTypefaceSpan.java +++ b/robototextview/src/main/java/com/devspark/robototextview/style/RobotoTypefaceSpan.java @@ -2,10 +2,11 @@ import android.content.Context; import android.graphics.Typeface; +import android.support.annotation.NonNull; import android.text.TextPaint; import android.text.style.MetricAffectingSpan; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; import com.devspark.robototextview.util.RobotoTypefaceManager; /** @@ -52,14 +53,21 @@ public RobotoTypefaceSpan(Context context, int fontFamily, int textWeight, int t mTypeface = RobotoTypefaceManager.obtainTypeface(context, fontFamily, textWeight, textStyle); } - @Override - public void updateDrawState(TextPaint ds) { - RobotoTextViewUtils.setTypeface(ds, mTypeface); + /** + * Returns the typeface specified by this span. + */ + @NonNull + public Typeface getTypeface() { + return mTypeface; } @Override - public void updateMeasureState(TextPaint paint) { - RobotoTextViewUtils.setTypeface(paint, mTypeface); + public void updateDrawState(TextPaint tp) { + updateMeasureState(tp); } + @Override + public void updateMeasureState(TextPaint tp) { + RobotoTypefaceUtils.setup(tp, mTypeface); + } } \ No newline at end of file diff --git a/robototextview/src/main/java/com/devspark/robototextview/util/RobotoTextViewUtils.java b/robototextview/src/main/java/com/devspark/robototextview/util/RobotoTypefaceUtils.java similarity index 61% rename from robototextview/src/main/java/com/devspark/robototextview/util/RobotoTextViewUtils.java rename to robototextview/src/main/java/com/devspark/robototextview/util/RobotoTypefaceUtils.java index b35f44c..df807c3 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/util/RobotoTextViewUtils.java +++ b/robototextview/src/main/java/com/devspark/robototextview/util/RobotoTypefaceUtils.java @@ -20,6 +20,8 @@ import android.content.res.TypedArray; import android.graphics.Paint; import android.graphics.Typeface; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.util.AttributeSet; import android.widget.TextView; @@ -30,9 +32,9 @@ * * @author Evgeny Shishkin */ -public class RobotoTextViewUtils { +public final class RobotoTypefaceUtils { - private RobotoTextViewUtils() { + private RobotoTypefaceUtils() { } /** @@ -43,29 +45,33 @@ private RobotoTextViewUtils() { * access the current theme, resources, etc. * @param attrs The attributes of the XML tag that is inflating the widget. */ - public static void initTypeface(TextView textView, Context context, AttributeSet attrs) { + public static void initView(@NonNull TextView textView, @NonNull Context context, @Nullable AttributeSet attrs) { Typeface typeface; if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RobotoTextView); - - if (a.hasValue(R.styleable.RobotoTextView_typeface)) { - int typefaceValue = a.getInt(R.styleable.RobotoTextView_typeface, RobotoTypefaceManager.Typeface.ROBOTO_REGULAR); - typeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue); - } else { - int fontFamily = a.getInt(R.styleable.RobotoTextView_fontFamily, RobotoTypefaceManager.FontFamily.ROBOTO); - int textWeight = a.getInt(R.styleable.RobotoTextView_textWeight, RobotoTypefaceManager.TextWeight.NORMAL); - int textStyle = a.getInt(R.styleable.RobotoTextView_textStyle, RobotoTypefaceManager.TextStyle.NORMAL); - - typeface = RobotoTypefaceManager.obtainTypeface(context, fontFamily, textWeight, textStyle); - } - + typeface = typefaceFromAttrs(context, a); a.recycle(); } else { typeface = RobotoTypefaceManager.obtainTypeface(context, RobotoTypefaceManager.Typeface.ROBOTO_REGULAR); } - setTypeface(textView, typeface); + setup(textView, typeface); + } + + @NonNull + public static Typeface typefaceFromAttrs(@NonNull Context context, @NonNull TypedArray a) { + Typeface typeface; + if (a.hasValue(R.styleable.RobotoTextView_typeface)) { + int typefaceValue = a.getInt(R.styleable.RobotoTextView_typeface, RobotoTypefaceManager.Typeface.ROBOTO_REGULAR); + typeface = RobotoTypefaceManager.obtainTypeface(context, typefaceValue); + } else { + int fontFamily = a.getInt(R.styleable.RobotoTextView_fontFamily, RobotoTypefaceManager.FontFamily.ROBOTO); + int textWeight = a.getInt(R.styleable.RobotoTextView_textWeight, RobotoTypefaceManager.TextWeight.NORMAL); + int textStyle = a.getInt(R.styleable.RobotoTextView_textStyle, RobotoTypefaceManager.TextStyle.NORMAL); + typeface = RobotoTypefaceManager.obtainTypeface(context, fontFamily, textWeight, textStyle); + } + return typeface; } /** @@ -75,7 +81,7 @@ public static void initTypeface(TextView textView, Context context, AttributeSet * @param textView The text view * @param typeface The specify typeface */ - public static void setTypeface(TextView textView, Typeface typeface) { + public static void setup(@NonNull TextView textView, @NonNull Typeface typeface) { textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); textView.setTypeface(typeface); } @@ -86,9 +92,8 @@ public static void setTypeface(TextView textView, Typeface typeface) { * @param paint The paint * @param typeface The specify typeface */ - public static void setTypeface(Paint paint, Typeface typeface) { + public static void setup(@NonNull Paint paint, @NonNull Typeface typeface) { paint.setFlags(paint.getFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); paint.setTypeface(typeface); } - } \ No newline at end of file diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoAutoCompleteTextView.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoAutoCompleteTextView.java index 037e59b..7e55bf6 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoAutoCompleteTextView.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoAutoCompleteTextView.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.AutoCompleteTextView; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link AutoCompleteTextView} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoAutoCompleteTextView(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoAutoCompleteTextView(Context context, AttributeSet attrs, int defSt super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoButton.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoButton.java index 5fb8adc..b29657e 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoButton.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoButton.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.Button; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link Button} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoButton(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckBox.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckBox.java index b6c1471..c0c820e 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckBox.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckBox.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.CheckBox; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link CheckBox} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoCheckBox(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoCheckBox(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckedTextView.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckedTextView.java index e413170..beae24c 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckedTextView.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCheckedTextView.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.CheckedTextView; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link CheckedTextView} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoCheckedTextView(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoCheckedTextView(Context context, AttributeSet attrs, int defStyle) super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoChronometer.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoChronometer.java index a8ff83a..b31dd08 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoChronometer.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoChronometer.java @@ -20,7 +20,7 @@ import android.util.AttributeSet; import android.widget.Chronometer; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link Chronometer} with native support for all the Roboto fonts. @@ -59,7 +59,7 @@ public RobotoChronometer(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -81,7 +81,7 @@ public RobotoChronometer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCompoundButton.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCompoundButton.java index ab106b0..ed5ce41 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCompoundButton.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoCompoundButton.java @@ -20,7 +20,7 @@ import android.util.AttributeSet; import android.widget.CompoundButton; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link CompoundButton} with native support for all the Roboto fonts. @@ -59,7 +59,7 @@ public RobotoCompoundButton(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -81,7 +81,7 @@ public RobotoCompoundButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoDigitalClock.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoDigitalClock.java index 5bd5bad..756ae1d 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoDigitalClock.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoDigitalClock.java @@ -20,7 +20,7 @@ import android.util.AttributeSet; import android.widget.DigitalClock; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link DigitalClock} with native support for all the Roboto fonts. @@ -58,7 +58,7 @@ public RobotoDigitalClock(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoEditText.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoEditText.java index 0fe6f20..e08b67d 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoEditText.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoEditText.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.EditText; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link EditText} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoEditText(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoEditText(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoExtractEditText.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoExtractEditText.java index fc68d95..1dd76ee 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoExtractEditText.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoExtractEditText.java @@ -20,7 +20,7 @@ import android.inputmethodservice.ExtractEditText; import android.util.AttributeSet; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link ExtractEditText} with native support for all the Roboto fonts. @@ -59,7 +59,7 @@ public RobotoExtractEditText(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -81,7 +81,7 @@ public RobotoExtractEditText(Context context, AttributeSet attrs, int defStyle) super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoMultiAutoCompleteTextView.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoMultiAutoCompleteTextView.java index d25bf34..72ad818 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoMultiAutoCompleteTextView.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoMultiAutoCompleteTextView.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.MultiAutoCompleteTextView; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link MultiAutoCompleteTextView} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoMultiAutoCompleteTextView(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoMultiAutoCompleteTextView(Context context, AttributeSet attrs, int super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoRadioButton.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoRadioButton.java index a174842..37a4c8c 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoRadioButton.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoRadioButton.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.RadioButton; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link RadioButton} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoRadioButton(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoRadioButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoSwitch.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoSwitch.java index 10eacef..6d46375 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoSwitch.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoSwitch.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.Switch; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link Switch} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoSwitch(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoSwitch(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextClock.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextClock.java index 42532fe..e3a676b 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextClock.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextClock.java @@ -22,7 +22,7 @@ import android.util.AttributeSet; import android.widget.TextClock; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link TextClock} with native support for all the Roboto fonts. @@ -62,7 +62,7 @@ public RobotoTextClock(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -84,7 +84,7 @@ public RobotoTextClock(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextView.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextView.java index fac1932..63a91ec 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextView.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoTextView.java @@ -21,7 +21,7 @@ import android.util.AttributeSet; import android.widget.TextView; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link TextView} with native support for all the Roboto fonts. @@ -60,7 +60,7 @@ public RobotoTextView(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -82,7 +82,7 @@ public RobotoTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } diff --git a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoToggleButton.java b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoToggleButton.java index ce82271..4956722 100644 --- a/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoToggleButton.java +++ b/robototextview/src/main/java/com/devspark/robototextview/widget/RobotoToggleButton.java @@ -20,7 +20,7 @@ import android.util.AttributeSet; import android.widget.ToggleButton; -import com.devspark.robototextview.util.RobotoTextViewUtils; +import com.devspark.robototextview.util.RobotoTypefaceUtils; /** * Implementation of a {@link ToggleButton} with native support for all the Roboto fonts. @@ -59,7 +59,7 @@ public RobotoToggleButton(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } } @@ -81,7 +81,7 @@ public RobotoToggleButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { - RobotoTextViewUtils.initTypeface(this, context, attrs); + RobotoTypefaceUtils.initView(this, context, attrs); } }