Skip to content
This repository was archived by the owner on Nov 10, 2024. It is now read-only.
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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ new GuideView.Builder(MainActivity.this)
.show();
```

## Set shape/pointer type solid/filled
```java
new GuideView.Builder(this)
.setTitle("Guide Title Text")
.setContentText("Guide Description Text\n .....Guide Description Text\n .....Guide Description Text .....")
.setTargetView(view)
.isShapeSolid(false) //optional - default is false
.build()
.show();
```

### DismissType Attribute

| Type | Description |
Expand All @@ -150,6 +161,14 @@ new GuideView.Builder(MainActivity.this)
| none | Show no pointer or line towards targetView |


### isShapeSolid Attribute

| Type | Description |
| ------ | ------ |
| true | Show shape pointer as solid/filled |
| false | Show shape pointer as not solid |


## Contribution :collision:

Pull requests are welcome! :clap:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ir.smartdevelop.eram.showcaseview;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
Expand All @@ -8,7 +9,6 @@
import smartdevelop.ir.eram.showcaseviewlib.config.DismissType;
import smartdevelop.ir.eram.showcaseviewlib.config.Gravity;
import smartdevelop.ir.eram.showcaseviewlib.config.PointerType;
import smartdevelop.ir.eram.showcaseviewlib.listener.GuideListener;

public class MainActivity extends AppCompatActivity {

Expand All @@ -21,6 +21,7 @@ public class MainActivity extends AppCompatActivity {
private GuideView mGuideView;
private GuideView.Builder builder;

@SuppressLint("NonConstantResourceId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -39,6 +40,7 @@ protected void onCreate(Bundle savedInstanceState) {
.setGravity(Gravity.center)
.setDismissType(DismissType.anywhere)
.setPointerType(PointerType.circle)
.isShapeSolid(false)
.setTargetView(view1)
.setGuideListener(view -> {
switch (view.getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class GuideView extends FrameLayout {
private DismissType dismissType;
private PointerType pointerType;
private final GuideMessageView mMessageView;
private boolean isShapeSolid;

private GuideView(Context context, View view) {
super(context);
Expand All @@ -100,19 +101,19 @@ private GuideView(Context context, View view) {

mMessageView = new GuideMessageView(getContext());
mMessageView.setPadding(
messageViewPadding,
messageViewPadding,
messageViewPadding,
messageViewPadding
messageViewPadding,
messageViewPadding,
messageViewPadding,
messageViewPadding
);
mMessageView.setColor(Color.WHITE);

addView(
mMessageView,
new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
mMessageView,
new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
);

ViewTreeObserver.OnGlobalLayoutListener layoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
Expand All @@ -130,21 +131,21 @@ public void onGlobalLayout() {
int[] locationTarget = new int[2];
target.getLocationOnScreen(locationTarget);
targetRect = new RectF(
locationTarget[0],
locationTarget[1],
locationTarget[0] + target.getWidth(),
locationTarget[1] + target.getHeight()
locationTarget[0],
locationTarget[1],
locationTarget[0] + target.getWidth(),
locationTarget[1] + target.getHeight()
);
if (isLandscape()) {
targetRect.offset(-getStatusBarHeight(), 0);
}
}

backgroundRect.set(
getPaddingLeft(),
getPaddingTop(),
getWidth() - getPaddingRight(),
getHeight() - getPaddingBottom()
getPaddingLeft(),
getPaddingTop(),
getWidth() - getPaddingRight(),
getHeight() - getPaddingBottom()
);
if (isLandscape()) {
backgroundRect.offset(-getNavigationBarSize(), 0);
Expand All @@ -166,8 +167,8 @@ public void onGlobalLayout() {
private void startAnimationSize() {
if (!isPerformedAnimationSize) {
final ValueAnimator circleSizeAnimator = ValueAnimator.ofFloat(
0f,
circleIndicatorSizeFinal
0f,
circleIndicatorSizeFinal
);
circleSizeAnimator.addUpdateListener(valueAnimator -> {
circleIndicatorSize = (float) circleSizeAnimator.getAnimatedValue();
Expand All @@ -176,8 +177,8 @@ private void startAnimationSize() {
});

final ValueAnimator linePositionAnimator = ValueAnimator.ofFloat(
stopY,
startYLineAndCircle
stopY,
startYLineAndCircle
);
linePositionAnimator.addUpdateListener(valueAnimator -> {
startYLineAndCircle = (float) linePositionAnimator.getAnimatedValue();
Expand Down Expand Up @@ -259,28 +260,35 @@ protected void onDraw(final Canvas canvas) {
paintLine.setStrokeWidth(lineIndicatorWidthSize);
paintLine.setAntiAlias(true);

paintCircle.setStyle(Paint.Style.STROKE);
if (isShapeSolid)
paintCircle.setStyle(Paint.Style.FILL);
else
paintCircle.setStyle(Paint.Style.STROKE);
paintCircle.setColor(CIRCLE_INDICATOR_COLOR);
paintCircle.setStrokeCap(Paint.Cap.ROUND);
paintCircle.setStrokeWidth(strokeCircleWidth);
paintCircle.setAntiAlias(true);

paintCircleInner.setStyle(Paint.Style.FILL);
paintCircleInner.setColor(CIRCLE_INNER_INDICATOR_COLOR);
paintCircleInner.setAntiAlias(true);

if (!isShapeSolid) {
paintCircleInner.setStyle(Paint.Style.FILL);
paintCircleInner.setColor(CIRCLE_INNER_INDICATOR_COLOR);
paintCircleInner.setAntiAlias(true);
}
final float x = (targetRect.left / 2 + targetRect.right / 2);

switch (pointerType) {
case circle:
canvas.drawLine(x, startYLineAndCircle, x, stopY, paintLine);
canvas.drawCircle(x, startYLineAndCircle, circleIndicatorSize, paintCircle);
canvas.drawCircle(
x,
startYLineAndCircle,
circleInnerIndicatorSize,
paintCircleInner
);

// to remove solid & inner circle drawing
if (!isShapeSolid)
canvas.drawCircle(
x,
startYLineAndCircle,
circleInnerIndicatorSize,
paintCircleInner
);
break;
case arrow:
canvas.drawLine(x, startYLineAndCircle, x, stopY, paintLine);
Expand All @@ -306,10 +314,10 @@ protected void onDraw(final Canvas canvas) {
canvas.drawPath(((Targetable) target).guidePath(), targetPaint);
} else {
canvas.drawRoundRect(
targetRect,
RADIUS_SIZE_TARGET_RECT,
RADIUS_SIZE_TARGET_RECT,
targetPaint
targetRect,
RADIUS_SIZE_TARGET_RECT,
RADIUS_SIZE_TARGET_RECT,
targetPaint
);
}
}
Expand Down Expand Up @@ -430,8 +438,8 @@ private Point resolveMessageViewLocation() {

public void show() {
this.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
this.setClickable(false);
((ViewGroup) ((Activity) getContext()).getWindow().getDecorView()).addView(this);
Expand Down Expand Up @@ -477,6 +485,7 @@ public static class Builder {
private Gravity gravity;
private DismissType dismissType;
private PointerType pointerType;
private boolean isShapeSolid;
private final Context context;
private Spannable contentSpan;
private Typeface titleTypeFace, contentTypeFace;
Expand Down Expand Up @@ -660,11 +669,22 @@ public Builder setPointerType(PointerType pointerType) {
return this;
}

/**
* this method defining the type of pointer
*
* @param isShapeSolid should be true/false to fill the shape arrow -> To be filled/solid you must set this parameter to true
*/
public Builder isShapeSolid(boolean isShapeSolid) {
this.isShapeSolid = isShapeSolid;
return this;
}

public GuideView build() {
GuideView guideView = new GuideView(context, targetView);
guideView.mGravity = gravity != null ? gravity : Gravity.auto;
guideView.dismissType = dismissType != null ? dismissType : DismissType.targetView;
guideView.pointerType = pointerType != null ? pointerType : PointerType.circle;
guideView.isShapeSolid = isShapeSolid;
float density = context.getResources().getDisplayMetrics().density;

guideView.setTitle(title);
Expand Down