From 6090c74240e3ba32344912b6eb45176cf512e00f Mon Sep 17 00:00:00 2001 From: Aimar Ugarte Date: Fri, 6 Sep 2019 21:27:05 +0200 Subject: [PATCH 1/2] Added option to choose the dim opacity --- .../java/com/getkeepsafe/taptargetview/TapTarget.java | 11 +++++++++++ .../com/getkeepsafe/taptargetview/TapTargetView.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java index aeb0ab9..d88b2d7 100644 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTarget.java @@ -44,6 +44,7 @@ public class TapTarget { @Nullable final CharSequence description; + float dimColorOpacity = 0.3f; float outerCircleAlpha = 0.96f; int targetRadius = 44; @@ -371,6 +372,16 @@ public TapTarget dimColorInt(@ColorInt int color) { return this; } + /** **/ /** + * Specify the opacity for the dim color + *

+ * Note: The specified opacity will range between 0 and 1 been the second 100% opacity + */ + public TapTarget dimColorOpacity(float opacity){ + this.dimColorOpacity = opacity; + return this; + } + /** Specify whether or not to draw a drop shadow around the outer circle **/ public TapTarget drawShadow(boolean draw) { this.drawShadow = draw; diff --git a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java index c21735d..4a0f1b0 100644 --- a/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java +++ b/taptargetview/src/main/java/com/getkeepsafe/taptargetview/TapTargetView.java @@ -609,7 +609,7 @@ public void getOutline(View view, Outline outline) { final Integer targetDimColor = target.dimColorInt(context); if (targetDimColor != null) { - dimColor = UiUtil.setAlpha(targetDimColor, 0.3f); + dimColor = UiUtil.setAlpha(targetDimColor, target.dimColorOpacity); } else { dimColor = -1; } From cde45d21f31e37ebcbb270d95bf59e47f1b72ba3 Mon Sep 17 00:00:00 2001 From: Aimar Ugarte Date: Sat, 23 Oct 2021 13:36:36 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f5f16e..5255de9 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ TapTargetView.showFor(this, // `this` is an Activity TapTarget.forView(findViewById(R.id.target), "This is a target", "We have the best targets, believe me") // All options below are optional .outerCircleColor(R.color.red) // Specify a color for the outer circle - .outerCircleAlpha(0.96f) // Specify the alpha amount for the outer circle + .outerCircleAlpha(0.96f) // Specify the alpha amount for the outer circle .targetCircleColor(R.color.white) // Specify a color for the target circle .titleTextSize(20) // Specify the size (in sp) of the title text .titleTextColor(R.color.white) // Specify the color of the title text @@ -50,7 +50,8 @@ TapTargetView.showFor(this, // `this` is an Activity .descriptionTextColor(R.color.red) // Specify the color of the description text .textColor(R.color.blue) // Specify a color for both the title and description text .textTypeface(Typeface.SANS_SERIF) // Specify a typeface for the text - .dimColor(R.color.black) // If set, will dim behind the view with 30% opacity of the given color + .dimColor(R.color.black) // If set, will dim behind the view with the given color + .dimColorOpacity(0.75f) // Specify the dim opacity for given color, 30% opacity if not set. .drawShadow(true) // Whether to draw a drop shadow or not .cancelable(false) // Whether tapping outside the outer circle dismisses the view .tintTarget(true) // Whether to tint the target view's color