From 9c8a5aa70a200f0e316ccd0b5414bc83b02228d5 Mon Sep 17 00:00:00 2001 From: Dani Mahardhika Date: Fri, 5 May 2017 23:51:45 +0700 Subject: [PATCH 1/2] Separate title and description typeface - Added textTypeface(titleTypeface, descriptionTypeface) --- .../com/getkeepsafe/taptargetview/TapTarget.java | 15 +++++++++++---- .../getkeepsafe/taptargetview/TapTargetView.java | 9 ++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java index e718457..9935531 100755 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java @@ -23,6 +23,7 @@ import android.support.annotation.ColorRes; import android.support.annotation.DimenRes; import android.support.annotation.IdRes; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.support.v7.widget.Toolbar; @@ -49,7 +50,8 @@ public class TapTarget { Rect bounds; Drawable icon; - Typeface typeface; + Typeface titleTypeface; + Typeface descriptionTypeface; @ColorRes private int outerCircleColorRes = -1; @@ -284,9 +286,14 @@ public TapTarget descriptionTextColorInt(@ColorInt int color) { } /** Specify the typeface for all text **/ - public TapTarget textTypeface(Typeface typeface) { - if (typeface == null) throw new IllegalArgumentException("Cannot use a null typeface"); - this.typeface = typeface; + public TapTarget textTypeface(@NonNull Typeface typeface) { + return textTypeface(typeface, typeface); + } + + /** Specify the typeface for title and description text **/ + public TapTarget textTypeface(@NonNull Typeface titleTypeface, @NonNull Typeface descriptionTypeface) { + this.titleTypeface = titleTypeface; + this.descriptionTypeface = descriptionTypeface; return this; } diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java index 7a1b7ea..29f0f34 100755 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java @@ -589,9 +589,12 @@ public void getOutline(View view, Outline outline) { descriptionPaint.setColor(titlePaint.getColor()); } - if (target.typeface != null) { - titlePaint.setTypeface(target.typeface); - descriptionPaint.setTypeface(target.typeface); + if (target.titleTypeface != null) { + titlePaint.setTypeface(target.titleTypeface); + } + + if (target.descriptionTypeface != null) { + descriptionPaint.setTypeface(target.descriptionTypeface); } } From 0092101537cf525875997027de53c10dd5fe0b6e Mon Sep 17 00:00:00 2001 From: Dani Mahardhika Date: Sat, 6 May 2017 14:06:44 +0700 Subject: [PATCH 2/2] Separate title and description typeface - titleTypeface(Typeface) - descriptionTypeface(Typeface) --- .../getkeepsafe/taptargetview/TapTarget.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java index 9935531..e338087 100755 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java @@ -23,7 +23,6 @@ import android.support.annotation.ColorRes; import android.support.annotation.DimenRes; import android.support.annotation.IdRes; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.support.v7.widget.Toolbar; @@ -286,13 +285,23 @@ public TapTarget descriptionTextColorInt(@ColorInt int color) { } /** Specify the typeface for all text **/ - public TapTarget textTypeface(@NonNull Typeface typeface) { - return textTypeface(typeface, typeface); + public TapTarget textTypeface(Typeface typeface) { + if (typeface == null) throw new IllegalArgumentException("Cannot use a null typeface"); + titleTypeface = typeface; + descriptionTypeface = typeface; + return this; } - /** Specify the typeface for title and description text **/ - public TapTarget textTypeface(@NonNull Typeface titleTypeface, @NonNull Typeface descriptionTypeface) { + /** Specify the typeface for title text **/ + public TapTarget titleTypeface(Typeface titleTypeface) { + if (titleTypeface == null) throw new IllegalArgumentException("Cannot use a null typeface"); this.titleTypeface = titleTypeface; + return this; + } + + /** Specify the typeface for description text **/ + public TapTarget descriptionTypeface(Typeface descriptionTypeface) { + if (descriptionTypeface == null) throw new IllegalArgumentException("Cannot use a null typeface"); this.descriptionTypeface = descriptionTypeface; return this; }