diff --git a/README.md b/README.md index e9ce951..aadcb9b 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ showcaseManager.show(context) // or showcaseManager.show(context, REQUEST_CODE_S | `builder.imageUrl(String)` | show image on tooltip | yes | null | no | | `builder.customContent(Int)` | show given layout | yes | null | no | | `builder.statusBarVisible(Boolean)` | statusBar visibility of window | yes | true | no | +| `builder.toolTipVisible(Boolean)` | tooltip visibility | yes | true | no | +| `builder.highlightRadius(Float, Float, Float, Float)` | tooltip visibility | yes | 0f, 0f, 0f, 0f | no | | `builder.setSlidableContentList(List)` | show slidable content | yes | null | no | | `builder.build()` | will return ShowcaseManager instance | no | | | | `showcaseManager.show(Context)` | show the tooltip with set attributes on | no | | | diff --git a/library/build.gradle b/library/build.gradle index 3cb63d8..d61584c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -17,8 +17,8 @@ android { defaultConfig { minSdkVersion 17 targetSdkVersion 30 - versionCode 13 - versionName "1.1.0" + versionCode 14 + versionName "1.2.0" vectorDrawables.useSupportLibrary = true } diff --git a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt index b7f3082..9198eed 100644 --- a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt +++ b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt @@ -131,12 +131,18 @@ class ShowcaseManager private constructor( @StyleRes private var resId: Int? = null - private var cancellableFromOutsideTouch: Boolean = Constants.DEFAULT_CANCELLABLE_FROM_OUTSIDE_TOUCH + private var cancellableFromOutsideTouch: Boolean = + Constants.DEFAULT_CANCELLABLE_FROM_OUTSIDE_TOUCH private var isShowcaseViewClickable: Boolean = Constants.DEFAULT_SHOWCASE_VIEW_CLICKABLE private var isDebugMode: Boolean = false private var attachOnParentLifecycle: Boolean = false private var textPosition: TextPosition = Constants.DEFAULT_TEXT_POSITION private var imageUrl: String = Constants.DEFAULT_TEXT + private var radiusTopStart: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS + private var radiusTopEnd: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS + private var radiusBottomStart: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS + private var radiusBottomEnd: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS + private var isToolTipVisible: Boolean = true @LayoutRes private var customContent: Int? = null @@ -177,7 +183,8 @@ class ShowcaseManager private constructor( * * @param fontFamily assigns fontFamily to descriptionText */ - fun descriptionTextFontFamily(fontFamily: String) = apply { descriptionTextFontFamily = fontFamily } + fun descriptionTextFontFamily(fontFamily: String) = + apply { descriptionTextFontFamily = fontFamily } /** * Assign textStyle to descriptionText @@ -242,7 +249,31 @@ class ShowcaseManager private constructor( * * @param clickable Set the value to true so that the showcase view is clickable */ - fun showcaseViewClickable(clickable: Boolean) = apply { isShowcaseViewClickable = clickable } + fun showcaseViewClickable(clickable: Boolean) = + apply { isShowcaseViewClickable = clickable } + + /** + * + * radius for highlight area. + */ + fun highlightRadius( + topStartRadius: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS, + topEndRadius: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS, + bottomStartRadius: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS, + bottomEndRadius: Float = Constants.DEFAULT_HIGHLIGHT_RADIUS + ) = apply { + radiusTopStart = topStartRadius + radiusTopEnd = topEndRadius + radiusBottomStart = bottomStartRadius + radiusBottomEnd = bottomEndRadius + } + + /** + * + * show toolTip or not. + */ + fun toolTipVisible(isToolTipVisible: Boolean) = + apply { this.isToolTipVisible = isToolTipVisible } /** * Running in debug mode or not @@ -314,6 +345,11 @@ class ShowcaseManager private constructor( customContent = customContent, isStatusBarVisible = isStatusBarVisible, slidableContentList = slidableContentList, + radiusTopStart = radiusTopStart, + radiusTopEnd = radiusTopEnd, + radiusBottomEnd = radiusBottomEnd, + radiusBottomStart = radiusBottomStart, + isToolTipVisible = isToolTipVisible ) return ShowcaseManager(showcaseModel = showcaseModel, resId = resId) diff --git a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt index 664fc0f..52f42ed 100644 --- a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt +++ b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt @@ -45,6 +45,11 @@ data class ShowcaseModel( @LayoutRes val customContent: Int?, val isStatusBarVisible: Boolean, val slidableContentList: List?, + val radiusTopStart: Float, + val radiusTopEnd: Float, + val radiusBottomEnd: Float, + val radiusBottomStart: Float, + val isToolTipVisible: Boolean ) : Parcelable { fun horizontalCenter() = rectF.left + ((rectF.right - rectF.left) / 2) diff --git a/library/src/main/java/com/trendyol/showcase/ui/showcase/ShowcaseView.kt b/library/src/main/java/com/trendyol/showcase/ui/showcase/ShowcaseView.kt index a511a36..56b7c0b 100644 --- a/library/src/main/java/com/trendyol/showcase/ui/showcase/ShowcaseView.kt +++ b/library/src/main/java/com/trendyol/showcase/ui/showcase/ShowcaseView.kt @@ -59,7 +59,11 @@ class ShowcaseView @JvmOverloads constructor( left = model.rectF.left - (model.highlightPadding / 2), top = model.rectF.top - (model.highlightPadding / 2), right = model.rectF.right + (model.highlightPadding / 2), - bottom = model.rectF.bottom + (model.highlightPadding / 2) + bottom = model.rectF.bottom + (model.highlightPadding / 2), + radiusTopStart = model.radiusTopStart, + radiusTopEnd = model.radiusTopEnd, + radiusBottomEnd = model.radiusBottomEnd, + radiusBottomStart = model.radiusBottomStart ) } } diff --git a/library/src/main/java/com/trendyol/showcase/ui/tooltip/TooltipViewState.kt b/library/src/main/java/com/trendyol/showcase/ui/tooltip/TooltipViewState.kt index 5edf9cd..7cec3a5 100644 --- a/library/src/main/java/com/trendyol/showcase/ui/tooltip/TooltipViewState.kt +++ b/library/src/main/java/com/trendyol/showcase/ui/tooltip/TooltipViewState.kt @@ -69,4 +69,6 @@ internal data class TooltipViewState( fun isShowcaseViewClickable() = showcaseModel.isShowcaseViewClickable fun isSlidableContentVisible() = showcaseModel.slidableContentList.isNullOrEmpty().not() + + fun isToolTipVisible() = showcaseModel.isToolTipVisible } diff --git a/library/src/main/java/com/trendyol/showcase/util/Constants.kt b/library/src/main/java/com/trendyol/showcase/util/Constants.kt index ee8ce54..ce6c142 100644 --- a/library/src/main/java/com/trendyol/showcase/util/Constants.kt +++ b/library/src/main/java/com/trendyol/showcase/util/Constants.kt @@ -27,4 +27,5 @@ object Constants { val DEFAULT_TEXT_POSITION = TextPosition.START const val DEFAULT_CANCELLABLE_FROM_OUTSIDE_TOUCH = false const val DEFAULT_SHOWCASE_VIEW_CLICKABLE = false + const val DEFAULT_HIGHLIGHT_RADIUS = 0f } \ No newline at end of file diff --git a/library/src/main/java/com/trendyol/showcase/util/shape/RectangleShape.kt b/library/src/main/java/com/trendyol/showcase/util/shape/RectangleShape.kt index 44d1e6f..9ed8337 100644 --- a/library/src/main/java/com/trendyol/showcase/util/shape/RectangleShape.kt +++ b/library/src/main/java/com/trendyol/showcase/util/shape/RectangleShape.kt @@ -1,6 +1,7 @@ package com.trendyol.showcase.util.shape import android.graphics.Canvas +import android.graphics.Path import android.graphics.RectF class RectangleShape( @@ -10,12 +11,29 @@ class RectangleShape( private val left: Float, private val top: Float, private val right: Float, - private val bottom: Float + private val bottom: Float, + private val radiusTopStart: Float, + private val radiusTopEnd: Float, + private val radiusBottomEnd: Float, + private val radiusBottomStart: Float, ) : Shape(screenWidth, screenHeight) { + private val path = Path() + private val corners = floatArrayOf( + radiusTopStart, + radiusTopStart, + radiusTopEnd, + radiusTopEnd, + radiusBottomEnd, + radiusBottomEnd, + radiusBottomStart, + radiusBottomStart + ) + override fun draw(windowBackgroundColor: Int, windowBackgroundAlpha: Int, canvas: Canvas) { super.draw(windowBackgroundColor, windowBackgroundAlpha, canvas) val rectF = RectF(left, top + statusBarDiff, right, bottom + statusBarDiff) - canvas.drawRect(rectF, paint) + path.addRoundRect(rectF, corners, Path.Direction.CW) + canvas.drawPath(path, paint) } } diff --git a/library/src/main/res/layout/layout_showcase.xml b/library/src/main/res/layout/layout_showcase.xml index f3b5749..54e8da2 100644 --- a/library/src/main/res/layout/layout_showcase.xml +++ b/library/src/main/res/layout/layout_showcase.xml @@ -22,6 +22,7 @@ android:id="@+id/tooltipView" android:layout_width="match_parent" android:layout_height="wrap_content" + app:isVisible="@{tooltipViewState.isToolTipVisible()}" app:applyMargin="@{showcaseViewState.margin}" app:arrowPosition="@{tooltipViewState.arrowPosition}" app:layout_constraintBottom_toBottomOf="parent" diff --git a/sample/src/main/java/com/trendyol/sample/SampleFragment.kt b/sample/src/main/java/com/trendyol/sample/SampleFragment.kt index d09e973..2e86852 100644 --- a/sample/src/main/java/com/trendyol/sample/SampleFragment.kt +++ b/sample/src/main/java/com/trendyol/sample/SampleFragment.kt @@ -103,6 +103,14 @@ class SampleFragment : Fragment() { .highlightType(HighlightType.RECTANGLE) .highlightPadding(8f) .textPosition(TextPosition.START) + .highlightRadius( + bottomEndRadius = 16f, + topStartRadius = 16f, + topEndRadius = 16f, + bottomStartRadius = 16f + ) + .cancellableFromOutsideTouch(true) + .toolTipVisible(false) .statusBarVisible(isStatusBarVisible) .build() .show(this@SampleFragment, REQUEST_CODE_SHOWCASE_CLICKED)