diff --git a/README.md b/README.md index 698ba473..dfe8b099 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # :flashlight:ShowCaseView:flashlight: -[![](https://jitpack.io/v/TKshadow018/ShowCaseView.svg)](https://jitpack.io/#TKshadow018/ShowCaseView) [![Release](https://jitpack.io/v/mreram/ShowCaseView.svg)](https://jitpack.io/#mreram/ShowCaseView) [![APK](https://img.shields.io/badge/APK-Demo-brightgreen.svg)](https://github.com/mreram/ShowCaseView/raw/master/demo-flatShowCaseView.apk) [![API](https://img.shields.io/badge/API-11%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=11) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FlatShowCaseView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6713) @@ -46,7 +45,7 @@ maven: com.github.mreram showcaseview - 1.2.0 + 1.3.0 ``` gradle: @@ -62,7 +61,7 @@ allprojects { ``` Step 2. Add the dependency ```groovy -implementation 'com.github.mreram:showcaseview:1.2.0' +implementation 'com.github.mreram:showcaseview:1.3.0' ``` ## Change type face ```java @@ -142,6 +141,14 @@ new GuideView.Builder(MainActivity.this) +### PointerType Attribute + +| Type | Description | +| ------ | ------ | +| circle | Show circle pointer towards targetView | +| arrow | Show arrow pointer towards targetView | +| none | Show no pointer or line towards targetView | + ## Contribution :collision: diff --git a/app/build.gradle b/app/build.gradle index e3c73d22..e9bb38e2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ android { compileSdkVersion 26 defaultConfig { applicationId "smartdevelop.ir.eram.showcaseview" - minSdkVersion 14 + minSdkVersion 11 targetSdkVersion 25 versionCode 1 versionName "1.0" diff --git a/app/src/main/java/ir/smartdevelop/eram/showcaseview/MainActivity.java b/app/src/main/java/ir/smartdevelop/eram/showcaseview/MainActivity.java index 0ff4306d..222e93df 100644 --- a/app/src/main/java/ir/smartdevelop/eram/showcaseview/MainActivity.java +++ b/app/src/main/java/ir/smartdevelop/eram/showcaseview/MainActivity.java @@ -3,11 +3,11 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; -import android.widget.EditText; import smartdevelop.ir.eram.showcaseviewlib.GuideView; 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 { @@ -38,6 +38,7 @@ protected void onCreate(Bundle savedInstanceState) { .setContentText("Guide Description Text\n .....Guide Description Text\n .....Guide Description Text .....") .setGravity(Gravity.center) .setDismissType(DismissType.anywhere) + .setPointerType(PointerType.arrow) .setTargetView(view1) .setGuideListener(new GuideListener() { @Override diff --git a/build.gradle b/build.gradle index 708a8105..98d9ecc6 100644 --- a/build.gradle +++ b/build.gradle @@ -4,27 +4,20 @@ buildscript { repositories { google() - jcenter() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files } } allprojects { repositories { - maven { - url 'http://clojars.org/repo' - } mavenCentral() maven { url "https://jitpack.io" } google() - jcenter() } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 13372aef..758de960 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b4eaa3d8..1f3fdbc5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Jun 14 22:30:27 IST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 9d82f789..cccdd3d5 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,20 +6,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -150,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282a..e95643d6 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,90 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/showcaseviewlib/build.gradle b/showcaseviewlib/build.gradle index fa705da2..2fd9382d 100644 --- a/showcaseviewlib/build.gradle +++ b/showcaseviewlib/build.gradle @@ -2,15 +2,15 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' group='com.github.mreram' android { - compileSdkVersion 26 + compileSdkVersion 30 defaultConfig { minSdkVersion 11 - targetSdkVersion 26 + targetSdkVersion 30 versionCode 2 - versionName "1.1" + versionName "1.3.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/GuideView.java b/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/GuideView.java index 153a68c7..33444b2e 100644 --- a/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/GuideView.java +++ b/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/GuideView.java @@ -10,6 +10,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; @@ -28,6 +29,7 @@ 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; /** @@ -84,6 +86,7 @@ public class GuideView extends FrameLayout { private GuideListener mGuideListener; private Gravity mGravity; private DismissType dismissType; + private PointerType pointerType; private final GuideMessageView mMessageView; private GuideView(Context context, View view) { @@ -271,17 +274,33 @@ protected void onDraw(final Canvas canvas) { paintCircleInner.setAntiAlias(true); final float x = (targetRect.left / 2 + targetRect.right / 2); - canvas.drawLine( - x, - startYLineAndCircle, - x, - stopY, - paintLine - ); - - canvas.drawCircle(x, startYLineAndCircle, circleIndicatorSize, paintCircle); - canvas.drawCircle(x, startYLineAndCircle, circleInnerIndicatorSize, paintCircleInner); + switch (pointerType) { + case circle: + 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); + path.close(); + } else { + path.moveTo(x, startYLineAndCircle + (circleIndicatorSize * 2)); + path.lineTo(x + circleIndicatorSize, startYLineAndCircle); + path.lineTo(x - circleIndicatorSize, startYLineAndCircle); + path.close(); + } + canvas.drawPath(path, paintCircle); + break; + case none: + //draw no line and no pointer + break; + } targetPaint.setXfermode(X_FER_MODE_CLEAR); targetPaint.setAntiAlias(true); @@ -455,6 +474,7 @@ public static class Builder { private String title, contentText; private Gravity gravity; private DismissType dismissType; + private PointerType pointerType; private final Context context; private Spannable contentSpan; private Typeface titleTypeFace, contentTypeFace; @@ -628,10 +648,20 @@ public Builder setCircleStrokeIndicatorSize(float size) { return this; } + /** + * this method defining the type of pointer + * + * @param pointerType should be one type of PointerType enum. for example: arrow -> To show arrow pointing to target view + */ + public Builder setPointerType(PointerType pointerType) { + this.pointerType = pointerType; + 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; float density = context.getResources().getDisplayMetrics().density; guideView.setTitle(title); diff --git a/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/config/PointerType.java b/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/config/PointerType.java new file mode 100644 index 00000000..5190873f --- /dev/null +++ b/showcaseviewlib/src/main/java/smartdevelop/ir/eram/showcaseviewlib/config/PointerType.java @@ -0,0 +1,5 @@ +package smartdevelop.ir.eram.showcaseviewlib.config; + +public enum PointerType { + circle, arrow, none +}