diff --git a/build.gradle b/build.gradle index 75af8da..123b269 100644 --- a/build.gradle +++ b/build.gradle @@ -27,8 +27,8 @@ ext { supportLibVersion = '25.3.1' - versionCode = 123 - versionName = '1.2.3' + versionCode = 125 + versionName = '1.2.5' } task clean(type: Delete) { diff --git a/toasty/src/main/java/es/dmoral/toasty/Toasty.java b/toasty/src/main/java/es/dmoral/toasty/Toasty.java index 5f3b9ee..901cbe6 100644 --- a/toasty/src/main/java/es/dmoral/toasty/Toasty.java +++ b/toasty/src/main/java/es/dmoral/toasty/Toasty.java @@ -9,6 +9,7 @@ import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; @@ -44,9 +45,12 @@ public class Toasty { private static int SUCCESS_COLOR = Color.parseColor("#388E3C"); @ColorInt private static int WARNING_COLOR = Color.parseColor("#FFA900"); + @ColorInt + private static int NORMAL_COLOR = Color.parseColor("#353A3E"); private static final Typeface LOADED_TOAST_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.NORMAL); private static Typeface currentTypeface = LOADED_TOAST_TYPEFACE; + private static int textSize = 16; // in SP private static boolean tintIcon = true; @@ -78,7 +82,7 @@ public static Toast normal(@NonNull Context context, @NonNull CharSequence messa @CheckResult public static Toast normal(@NonNull Context context, @NonNull CharSequence message, int duration, Drawable icon, boolean withIcon) { - return custom(context, message, icon, duration, withIcon); + return custom(context, message, icon, NORMAL_COLOR, duration, withIcon, true); } @CheckResult @@ -189,6 +193,7 @@ public static Toast custom(@NonNull Context context, @NonNull CharSequence messa toastTextView.setTextColor(DEFAULT_TEXT_COLOR); toastTextView.setText(message); toastTextView.setTypeface(currentTypeface); + toastTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); currentToast.setView(toastLayout); currentToast.setDuration(duration); @@ -208,6 +213,7 @@ public static class Config { private int WARNING_COLOR = Toasty.WARNING_COLOR; private Typeface typeface = Toasty.currentTypeface; + private int textSize = Toasty.textSize; private boolean tintIcon = Toasty.tintIcon; @@ -227,6 +233,7 @@ public static void reset() { Toasty.SUCCESS_COLOR = Color.parseColor("#388E3C"); Toasty.WARNING_COLOR = Color.parseColor("#FFA900"); Toasty.currentTypeface = LOADED_TOAST_TYPEFACE; + Toasty.textSize = 16; Toasty.tintIcon = true; } @@ -266,6 +273,12 @@ public Config setToastTypeface(@NonNull Typeface typeface) { return this; } + @CheckResult + public Config setTextSize(int sizeInSp) { + this.textSize = sizeInSp; + return this; + } + @CheckResult public Config tintIcon(boolean tintIcon) { this.tintIcon = tintIcon; @@ -279,6 +292,7 @@ public void apply() { Toasty.SUCCESS_COLOR = SUCCESS_COLOR; Toasty.WARNING_COLOR = WARNING_COLOR; Toasty.currentTypeface = typeface; + Toasty.textSize = textSize; Toasty.tintIcon = tintIcon; } }