Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 新增配置项,允许高亮展示目标 view 的父 view #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion app/src/main/java/com/demo/aty/SimpleGuideViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public void showGuideView2() {
final GuideBuilder builder1 = new GuideBuilder();
builder1.setTargetView(ll_nearby)
.setAlpha(150)
.setHighTargetGraphStyle(Component.CIRCLE);
.setHighTargetGraphStyle(Component.ROUNDRECT)
.setIsHighlightParent(true);
builder1.setOnVisibilityChangedListener(new GuideBuilder.OnVisibilityChangedListener() {
@Override
public void onShown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class Configuration implements Parcelable {

int mExitAnimationId = -1;

/**
* 是否高亮显示父 view
*/
boolean mIsHighlightShowParent = false;

@Override
public int describeContents() {
return 0;
Expand All @@ -110,6 +115,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mGraphStyle);
dest.writeByte((byte) (mAutoDismiss ? 1 : 0));
dest.writeByte((byte) (mOverlayTarget ? 1 : 0));
dest.writeByte((byte) (mIsHighlightShowParent ? 1 : 0));
}

public static final Creator<Configuration> CREATOR = new Creator<Configuration>() {
Expand All @@ -129,6 +135,7 @@ public Configuration createFromParcel(Parcel source) {
conf.mGraphStyle = source.readInt();
conf.mAutoDismiss = source.readByte() == 1;
conf.mOverlayTarget = source.readByte() == 1;
conf.mIsHighlightShowParent = source.readByte() == 1;
return conf;
}

Expand Down
16 changes: 14 additions & 2 deletions guideview/src/main/java/com/binioter/guideview/Guide.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,24 @@ private MaskView onCreateView(Activity activity, ViewGroup overlay) {
}

if (mConfiguration.mTargetView != null) {
maskView.setTargetRect(Common.getViewAbsRect(mConfiguration.mTargetView, parentX, parentY));
if (mConfiguration.mIsHighlightShowParent &&
mConfiguration.mTargetView.getParent() != null) {
maskView.setTargetRect(Common.getViewAbsRect((View) mConfiguration.mTargetView.getParent(),
parentX, parentY));
} else {
maskView.setTargetRect(Common.getViewAbsRect(mConfiguration.mTargetView, parentX, parentY));
}
} else {
// Gets the target view's abs rect
View target = activity.findViewById(mConfiguration.mTargetViewId);
if (target != null) {
maskView.setTargetRect(Common.getViewAbsRect(target, parentX, parentY));
if (mConfiguration.mIsHighlightShowParent &&
target.getParent() != null) {
maskView.setTargetRect(Common.getViewAbsRect((View) target.getParent(),
parentX, parentY));
} else {
maskView.setTargetRect(Common.getViewAbsRect(target, parentX, parentY));
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions guideview/src/main/java/com/binioter/guideview/GuideBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,19 @@ public GuideBuilder setHighTargetPaddingBottom(int padding) {
return this;
}

/**
* 是否高粱展示父 view
*
* @return GuideBuilder
*/
public GuideBuilder setIsHighlightParent(boolean isHighlightParent) {
if (mBuilt) {
throw new BuildException("Already created. rebuild a new one.");
}
mConfiguration.mIsHighlightShowParent = isHighlightParent;
return this;
}

/**
* 创建Guide,非Fragment版本
*
Expand Down