Skip to content
This repository has been archived by the owner on Apr 24, 2018. It is now read-only.

Added a "setHideOnTouchTarget" option. #393

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class ShowcaseView extends RelativeLayout
private boolean hasCustomClickListener = false;
private boolean blockTouches = true;
private boolean hideOnTouch = false;
private boolean hideOnTouchTarget = false;
private OnShowcaseEventListener mEventListener = OnShowcaseEventListener.NONE;

private boolean hasAlteredText = false;
Expand Down Expand Up @@ -274,6 +275,10 @@ public void setButtonText(CharSequence text) {
mEndButton.setText(text);
}
}

public void setHideOnTouchTarget(boolean hideOnTouchTarget){
this.hideOnTouchTarget = hideOnTouchTarget;
}

private void recalculateText() {
boolean recalculatedCling = showcaseAreaCalculator.calculateShowcaseRect(showcaseX, showcaseY, showcaseDrawer);
Expand Down Expand Up @@ -385,6 +390,11 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
if (blocked) {
mEventListener.onShowcaseViewTouchBlocked(motionEvent);
}

if (MotionEvent.ACTION_UP == motionEvent.getAction() &&
hideOnTouchTarget && distanceFromFocus <= showcaseDrawer.getBlockedRadius()) {
this.hide();
}
return blocked;
}

Expand Down Expand Up @@ -538,6 +548,19 @@ public Builder setTarget(Target target) {
showcaseView.setTarget(target);
return this;
}


/**
* Set whether the showcase should hide when the target is touched.
*
* @param hideOnTouchTarget true if this showcase should hide when the specified target is
* touched. The showcase will hide when a touch is performed anywhere inside the
* focus area.
*/
public Builder setHideOnTouchTarget(boolean hideOnTouchTarget){
showcaseView.setHideOnTouchTarget(hideOnTouchTarget);
return this;
}

/**
* Set the style of the ShowcaseView. See the sample app for example styles.
Expand Down