Skip to content

Commit

Permalink
Add New feature to change text of Next Button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Haider committed Sep 14, 2022
1 parent e02f777 commit 2428527
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class BubbleMessageView : ConstraintLayout {
if (builder.mShowNextButton) {
nextButton?.visibility = View.VISIBLE
}

if (builder.mNextButtonText != null) {
nextButton?.text = builder.mNextButtonText
}
}

private fun setBubbleListener(builder: Builder) {
Expand Down Expand Up @@ -288,6 +292,7 @@ class BubbleMessageView : ConstraintLayout {
var mArrowPosition = ArrayList<BubbleShowCase.ArrowPosition>()
var mListener: OnBubbleMessageViewListener? = null
var mShowNextButton: Boolean = false
var mNextButtonText: String? = null

fun from(context: Context): Builder {
mContext = WeakReference(context)
Expand Down Expand Up @@ -355,6 +360,11 @@ class BubbleMessageView : ConstraintLayout {
return this
}

fun setNextButtonText(text: String?): Builder {
mNextButtonText = text
return this
}

fun listener(listener: OnBubbleMessageViewListener?): Builder {
mListener = listener
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class BubbleShowCase(builder: BubbleShowCaseBuilder) {
private val mSubtitleTextSize: Int? = builder.mSubtitleTextSize
private val mShowOnce: String? = builder.mShowOnce
private val mShowNextButton: Boolean = builder.mShowNextButton
private val mNextButtonText: String? = builder.mNextButtonText
private val mDisableTargetClick: Boolean = builder.mDisableTargetClick
private val mDisableCloseAction: Boolean = builder.mDisableCloseAction
private val mHighlightMode: HighlightMode? = builder.mHighlightMode
Expand Down Expand Up @@ -195,6 +196,7 @@ class BubbleShowCase(builder: BubbleShowCaseBuilder) {
.subtitle(mSubtitle)
.image(mImage)
.showNextButton(mShowNextButton)
.setNextButtonText(mNextButtonText)
.closeActionImage(mCloseAction)
.disableCloseAction(mDisableCloseAction)
.listener(object : OnBubbleMessageViewListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BubbleShowCaseBuilder(activity: Activity) {
internal var mBubbleShowCaseListener: BubbleShowCaseListener? = null
internal var mSequenceShowCaseListener: SequenceShowCaseListener? = null
internal var mShowNextButton: Boolean = false
internal var mNextButtonText: String? = null

private var onGlobalLayoutListenerTargetView: ViewTreeObserver.OnGlobalLayoutListener? = null

Expand Down Expand Up @@ -224,6 +225,15 @@ class BubbleShowCaseBuilder(activity: Activity) {
return this
}

/**
* Set a text of Next Button
* Default value -> Next
*/
fun setNextButtonText(text: String): BubbleShowCaseBuilder {
mNextButtonText = text
return this
}

/**
* Add a BubbleShowCaseListener in order to listen the user actions:
* - onTargetClick -> It is triggered when the user clicks on the target view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MainActivity : AppCompatActivity() {
.descriptionTextSize(16)
.closeActionImage(null)
.showNextButton(true)
.setNextButtonText("Finish")
.targetView(binding.buttonTextSizeShowCase)
}

Expand Down

0 comments on commit 2428527

Please sign in to comment.