Skip to content

Commit

Permalink
Add support to customize tooltip for tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavpandey committed Jul 3, 2022
1 parent f0843ef commit 1691994
Showing 1 changed file with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ public void onPageScrolled(int position,
}

onSetColor(position, color, tintColor);
onSetTooltip(position, color, tintColor);

Dynamic.onPageScrolled(getTutorial(position), position,
positionOffset, positionOffsetPixels);
Dynamic.onSetPadding(getTutorial(position), 0, 0, 0, mFooterHeight);
Expand All @@ -208,6 +210,10 @@ public void onPageSelected(int position) {
onSetColor(position, Dynamic.getColor(
getTutorial(position), getBackgroundColor()),
Dynamic.getTintColor(getTutorial(position), getTintColor()));
onSetTooltip(position, Dynamic.getColor(
getTutorial(position), getBackgroundColor()),
Dynamic.getTintColor(getTutorial(position), getTintColor()));

Dynamic.onPageSelected(getTutorial(position), position);
Dynamic.onSetPadding(getTutorial(position),
0, 0, 0, mFooterHeight);
Expand All @@ -226,6 +232,10 @@ public void onPageScrollStateChanged(int state) {
onSetColor(getCurrentPosition(), Dynamic.getColor(getTutorial(
getCurrentPosition()), getBackgroundColor()), Dynamic.getTintColor(
getTutorial(getCurrentPosition()), getTintColor()));
onSetTooltip(getCurrentPosition(), Dynamic.getColor(getTutorial(
getCurrentPosition()), getBackgroundColor()), Dynamic.getTintColor(
getTutorial(getCurrentPosition()), getTintColor()));

Dynamic.onColorChanged(getTutorial(getCurrentPosition()),
Dynamic.getColor(getTutorial(getCurrentPosition()),
getBackgroundColor()), Dynamic.getTintColor(getTutorial(
Expand Down Expand Up @@ -585,13 +595,29 @@ protected void onSetColor(int position, @ColorInt int color, @ColorInt int tintC
this, R.drawable.ads_ic_check));
Dynamic.setContentDescription(mActionNext, getString(R.string.ads_finish));
}
}

/**
* This method will be called to set the tooltip for the tutorial actions.
*
* @param position The current position of the tutorial.
* @param color The background color to be applied.
* @param tintColor The tint color to be applied.
*/
protected void onSetTooltip(int position, @ColorInt int color, @ColorInt int tintColor) {
if (getActionPrevious() != null) {
DynamicTooltip.set(getActionPrevious(),
Dynamic.getColor(getActionPrevious(), tintColor),
Dynamic.getContrastWithColor(getActionPrevious(), color),
getActionPrevious().getContentDescription());
}

DynamicTooltip.set(mActionPrevious, Dynamic.getColor(mActionPrevious, tintColor),
Dynamic.getContrastWithColor(mActionPrevious, color),
mActionPrevious.getContentDescription());
DynamicTooltip.set(mActionNext, Dynamic.getColor(mActionNext, tintColor),
Dynamic.getContrastWithColor(mActionNext, color),
mActionNext.getContentDescription());
if (getActionNext() != null) {
DynamicTooltip.set(getActionNext(),
Dynamic.getColor(getActionNext(), tintColor),
Dynamic.getContrastWithColor(getActionNext(), color),
getActionNext().getContentDescription());
}
}

/**
Expand Down

0 comments on commit 1691994

Please sign in to comment.