diff --git a/README.md b/README.md index f4bc550..260b5ff 100644 --- a/README.md +++ b/README.md @@ -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. - -
- -Chat Bubble Image - - -Shape Image View - -
- -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' +Step 1. Add JitPack repository in your root build.gradle at the end of repositories: + +```groovy +allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } + } +} ``` +Step 2. 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) @@ -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 ``` @@ -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) diff --git a/build.gradle b/build.gradle index 0b571da..28be4a7 100644 --- a/build.gradle +++ b/build.gradle @@ -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 } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8f8d75f..f517377 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e8c6bf7..87b738c 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 6bbbf74..87d8475 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index 97fac78..af6708f 100755 --- 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='"-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 @@ -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\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - 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 aec9973..0f8d593 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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 @@ -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. @@ -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 diff --git a/library/build.gradle b/library/build.gradle index 741029a..7f0c163 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -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) @@ -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' \ No newline at end of file + implementation group: 'net.sf.kxml', name: 'kxml2', version:'2.3.0' +} \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 7fb0d19..98a0b06 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -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) @@ -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 { @@ -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' } diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index a2fcac9..03e3b2d 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:label="@string/app_name" android:theme="@style/AppTheme" > diff --git a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleActivity.java b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleActivity.java index aeacde0..c41a508 100644 --- a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleActivity.java +++ b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleActivity.java @@ -1,11 +1,11 @@ package com.github.siyamed.shapeimageview.sample; import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.appcompat.app.AppCompatActivity; import com.astuetz.PagerSlidingTabStrip; @@ -18,9 +18,9 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().hide(); - ViewPager pager = (ViewPager) findViewById(R.id.pager); + ViewPager pager = findViewById(R.id.pager); pager.setAdapter(new PagerAdapter(getSupportFragmentManager())); - PagerSlidingTabStrip tabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabs); + PagerSlidingTabStrip tabStrip = findViewById(R.id.tabs); tabStrip.setViewPager(pager); } diff --git a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleBubbleFragment.java b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleBubbleFragment.java index e28de26..7bfd074 100644 --- a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleBubbleFragment.java +++ b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleBubbleFragment.java @@ -2,7 +2,7 @@ import android.content.Context; import android.os.Bundle; -import android.support.v4.app.Fragment; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -38,13 +38,13 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_chat_sample, container, false); - final Picasso picasso = Picasso.with(getActivity()); + final Picasso picasso = new Picasso.Builder(getActivity()).build(); picasso.setLoggingEnabled(true); picasso.setIndicatorsEnabled(false); int listLayout1 = getArguments().getInt(ARG_LAYOUT_1); int listLayout2 = getArguments().getInt(ARG_LAYOUT_2); - final ListView listView = (ListView) view.findViewById(R.id.list); + final ListView listView = view.findViewById(R.id.list); Adapter adapter = new Adapter(getActivity(), picasso, listLayout1, listLayout2); listView.setAdapter(adapter); @@ -91,8 +91,8 @@ public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(layout, parent, false); holder = new ViewHolder(); - holder.image = (ImageView) convertView.findViewById(R.id.image); - holder.text = (TextView) convertView.findViewById(R.id.text); + holder.image = convertView.findViewById(R.id.image); + holder.text = convertView.findViewById(R.id.text); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); diff --git a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleFragment.java b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleFragment.java index d3e1857..1f48567 100644 --- a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleFragment.java +++ b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleFragment.java @@ -1,7 +1,7 @@ package com.github.siyamed.shapeimageview.sample; import android.os.Bundle; -import android.support.v4.app.Fragment; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,12 +36,12 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(layout, container, false); - final ImageView imageView = (ImageView) view.findViewById(R.id.relative_test_img_1); + final ImageView imageView = view.findViewById(R.id.relative_test_img_1); if(imageView != null) { imageView.postDelayed(new Runnable() { @Override public void run() { - Picasso.with(getActivity()).load(Constants.IMAGES[0][0]).into(imageView); + Picasso.get().load(Constants.IMAGES[0][0]).into(imageView); } }, 3000); } diff --git a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleListFragment.java b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleListFragment.java index 6b7b941..4f373d5 100644 --- a/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleListFragment.java +++ b/sample/src/main/java/com/github/siyamed/shapeimageview/sample/SampleListFragment.java @@ -2,7 +2,7 @@ import android.content.Context; import android.os.Bundle; -import android.support.v4.app.Fragment; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,12 +36,12 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_list_sample, container, false); - final Picasso picasso = Picasso.with(getActivity()); + final Picasso picasso = new Picasso.Builder(getActivity()).build(); picasso.setLoggingEnabled(true); picasso.setIndicatorsEnabled(false); int listLayout = getArguments().getInt(ARG_LAYOUT); - final ListView listView = (ListView) view.findViewById(R.id.list); + final ListView listView = view.findViewById(R.id.list); Adapter adapter = new Adapter(getActivity(), picasso, listLayout); listView.setAdapter(adapter); @@ -67,8 +67,8 @@ public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(layout, parent, false); holder = new ViewHolder(); - holder.image = (ImageView) convertView.findViewById(R.id.image); - holder.title = (TextView) convertView.findViewById(R.id.title); + holder.image = convertView.findViewById(R.id.image); + holder.title = convertView.findViewById(R.id.title); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); diff --git a/sample/src/main/res/layout/activity_sample.xml b/sample/src/main/res/layout/activity_sample.xml index e8ee97b..8e9b721 100644 --- a/sample/src/main/res/layout/activity_sample.xml +++ b/sample/src/main/res/layout/activity_sample.xml @@ -14,10 +14,10 @@ android:layout_height="48dip" app:pstsIndicatorColor="@color/green"/> - - +