diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/TextViewUtils.java b/QKSMS/src/main/java/com/moez/QKSMS/common/TextViewUtils.java index ae96ae1f..c60b6534 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/TextViewUtils.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/TextViewUtils.java @@ -50,14 +50,14 @@ public class TextViewUtils { if (a.hasValue(R.styleable.RobotoTextView_typeface)) { int typefaceValue = a.getInt(R.styleable.RobotoTextView_typeface, TypefaceManager.Typefaces.ROBOTO_REGULAR); - typeface = TypefaceManager.obtainTypeface(context, typefaceValue); + typeface = TypefaceManager.obtainTypeface(typefaceValue); } a.recycle(); } if (typeface == null) { - typeface = TypefaceManager.obtainTypeface(context, TypefaceManager.Typefaces.ROBOTO_REGULAR); + typeface = TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_REGULAR); } setTypeface(textView, typeface); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/TypefaceManager.java b/QKSMS/src/main/java/com/moez/QKSMS/common/TypefaceManager.java index bc779cb8..fba75449 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/TypefaceManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/TypefaceManager.java @@ -1,6 +1,5 @@ package com.moez.QKSMS.common; -import android.content.Context; import android.graphics.Typeface; import android.os.Build; import android.util.SparseArray; @@ -12,7 +11,7 @@ public class TypefaceManager { private final static SparseArray mTypefaces = new SparseArray<>(); - public static android.graphics.Typeface obtainTypeface(Context context, int typefaceValue) throws IllegalArgumentException { + public static android.graphics.Typeface obtainTypeface(int typefaceValue) throws IllegalArgumentException { android.graphics.Typeface typeface = mTypefaces.get(typefaceValue); if (typeface == null) { typeface = createTypeface(typefaceValue); @@ -21,12 +20,7 @@ public class TypefaceManager { return typeface; } - public static android.graphics.Typeface obtainTypeface(Context context, int fontFamily, int textWeight, int textStyle) throws IllegalArgumentException { - int typefaceValue = getTypefaceValue(fontFamily, textWeight, textStyle); - return obtainTypeface(context, typefaceValue); - } - - private static int getTypefaceValue(int fontFamily, int textWeight, int textStyle) { + public static android.graphics.Typeface obtainTypeface(int fontFamily, int textWeight, int textStyle) throws IllegalArgumentException { int typeface; if (fontFamily == FontFamily.ROBOTO) { if (textWeight == TextWeight.NORMAL) { @@ -115,7 +109,7 @@ public class TypefaceManager { throw new IllegalArgumentException("`textWeight` attribute value " + textWeight + " is not supported for this font family " + fontFamily); } - } else if (fontFamily == FontFamily.LATO) { + } else if (fontFamily == FontFamily.LATO) { if (textWeight == TextWeight.NORMAL) { switch (textStyle) { case TextStyle.NORMAL: @@ -170,7 +164,7 @@ public class TypefaceManager { } else { throw new IllegalArgumentException("Unknown `fontFamily` attribute value " + fontFamily); } - return typeface; + return obtainTypeface(typeface); } private static Typeface createTypeface(int typefaceValue) throws IllegalArgumentException { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java index ea7fff1c..9fdd8a7f 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java @@ -203,7 +203,7 @@ public class ContactHelper { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); - paint.setTypeface(TypefaceManager.obtainTypeface(context, TypefaceManager.Typefaces.ROBOTO_LIGHT)); + paint.setTypeface(TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_LIGHT)); paint.setTextSize(length / 2); Rect bounds = new Rect(); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java index 418b3f49..fe930494 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java @@ -57,7 +57,7 @@ public class AutoCompleteContactView extends RecipientEditTextView implements Li @Override public void refresh() { - setTypeface(TypefaceManager.obtainTypeface(mContext, FontManager.getFontFamily(mContext), + setTypeface(TypefaceManager.obtainTypeface(FontManager.getFontFamily(mContext), FontManager.getFontWeight(mContext, false), TypefaceManager.TextStyle.NORMAL)); setTextSize(TypedValue.COMPLEX_UNIT_SP, FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY)); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java index 19ca3961..edda052d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java @@ -77,7 +77,7 @@ public class AvatarView extends ImageView implements View.OnClickListener, LiveV mPaint.setTextSize(Units.dpToPx(context, 32)); mPaint.setTextAlign(Paint.Align.CENTER); mPaint.setAntiAlias(true); - mPaint.setTypeface(TypefaceManager.obtainTypeface(context, TypefaceManager.Typefaces.ROBOTO_LIGHT)); + mPaint.setTypeface(TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_LIGHT)); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarView, defStyle, 0); for (int i = 0; i < a.getIndexCount(); i++) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java index df966063..6e2cfd0a 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java @@ -97,7 +97,7 @@ public class QKEditText extends android.widget.EditText implements LiveView { // Typeface and colors int fontFamily = FontManager.getFontFamily(mContext); int fontWeight = FontManager.getFontWeight(mContext, false); - setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight, + setTypeface(TypefaceManager.obtainTypeface(fontFamily, fontWeight, TypefaceManager.TextStyle.NORMAL)); setTextColor(ThemeManager.getTextOnBackgroundPrimary()); setHintTextColor(ThemeManager.getTextOnBackgroundSecondary()); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java index b67d77fe..5599ef6f 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java @@ -162,7 +162,7 @@ public class QKTextView extends TextView implements LiveView { // Typeface int fontFamily = FontManager.getFontFamily(mContext); int fontWeight = FontManager.getFontWeight(mContext, FontManager.getIsFontHeavy(mType)); - setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight, + setTypeface(TypefaceManager.obtainTypeface(fontFamily, fontWeight, TypefaceManager.TextStyle.NORMAL)); // Text size and color