Skip to content

Migrate to AndroidX #87

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

Open
wants to merge 11 commits 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
73 changes: 19 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,27 @@
# Shape Image View
[![](https://travis-ci.org/siyamed/android-shape-imageview.svg?branch=master&style=flat)](https://travis-ci.org/siyamed/android-shape-imageview/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.siyamed/android-shape-imageview/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.github.siyamed/android-shape-imageview)

Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both **shader** and **bitmap mask** based image views.

[Shader]: http://developer.android.com/reference/android/graphics/BitmapShader.html
[Path.addPath]: http://developer.android.com/reference/android/graphics/Path.html#addPath(android.graphics.Path)
[Path]: http://developer.android.com/reference/android/graphics/Path.html
[xfermode]: http://developer.android.com/reference/android/graphics/Xfermode.html
[svg_location]: library/src/main/res/raw
[svg_rectangle]: http://www.w3schools.com/svg/svg_rect.asp
[svg_circle]: http://www.w3schools.com/svg/svg_circle.asp
[svg_ellipse]: http://www.w3schools.com/svg/svg_ellipse.asp
[svg_polygon]: http://www.w3schools.com/svg/svg_polygon.asp
[svg_path]: http://www.w3schools.com/svg/svg_path.asp
[svg_group]: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/g
[svg_transformations]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform
[sample_app_play_store]: https://play.google.com/store/apps/details?id=com.github.siyamed.shapeimageview.sample
[youtube_video]: http://youtu.be/6fCkptmwxtQ

* [Shader][Shader] based one uses *canvas draw methods* and *[Path][Path]* class,
* Mask based one uses [xfermode][xfermode] to draw image on bitmaps defined by android shape XML's or resource bitmaps.

<div>
<a href="images/shader-buble.png" style="float:left;">
<img src="images/shader-buble.png" alt="Chat Bubble Image" height="600px"/>
</a>
<a href="images/all-samples.png" >
<img src="images/all-samples.png" alt="Shape Image View" height="600px"/>
</a>
</div>

There are many projects online implementing such components, however one goal of this project is to provide a
performant/smooth scrolling **image view component framework** to define different shapes for imageviews.

**For use with recycling view such as ListView or GridView please use shader based implementations.**

[Sample app in play store][sample_app_play_store]

[Youtube video][youtube_video]
# Shape Image View (Compatible with AndroidX)
[![](https://jitpack.io/v/arefhosseini/android-shape-imageview.svg)](https://jitpack.io/#arefhosseini/android-shape-imageview)
[![](https://jitci.com/gh/arefhosseini/android-shape-imageview/svg)](https://jitci.com/gh/arefhosseini/android-shape-imageview)

## How to use

Gradle dependency:
```Groovy
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
<b>Step 1.</b> Add JitPack repository in your root build.gradle at the end of repositories:

```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

<b>Step 2.</b> Add the dependency:

```groovy
dependencies {
implementation 'com.github.arefhosseini:android-shape-imageview:1.0.3'
}
```
###Shader Based ImageView's
####BubbleImageView
![Android Bubble ImageView](images/small-bubble.png)
Expand Down Expand Up @@ -195,10 +170,6 @@ This method reads a shape file (either bitmap or an android shape xml), creates

See/execute the [sample](sample) for a demonstration of the components.

If you are lazy check [this youtube video][youtube_video] demonstrating scrolling in the sample app

You can download the [sample app from play store][sample_app_play_store]

## Proguard

```
Expand All @@ -209,9 +180,3 @@ You can download the [sample app from play store][sample_app_play_store]
-dontwarn com.github.siyamed.**
-keep class com.github.siyamed.shapeimageview.**{ *; }
```

## References
* [MostafaGazar/CustomShapeImageView](https://github.com/MostafaGazar/CustomShapeImageView): Used this project a basis for bitmap masks
* [geosolutions-it/mapsforge/svg-android](https://github.com/geosolutions-it/mapsforge/tree/master/svg-android): Used and modified to create a path from a svg file

[![Android Shape Image View on Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-android--shape--imageview-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/932)
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.7'
task clean(type: Delete) {
delete rootProject.buildDir
}
14 changes: 8 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
VERSION_NAME=0.9.3
VERSION_CODE=1
VERSION_NAME=1.0.4
VERSION_CODE=6

ANDROID_BUILD_MIN_SDK_VERSION=9
ANDROID_BUILD_TARGET_SDK_VERSION=23
ANDROID_BUILD_TOOLS_VERSION=23.0.1
ANDROID_BUILD_SDK_VERSION=23
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=29
ANDROID_BUILD_TOOLS_VERSION=29.0.0
ANDROID_BUILD_SDK_VERSION=29

GROUP=com.github.siyamed

Expand All @@ -18,4 +18,6 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=siyamed
POM_DEVELOPER_NAME=Siyamed Sinir
android.useAndroidX=true
android.enableJetifier=true

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 29 10:49:34 PDT 2015
#Fri Jul 26 00:14:28 IRDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
72 changes: 42 additions & 30 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# 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='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -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\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
Expand All @@ -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
Expand Down Expand Up @@ -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" "$@"
14 changes: 4 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
@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 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="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

Expand Down Expand Up @@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows 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.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
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
Expand Down
7 changes: 2 additions & 5 deletions library/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.ben-manes.versions'

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
Expand All @@ -14,7 +13,5 @@ android {
}

dependencies {
compile group: 'net.sf.kxml', name: 'kxml2', version:'2.3.0'
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
implementation group: 'net.sf.kxml', name: 'kxml2', version:'2.3.0'
}
17 changes: 8 additions & 9 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'com.android.application'
apply plugin: 'com.github.ben-manes.versions'

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
Expand All @@ -9,8 +8,8 @@ android {
applicationId "com.github.siyamed.shapeimageview.sample"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 3
versionName "1.0"
versionCode 6
versionName "1.0.4"
}
buildTypes {
release {
Expand All @@ -21,10 +20,10 @@ android {
}

dependencies {
compile project(':library')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:gridlayout-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
implementation project(':library')
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
2 changes: 1 addition & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".SampleActivity"
android:name="com.github.siyamed.shapeimageview.sample.SampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Loading