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 1 commit
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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -20,7 +20,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation project(':showcaseviewlib')

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ir.smartdevelop.eram.showcaseview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;

import smartdevelop.ir.eram.showcaseviewlib.GuideView;
Expand Down Expand Up @@ -45,19 +45,19 @@ protected void onCreate(Bundle savedInstanceState) {
public void onDismiss(View view) {
switch (view.getId()) {
case R.id.view1:
builder.setTargetView(view2).build();
builder.setGravity(Gravity.sideauto).setTargetView(view2).build();
break;
case R.id.view2:
builder.setTargetView(view3).build();
builder.setGravity(Gravity.auto).setTargetView(view3).build();
break;
case R.id.view3:
builder.setTargetView(view4).build();
builder.setGravity(Gravity.auto).setTargetView(view4).build();
break;
case R.id.view4:
builder.setTargetView(view5).build();
builder.setGravity(Gravity.auto).setTargetView(view5).build();
break;
case R.id.view5:
builder.setTargetView(view6).build();
builder.setGravity(Gravity.sidecenter).setTargetView(view6).build();
break;
case R.id.view6:
return;
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

<ImageView
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:maxWidth="0dp"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It made invisible this image view, please revert these changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset

android:layout_marginTop="30dp"
android:src="@mipmap/ic_launcher"

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sun Jan 21 11:44:08 IRST 2018
android.enableJetifier=true
android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Binary file added showcaseviewlib.zip
Binary file not shown.
5 changes: 1 addition & 4 deletions showcaseviewlib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.mreram'
android {
compileSdkVersion 30
Expand All @@ -9,10 +8,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 30
versionCode 3
versionName "1.4.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

}

Expand Down
8 changes: 8 additions & 0 deletions showcaseviewlib/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Jan 27 20:47:37 CST 2022
sdk.dir=/Users/asproat/Library/Android/sdk
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,25 @@ public class GuideView extends FrameLayout {

private final float density;
private float stopY;
private float stopX;
private boolean isTop;
private boolean isLeft;
private boolean mIsShowing;
private int yMessageView = 0;
private int xMessageView = 0;

private float startXLineAndCircle;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unused. you can remove it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

private float startYLineAndCircle;
private float circleIndicatorSize = 0;
private float circleIndicatorSizeFinal;
private float circleInnerIndicatorSize = 0;
private float lineIndicatorWidthSize;
private float lineIndicatorHeightSize;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this one is unused

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

private int messageViewPadding;
private float marginGuide;
private float strokeCircleWidth;
private float indicatorHeight;
private float indicatorWidth;

private boolean isPerformedAnimationSize = false;

Expand Down Expand Up @@ -160,9 +166,15 @@ public void onGlobalLayout() {
getHeight() - getPaddingBottom()
);

marginGuide = (int) (isTop ? marginGuide : -marginGuide);
startYLineAndCircle = (isTop ? targetRect.bottom : targetRect.top) + marginGuide;
stopY = yMessageView + indicatorHeight;
if(mGravity == Gravity.sideauto || mGravity == Gravity.sidecenter) {
marginGuide = (int) (isLeft ? -marginGuide : marginGuide);
startYLineAndCircle = (isLeft ? targetRect.left : targetRect.right) + marginGuide;
stopY = xMessageView + indicatorWidth;
} else {
marginGuide = (int) (isTop ? marginGuide : -marginGuide);
startYLineAndCircle = (isTop ? targetRect.bottom : targetRect.top) + marginGuide;
stopY = yMessageView + indicatorHeight;
}
startAnimationSize();
getViewTreeObserver().addOnGlobalLayoutListener(this);
}
Expand Down Expand Up @@ -227,8 +239,10 @@ public void onAnimationRepeat(Animator animator) {

private void init() {
lineIndicatorWidthSize = LINE_INDICATOR_WIDTH_SIZE * density;
lineIndicatorHeightSize = LINE_INDICATOR_WIDTH_SIZE * density;
marginGuide = MARGIN_INDICATOR * density;
indicatorHeight = INDICATOR_HEIGHT * density;
indicatorWidth = INDICATOR_HEIGHT * density;
messageViewPadding = (int) (MESSAGE_VIEW_PADDING * density);
strokeCircleWidth = STROKE_CIRCLE_INDICATOR_SIZE * density;
circleIndicatorSizeFinal = CIRCLE_INDICATOR_SIZE * density;
Expand Down Expand Up @@ -273,24 +287,48 @@ protected void onDraw(final Canvas canvas) {
paintCircleInner.setColor(CIRCLE_INNER_INDICATOR_COLOR);
paintCircleInner.setAntiAlias(true);

final float x = (targetRect.left / 2 + targetRect.right / 2);
float x = 0.0f;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable name is too general, x of what? please clarify it and choose a better name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to xOfCalloutLine

if (mGravity == Gravity.sideauto || mGravity == Gravity.sidecenter) {
x = (targetRect.top / 2 + targetRect.bottom / 2);
} else {
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);
if (mGravity == Gravity.sideauto || mGravity == Gravity.sidecenter) {
canvas.drawLine(startYLineAndCircle, x, stopY, x, paintLine);
canvas.drawCircle(startYLineAndCircle, x, circleIndicatorSize, paintCircle);
canvas.drawCircle(startYLineAndCircle, x, circleInnerIndicatorSize, paintCircleInner);
}
else {
canvas.drawLine(x, startYLineAndCircle, x, stopY, paintLine);
canvas.drawCircle(x, startYLineAndCircle, circleIndicatorSize, paintCircle);
canvas.drawCircle(x, startYLineAndCircle, circleInnerIndicatorSize, paintCircleInner);
}

break;
case arrow:
canvas.drawLine(x,startYLineAndCircle,x,stopY,paintLine);
Path path = new Path();
if (isTop) {
path.moveTo(x, startYLineAndCircle - (circleIndicatorSize * 2));
path.lineTo(x + circleIndicatorSize, startYLineAndCircle);
path.lineTo(x - circleIndicatorSize, startYLineAndCircle);
if (mGravity == Gravity.sideauto || mGravity == Gravity.sidecenter) {
canvas.drawLine(startYLineAndCircle, x, stopY, x, paintLine);
if (isLeft) {
path.moveTo(startYLineAndCircle + (circleIndicatorSize * 2), x);
} else {
path.moveTo(startYLineAndCircle - (circleIndicatorSize * 2), x);
}
path.lineTo(startYLineAndCircle, x + circleIndicatorSize);
path.lineTo(startYLineAndCircle, x - circleIndicatorSize);
path.close();

} else {
path.moveTo(x, startYLineAndCircle + (circleIndicatorSize * 2));
canvas.drawLine(x, startYLineAndCircle, x, stopY, paintLine);
if (isTop) {
path.moveTo(x, startYLineAndCircle - (circleIndicatorSize * 2));
} else {
path.moveTo(x, startYLineAndCircle + (circleIndicatorSize * 2));
}
path.lineTo(x + circleIndicatorSize, startYLineAndCircle);
path.lineTo(x - circleIndicatorSize, startYLineAndCircle);
path.close();
Expand Down Expand Up @@ -394,39 +432,70 @@ public void updateGuideViewLocation() {

private Point resolveMessageViewLocation() {

int xMessageView;
if (mGravity == Gravity.center) {
xMessageView = (int) (targetRect.left - mMessageView.getWidth() / 2 + target.getWidth() / 2);
} else {
xMessageView = (int) (targetRect.right) - mMessageView.getWidth();
}
if(mGravity == Gravity.sideauto || mGravity == Gravity.sidecenter)
{
if (mGravity == Gravity.sidecenter) {
yMessageView = (int) (targetRect.top + target.getHeight() / 2 - mMessageView.getHeight() / 2);
} else {
yMessageView = (int) (targetRect.top);
}

if (isLandscape()) {
xMessageView -= getNavigationBarSize();
}
if (yMessageView + mMessageView.getHeight() > getHeight()) {
yMessageView = getHeight() - mMessageView.getHeight();
}
if (yMessageView < 0) {
yMessageView = 0;
}

if (xMessageView + mMessageView.getWidth() > getWidth()) {
xMessageView = getWidth() - mMessageView.getWidth();
}
if (xMessageView < 0) {
xMessageView = 0;
}
//set message view bottom
if ((targetRect.left - (indicatorWidth)) < getWidth() / 2f) {
isLeft = false;
xMessageView = (int) (targetRect.right + indicatorWidth);
}
//set message view top
else {
isLeft = true;
xMessageView = (int) (targetRect.left - mMessageView.getWidth() - indicatorWidth);
}

if (xMessageView < 0) {
xMessageView = 0;
}

//set message view bottom
if ((targetRect.top + (indicatorHeight)) > getHeight() / 2f) {
isTop = false;
yMessageView = (int) (targetRect.top - mMessageView.getHeight() - indicatorHeight);
}
//set message view top
else {
isTop = true;
yMessageView = (int) (targetRect.top + target.getHeight() + indicatorHeight);
}
if (mGravity == Gravity.center) {
xMessageView = (int) (targetRect.left - mMessageView.getWidth() / 2 + target.getWidth() / 2);
} else {
xMessageView = (int) (targetRect.right) - mMessageView.getWidth();
}

if (yMessageView < 0) {
yMessageView = 0;
}
if (isLandscape()) {
xMessageView -= getNavigationBarSize();
}

if (xMessageView + mMessageView.getWidth() > getWidth()) {
xMessageView = getWidth() - mMessageView.getWidth();
}
if (xMessageView < 0) {
xMessageView = 0;
}

//set message view bottom
if ((targetRect.top + (indicatorHeight)) > getHeight() / 2f) {
isTop = false;
yMessageView = (int) (targetRect.top - mMessageView.getHeight() - indicatorHeight);
}
//set message view top
else {
isTop = true;
yMessageView = (int) (targetRect.top + target.getHeight() + indicatorHeight);
}

if (yMessageView < 0) {
yMessageView = 0;
}
}
return new Point(xMessageView, yMessageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* Created by Mohammad Reza Eram (https://github.com/mreram) on 27,November,2018
*/
public enum Gravity {
auto, center
auto, center, sideauto, sidecenter
}