diff --git a/QKSMS/build.gradle b/QKSMS/build.gradle index 7bf43352..f6ea2733 100644 --- a/QKSMS/build.gradle +++ b/QKSMS/build.gradle @@ -30,7 +30,7 @@ android { defaultConfig { versionCode 116 versionName "2.2.4" - minSdkVersion 16 + minSdkVersion 15 targetSdkVersion 22 } diff --git a/QKSMS/src/main/assets/fonts/Roboto-Light.ttf b/QKSMS/src/main/assets/fonts/Roboto-Light.ttf new file mode 100644 index 00000000..aa453407 Binary files /dev/null and b/QKSMS/src/main/assets/fonts/Roboto-Light.ttf differ diff --git a/QKSMS/src/main/assets/fonts/Roboto-Medium.ttf b/QKSMS/src/main/assets/fonts/Roboto-Medium.ttf new file mode 100644 index 00000000..a3c1a1f1 Binary files /dev/null and b/QKSMS/src/main/assets/fonts/Roboto-Medium.ttf differ diff --git a/QKSMS/src/main/assets/fonts/Roboto-Regular.ttf b/QKSMS/src/main/assets/fonts/Roboto-Regular.ttf new file mode 100644 index 00000000..0e58508a Binary files /dev/null and b/QKSMS/src/main/assets/fonts/Roboto-Regular.ttf differ diff --git a/QKSMS/src/main/assets/fonts/Roboto-Thin.ttf b/QKSMS/src/main/assets/fonts/Roboto-Thin.ttf new file mode 100644 index 00000000..8779333b Binary files /dev/null and b/QKSMS/src/main/assets/fonts/Roboto-Thin.ttf differ diff --git a/QKSMS/src/main/assets/fonts/RobotoCondensed-Bold.ttf b/QKSMS/src/main/assets/fonts/RobotoCondensed-Bold.ttf new file mode 100644 index 00000000..3e06c7cd Binary files /dev/null and b/QKSMS/src/main/assets/fonts/RobotoCondensed-Bold.ttf differ diff --git a/QKSMS/src/main/assets/fonts/RobotoCondensed-Light.ttf b/QKSMS/src/main/assets/fonts/RobotoCondensed-Light.ttf new file mode 100644 index 00000000..d4eb1980 Binary files /dev/null and b/QKSMS/src/main/assets/fonts/RobotoCondensed-Light.ttf differ diff --git a/QKSMS/src/main/assets/fonts/RobotoCondensed-Regular.ttf b/QKSMS/src/main/assets/fonts/RobotoCondensed-Regular.ttf new file mode 100644 index 00000000..b9fc49c9 Binary files /dev/null and b/QKSMS/src/main/assets/fonts/RobotoCondensed-Regular.ttf differ 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 c60b6534..ae96ae1f 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(typefaceValue); + typeface = TypefaceManager.obtainTypeface(context, typefaceValue); } a.recycle(); } if (typeface == null) { - typeface = TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_REGULAR); + typeface = TypefaceManager.obtainTypeface(context, 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 06ab1f07..2aedd260 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/TypefaceManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/TypefaceManager.java @@ -1,7 +1,7 @@ package com.moez.QKSMS.common; +import android.content.Context; import android.graphics.Typeface; -import android.os.Build; import android.util.SparseArray; /** @@ -11,7 +11,7 @@ public class TypefaceManager { private final static SparseArray mTypefaces = new SparseArray<>(); - public static Typeface obtainTypeface(int fontFamily, int textWeight) throws IllegalArgumentException { + public static Typeface obtainTypeface(Context context, int fontFamily, int textWeight) throws IllegalArgumentException { int typefaceValue = Typefaces.ROBOTO_REGULAR; switch (fontFamily) { case FontFamily.ROBOTO: @@ -36,6 +36,8 @@ public class TypefaceManager { switch (textWeight) { case TextWeight.THIN: case TextWeight.LIGHT: + typefaceValue = Typefaces.ROBOTO_CONDENSED_LIGHT; + break; case TextWeight.NORMAL: typefaceValue = Typefaces.ROBOTO_CONDENSED_REGULAR; break; @@ -61,39 +63,40 @@ public class TypefaceManager { break; } - return obtainTypeface(typefaceValue); + return obtainTypeface(context, typefaceValue); } - public static Typeface obtainTypeface(int typefaceValue) throws IllegalArgumentException { + public static Typeface obtainTypeface(Context context, int typefaceValue) throws IllegalArgumentException { android.graphics.Typeface typeface = mTypefaces.get(typefaceValue); if (typeface == null) { - typeface = createTypeface(typefaceValue); + typeface = createTypeface(context, typefaceValue); mTypefaces.put(typefaceValue, typeface); } return typeface; } - private static Typeface createTypeface(int typefaceValue) throws IllegalArgumentException { + private static Typeface createTypeface(Context context, int typefaceValue) throws IllegalArgumentException { switch (typefaceValue) { case Typefaces.ROBOTO_THIN: - return Typeface.create("sans-serif-thin", Typeface.NORMAL); + return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Thin.ttf"); case Typefaces.ROBOTO_LIGHT: - return Typeface.create("sans-serif-light", Typeface.NORMAL); + return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf"); case Typefaces.ROBOTO_REGULAR: - return Typeface.create("sans-serif", Typeface.NORMAL); + return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Regular.ttf"); case Typefaces.ROBOTO_MEDIUM: - String name = Build.VERSION.SDK_INT >= 21 ? "sans-serif-medium" : "sans-serif"; - int style = Build.VERSION.SDK_INT >= 21 ? Typeface.NORMAL : Typeface.BOLD; - return Typeface.create(name, style); + return Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Medium.ttf"); + + case Typefaces.ROBOTO_CONDENSED_LIGHT: + return Typeface.createFromAsset(context.getAssets(), "fonts/RobotoCondensed-Light.ttf"); case Typefaces.ROBOTO_CONDENSED_REGULAR: - return Typeface.create("sans-serif-condensed", Typeface.NORMAL); + return Typeface.createFromAsset(context.getAssets(), "fonts/RobotoCondensed-Regular.ttf"); case Typefaces.ROBOTO_CONDENSED_BOLD: - return Typeface.create("sans-serif-condensed", Typeface.BOLD); + return Typeface.createFromAsset(context.getAssets(), "fonts/RobotoCondensed-Bold.ttf"); case Typefaces.DEFAULT_REGULAR: return Typeface.DEFAULT; @@ -111,10 +114,13 @@ public class TypefaceManager { public final static int ROBOTO_LIGHT = 1; public final static int ROBOTO_REGULAR = 2; public final static int ROBOTO_MEDIUM = 3; + public final static int ROBOTO_CONDENSED_REGULAR = 4; public final static int ROBOTO_CONDENSED_BOLD = 5; - public final static int DEFAULT_REGULAR = 6; - public final static int DEFAULT_BOLD = 7; + public final static int ROBOTO_CONDENSED_LIGHT = 6; + + public final static int DEFAULT_REGULAR = 7; + public final static int DEFAULT_BOLD = 8; } public class FontFamily { 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 9fdd8a7f..ea7fff1c 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(TypefaceManager.Typefaces.ROBOTO_LIGHT)); + paint.setTypeface(TypefaceManager.obtainTypeface(context, 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 9415444f..3ddb31a1 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(FontManager.getFontFamily(mContext), + setTypeface(TypefaceManager.obtainTypeface(mContext, FontManager.getFontFamily(mContext), FontManager.getFontWeight(mContext, false))); 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 edda052d..f2b6ff8d 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(TypefaceManager.Typefaces.ROBOTO_LIGHT)); + mPaint.setTypeface(TypefaceManager.obtainTypeface(getContext(), 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 85bb5a07..5b2ff0cc 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(fontFamily, fontWeight + setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight )); 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 8876c05f..1e8ab62c 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(fontFamily, fontWeight + setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight )); // Text size and color