├── .gitignore
├── README.md
├── android-tagview.iml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── veinhorn
│ │ └── tagview
│ │ └── example
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── veinhorn
│ │ └── tagview
│ │ └── example
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── veinhorn
│ │ └── tagview
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── veinhorn
│ │ └── tagview
│ │ ├── TagView.java
│ │ ├── Tags.java
│ │ ├── Utils.java
│ │ └── drawers
│ │ ├── ClassicTagDrawer.java
│ │ ├── ModernSharpTagDrawer.java
│ │ ├── ModernTagDrawer.java
│ │ ├── ReversedModernSharpTagDrawer.java
│ │ ├── ReversedModernTagDrawer.java
│ │ ├── ReversedSharpTagDrawer.java
│ │ ├── SharpTagDrawer.java
│ │ └── TagDrawer.java
│ └── res
│ └── values
│ ├── attrs.xml
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | .DS_Store
4 | build/
5 | .idea/
6 | *.iml
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | # Android TagView
3 |
4 | Android library for creating different tags for your content. Library uses TextView as a parent class. Example usages can be found in app module (folder).
5 |
6 | ## Install
7 |
8 | ```gradle
9 | compile 'com.veinhorn.tagview:library:1.0.4'
10 | ```
11 |
12 | ## Usage
13 |
14 | Add to your layout:
15 |
16 | ```xml
17 |
24 |
30 |
40 |
49 |
50 |
51 | ```
52 |
53 | ## Customization
54 | ---------------
55 | TagView extends TextView, so you can use all TextView methods and xml properties
56 |
57 | * ```tagType``` - selecting type of tag(classic, modern, trapezium, modern_trapezium, modern_reversed, etc.).
58 | * ```tagColor``` - background color of tag.
59 | * ```tagUpperCase``` - making every tag uppercase.
60 | * ```tagBorderRadius``` - setting border radius of tag
61 | * ```tagCircleRadius``` - radius of crop that is inside of tag
62 | * ```tagCircleColor``` - color of tag circle that is inside of tag
63 | * ```tagTextColor``` - color of text
64 |
65 | ### Padding
66 |
67 | The default padding values for TagView is:
68 | * left - 15dp
69 | * right - 15dp
70 | * top - 10dp
71 | * bottom - 10dp
72 |
73 | But you can set up your own padding using getters and setters.
74 |
75 | ### Tag types
76 |
77 | * TagView.CLASSIC
78 | * TagView.MODERN
79 | * TagView.TRAPEZIUM
80 | * TagView.MODERN_TRAPEZIUM
81 | * TagView.MODERN_REVERSED
82 | * TagView.TRAPEZIUM_REVERSED
83 | * TagView.MODERN_TRAPEZIUM_REVERSED
84 |
85 | ## Screenshots
86 |
87 | 
88 | 
89 | 
90 | 
91 | 
92 | 
93 |
94 | ## License
95 |
96 | Copyright 2019 Boris Korogvich
97 |
98 | Licensed under the Apache License, Version 2.0 (the "License");
99 | you may not use this file except in compliance with the License.
100 | You may obtain a copy of the License at
101 |
102 | http://www.apache.org/licenses/LICENSE-2.0
103 |
104 | Unless required by applicable law or agreed to in writing, software
105 | distributed under the License is distributed on an "AS IS" BASIS,
106 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
107 | See the License for the specific language governing permissions and
108 | limitations under the License.
109 |
--------------------------------------------------------------------------------
/android-tagview.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.veinhorn.tagview.example"
9 | minSdkVersion 7
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile project(':library')
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | }
26 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/veinhorn/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/veinhorn/tagview/example/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagviewexample;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/veinhorn/tagview/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.example;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 |
6 | import com.veinhorn.tagview.TagView;
7 | import com.veinhorn.tagviewexample.R;
8 |
9 |
10 | public class MainActivity extends Activity {
11 | private TagView tagView;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 | //tagView = (TagView)findViewById(R.id.tagView);
18 | //tagView.setTagType(TagView.MODERN_SHARP);
19 | }
20 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
14 |
26 |
27 |
39 |
40 |
52 |
53 |
65 |
66 |
78 |
79 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VEINHORN/android-tagview/5a64f3cc9da6375d57d8f931c3081e35e9edcfa5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VEINHORN/android-tagview/5a64f3cc9da6375d57d8f931c3081e35e9edcfa5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VEINHORN/android-tagview/5a64f3cc9da6375d57d8f931c3081e35e9edcfa5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VEINHORN/android-tagview/5a64f3cc9da6375d57d8f931c3081e35e9edcfa5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TagView Example
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven { url "http://dl.bintray.com/veinhorn/maven" }
4 | mavenCentral()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.5.0'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | maven { url "http://dl.bintray.com/veinhorn/maven" }
17 | mavenCentral()
18 | jcenter()
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VEINHORN/android-tagview/5a64f3cc9da6375d57d8f931c3081e35e9edcfa5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Mar 02 22:33:24 MSK 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 7
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName '1.0.4'
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | }
24 |
25 | ext {
26 | bintrayRepo = 'maven'
27 | bintrayName = 'tagview-library'
28 |
29 | publishedGroupId = 'com.veinhorn.tagview'
30 | libraryName = 'android-tagview'
31 | artifact = 'library'
32 |
33 | libraryDescription = 'Android library for creating beautiful tags for your content.'
34 |
35 | siteUrl = 'https://github.com/VEINHORN/android-tagview'
36 | gitUrl = 'https://github.com/VEINHORN/android-tagview.git'
37 |
38 | libraryVersion = '1.0.4'
39 |
40 | developerId = 'veinhorn'
41 | developerName = 'Boris Korogvich'
42 | developerEmail = 'b.korogvich@gmail.com'
43 |
44 | licenseName = 'The Apache Software License, Version 2.0'
45 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
46 | allLicenses = ["Apache-2.0"]
47 | }
48 |
49 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
50 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
51 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/veinhorn/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/veinhorn/tagview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/TagView.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.ColorFilter;
8 | import android.graphics.Paint;
9 | import android.graphics.Rect;
10 | import android.graphics.drawable.Drawable;
11 | import android.os.Build;
12 | import android.util.AttributeSet;
13 | import android.widget.TextView;
14 |
15 | import com.veinhorn.tagview.drawers.ClassicTagDrawer;
16 | import com.veinhorn.tagview.drawers.ModernSharpTagDrawer;
17 | import com.veinhorn.tagview.drawers.ModernTagDrawer;
18 | import com.veinhorn.tagview.drawers.ReversedModernSharpTagDrawer;
19 | import com.veinhorn.tagview.drawers.ReversedModernTagDrawer;
20 | import com.veinhorn.tagview.drawers.ReversedSharpTagDrawer;
21 | import com.veinhorn.tagview.drawers.SharpTagDrawer;
22 |
23 | import static com.veinhorn.tagview.Tags.*;
24 |
25 | /**
26 | * Created by veinhorn on 1.3.15.
27 | */
28 |
29 | public class TagView extends TextView {
30 | public class TagViewData {
31 | // TagView properties
32 | public int tagType;
33 | public int tagColor;
34 | public int tagTextColor;
35 | public boolean tagUpperCase;
36 | public float tagBorderRadius;
37 | public float tagCircleRadius;
38 | public int tagCircleColor;
39 |
40 | public int tagLeftPadding;
41 | public int tagRightPadding;
42 | private int tagTopPadding;
43 | private int tagBottomPadding;
44 | // Paint object for drawing various types of tags
45 | public Paint backgroundPaint;
46 | public Paint circlePaint;
47 | public Paint trianglePaint;
48 | }
49 | private TagViewData data;
50 |
51 | private class TagDrawable extends Drawable {
52 | @Override
53 | public void setAlpha(int alpha) {}
54 |
55 | // TODO: Replace with case statement
56 | @Override
57 | public void draw(Canvas canvas) {
58 | Rect bounds = getBounds();
59 | if (data.tagType == CLASSIC) {
60 | setPadding(data.tagLeftPadding, data.tagTopPadding,
61 | data.tagRightPadding, data.tagBottomPadding);
62 | new ClassicTagDrawer().drawTag(bounds, canvas, data);
63 | } else if (data.tagType == MODERN) {
64 | setPadding(data.tagLeftPadding * MODERN_TAG_MULTIPLIER, data.tagTopPadding,
65 | data.tagRightPadding, data.tagBottomPadding);
66 | new ModernTagDrawer().drawTag(bounds, canvas, data);
67 | } else if (data.tagType == REVERSED_MODERN) {
68 | setPadding(data.tagLeftPadding, data.tagTopPadding,
69 | data.tagRightPadding * MODERN_TAG_MULTIPLIER, data.tagBottomPadding);
70 | new ReversedModernTagDrawer().drawTag(bounds, canvas, data);
71 | } else if (data.tagType == SHARP) {
72 | setPadding(data.tagLeftPadding, data.tagTopPadding,
73 | data.tagRightPadding * SHARP_TAG_MULTIPLIER, data.tagBottomPadding);
74 | new SharpTagDrawer().drawTag(bounds, canvas, data);
75 | } else if (data.tagType == REVERSED_SHARP) {
76 | setPadding(data.tagLeftPadding * SHARP_TAG_MULTIPLIER, data.tagTopPadding,
77 | data.tagRightPadding, data.tagBottomPadding);
78 | new ReversedSharpTagDrawer().drawTag(bounds, canvas, data);
79 | } else if (data.tagType == MODERN_SHARP) {
80 | setPadding(data.tagLeftPadding * MODERN_TAG_MULTIPLIER, data.tagTopPadding,
81 | data.tagRightPadding * SHARP_TAG_MULTIPLIER, data.tagBottomPadding);
82 | new ModernSharpTagDrawer().drawTag(bounds, canvas, data);
83 | } else if (data.tagType == REVERSED_MODERN_SHARP) {
84 | setPadding(data.tagLeftPadding * SHARP_TAG_MULTIPLIER, data.tagTopPadding,
85 | data.tagRightPadding * MODERN_TAG_MULTIPLIER, data.tagBottomPadding);
86 | new ReversedModernSharpTagDrawer().drawTag(bounds, canvas, data);
87 | }
88 | setTextColor(data.tagTextColor);
89 | }
90 |
91 | @Override
92 | public void setColorFilter(ColorFilter colorFilter) {}
93 |
94 | @Override
95 | public int getOpacity() {
96 | return 0;
97 | }
98 | }
99 |
100 | public TagView(Context context, AttributeSet attrs) {
101 | super(context, attrs);
102 |
103 | TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TagView, 0, 0);
104 | data = new TagViewData();
105 | try {
106 | data.tagType = typedArray.getInteger(R.styleable.TagView_tagType, CLASSIC);
107 | data.tagColor = typedArray.getColor(R.styleable.TagView_tagColor, Color.BLACK);
108 | data.tagUpperCase = typedArray.getBoolean(R.styleable.TagView_tagUpperCase, false);
109 | data.tagBorderRadius = typedArray.getInteger(R.styleable.TagView_tagBorderRadius, BORDER_RADIUS_DEFAULT);
110 | data.tagCircleRadius = typedArray.getInteger(R.styleable.TagView_tagCircleRadius, CIRCLE_RADIUS_DEFAULT);
111 | data.tagCircleColor = typedArray.getColor(R.styleable.TagView_tagCircleColor, CIRCLE_COLOR_DEFAULT);
112 | data.tagTextColor = typedArray.getColor(R.styleable.TagView_tagTextColor, TEXT_COLOR_DEFAULT);
113 | } finally {
114 | typedArray.recycle();
115 | }
116 |
117 | initPadding();
118 | init();
119 | }
120 |
121 | @Override
122 | public void onDraw(Canvas canvas) {
123 | if(data.tagUpperCase) setText(getText().toString().toUpperCase());
124 | super.onDraw(canvas);
125 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
126 | setBackground(new TagDrawable());
127 | } else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
128 | setBackgroundDrawable(new TagDrawable());
129 | }
130 | }
131 |
132 | /**
133 | * Initializes Paint objects that will be used to draw tags, speed up draw method
134 | */
135 | private void init() {
136 | data.backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
137 | data.backgroundPaint.setColor(data.tagColor);
138 |
139 | data.circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
140 | data.circlePaint.setColor(data.tagCircleColor);
141 |
142 | data.trianglePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
143 | data.trianglePaint.setColor(data.tagColor);
144 | data.trianglePaint.setStyle(Paint.Style.FILL);
145 | }
146 |
147 | /**
148 | * Set default values for padding, if you not specify it in xml layout
149 | */
150 | private void initPadding() {
151 | int left = getPaddingLeft();
152 | int right = getPaddingRight();
153 | int top = getPaddingTop();
154 | int bottom = getPaddingBottom();
155 | if(left == 0) data.tagLeftPadding = LEFT_PADDING_DEFAULT;
156 | else data.tagLeftPadding = left;
157 | if(right == 0) data.tagRightPadding = RIGHT_PADDING_DEFAULT;
158 | else data.tagRightPadding = right;
159 | if(top == 0) data.tagTopPadding = TOP_PADDING_DEFAULT;
160 | else data.tagTopPadding = top;
161 | if(bottom == 0) data.tagBottomPadding = BOTTOM_PADDING_DEFAULT;
162 | else data.tagBottomPadding = bottom;
163 | }
164 |
165 | public int getTagType() {
166 | return data.tagType;
167 | }
168 |
169 | public void setTagType(int tagType) {
170 | data.tagType = tagType;
171 | invalidate();
172 | requestLayout();
173 | }
174 |
175 | public int getTagColor() {
176 | return data.tagColor;
177 | }
178 |
179 | public void setTagColor(int tagColor) {
180 | data.tagColor = tagColor;
181 | init();
182 | invalidate();
183 | requestLayout();
184 | }
185 |
186 | public boolean isTagUpperCase() {
187 | return data.tagUpperCase;
188 | }
189 |
190 | public void setTagUpperCase(boolean tagUpperCase) {
191 | data.tagUpperCase = tagUpperCase;
192 | invalidate();
193 | requestLayout();
194 | }
195 |
196 | public float getTagBorderRadius() {
197 | return data.tagBorderRadius;
198 | }
199 |
200 | public void setTagBorderRadius(int tagBorderRadius) {
201 | data.tagBorderRadius = tagBorderRadius;
202 | invalidate();
203 | requestLayout();
204 | }
205 |
206 | public float getTagCircleRadius() {
207 | return data.tagCircleRadius;
208 | }
209 |
210 | public void setTagCircleRadius(float tagCircleRadius) {
211 | data.tagCircleRadius = tagCircleRadius;
212 | invalidate();
213 | requestLayout();
214 | }
215 |
216 | public int getTagCircleColor() {
217 | return data.tagCircleColor;
218 | }
219 |
220 | public void setTagCircleColor(int tagCircleColor) {
221 | data.tagCircleColor = tagCircleColor;
222 | init();
223 | invalidate();
224 | requestLayout();
225 | }
226 |
227 | public int getTagTextColor() {
228 | return data.tagTextColor;
229 | }
230 |
231 | public void setTagTextColor(int tagTextColor) {
232 | data.tagTextColor = tagTextColor;
233 | invalidate();
234 | requestLayout();
235 | }
236 |
237 | public int getTagLeftPadding() {
238 | return data.tagLeftPadding;
239 | }
240 |
241 | public void setTagLeftPadding(int tagLeftPadding) {
242 | data.tagLeftPadding = tagLeftPadding;
243 | invalidate();
244 | requestLayout();
245 | }
246 |
247 | public int getTagRightPadding() {
248 | return data.tagRightPadding;
249 | }
250 |
251 | public void setTagRightPadding(int tagRightPadding) {
252 | data.tagRightPadding = tagRightPadding;
253 | invalidate();
254 | requestLayout();
255 | }
256 |
257 | public int getTagTopPadding() {
258 | return data.tagTopPadding;
259 | }
260 |
261 | public void setTagTopPadding(int tagTopPadding) {
262 | data.tagTopPadding = tagTopPadding;
263 | invalidate();
264 | requestLayout();
265 | }
266 |
267 | public int getTagBottomPadding() {
268 | return data.tagBottomPadding;
269 | }
270 |
271 | public void setTagBottomPadding(int tagBottomPadding) {
272 | data.tagBottomPadding = tagBottomPadding;
273 | invalidate();
274 | requestLayout();
275 | }
276 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/Tags.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview;
2 |
3 | import android.graphics.Color;
4 |
5 | /**
6 | * Created by veinhorn on 11.3.16.
7 | */
8 | public class Tags {
9 | // Tag types
10 | public static final int CLASSIC = 0;
11 | public static final int MODERN = 1;
12 | public static final int SHARP = 2;
13 | public static final int MODERN_SHARP = 3;
14 | public static final int REVERSED_MODERN = 4;
15 | public static final int REVERSED_SHARP = 5;
16 | public static final int REVERSED_MODERN_SHARP = 6;
17 | // Default tag paddings
18 | public static final int LEFT_PADDING_DEFAULT = 15;
19 | public static final int RIGHT_PADDING_DEFAULT = 15;
20 | public static final int TOP_PADDING_DEFAULT = 10;
21 | public static final int BOTTOM_PADDING_DEFAULT = 10;
22 | // Default tag colors
23 | public static final int TEXT_COLOR_DEFAULT = Color.WHITE;
24 | public static final int CIRCLE_COLOR_DEFAULT = Color.WHITE;
25 | // Tag constants
26 | public static final int BORDER_RADIUS_DEFAULT = 5;
27 | public static final int CIRCLE_RADIUS_DEFAULT = 7;
28 |
29 | public static final int MODERN_TAG_MULTIPLIER = 2; // used to draw crop inside modern tag
30 | public static final int SHARP_TAG_MULTIPLIER = 3; // used to draw triangle for "sharp" tag
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/Utils.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview;
2 |
3 | import android.graphics.Rect;
4 | import android.graphics.RectF;
5 |
6 | /**
7 | * Created by veinhorn on 11.3.16.
8 | */
9 | public class Utils {
10 | /**
11 | * Converts Rect object to RectF
12 | * @param rect
13 | * @return
14 | */
15 | public static RectF toRectF(Rect rect) {
16 | return new RectF(rect.left, rect.top, rect.right, rect.bottom);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/ClassicTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 | import android.graphics.RectF;
6 |
7 | import com.veinhorn.tagview.TagView;
8 | import com.veinhorn.tagview.Utils;
9 |
10 | /**
11 | * Created by veinhorn on 11.3.16.
12 | */
13 | public class ClassicTagDrawer implements TagDrawer {
14 | @Override
15 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
16 | RectF rect = Utils.toRectF(bounds);
17 | canvas.drawRoundRect(rect, data.tagBorderRadius, data.tagBorderRadius, data.backgroundPaint);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/ModernSharpTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Path;
5 | import android.graphics.Rect;
6 | import android.graphics.RectF;
7 |
8 | import com.veinhorn.tagview.TagView;
9 | import com.veinhorn.tagview.Utils;
10 | import static com.veinhorn.tagview.Tags.*;
11 |
12 | /**
13 | * Created by veinhorn on 11.3.16.
14 | */
15 | public class ModernSharpTagDrawer extends SharpTagDrawer {
16 | @Override
17 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
18 | RectF formattedBounds = Utils.toRectF(bounds);
19 | RectF rect = new RectF(formattedBounds);
20 | rect.right -= data.tagRightPadding * SHARP_TAG_MULTIPLIER;
21 | canvas.drawRect(rect, data.backgroundPaint);
22 | float xPos = formattedBounds.left + data.tagLeftPadding;
23 | float yPos = (formattedBounds.bottom - formattedBounds.top) / 2;
24 | canvas.drawCircle(xPos, yPos, data.tagCircleRadius, data.circlePaint);
25 | float halfOfRectHeight = (rect.bottom - rect.top) / 2;
26 | Path trianglePath = createTrianglePath(data, rect, halfOfRectHeight);
27 | canvas.drawPath(trianglePath, data.trianglePaint);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/ModernTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 | import android.graphics.RectF;
6 |
7 | import com.veinhorn.tagview.TagView;
8 | import com.veinhorn.tagview.Utils;
9 |
10 | /**
11 | * Created by veinhorn on 11.3.16.
12 | */
13 | public class ModernTagDrawer implements TagDrawer {
14 | @Override
15 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
16 | RectF rect = Utils.toRectF(bounds);
17 | canvas.drawRoundRect(rect, data.tagBorderRadius, data.tagBorderRadius, data.backgroundPaint);
18 | float xPos = rect.left + data.tagLeftPadding;
19 | float yPos = (rect.bottom - rect.top) / 2;
20 | canvas.drawCircle(xPos, yPos, data.tagCircleRadius, data.circlePaint);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/ReversedModernSharpTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Path;
5 | import android.graphics.Rect;
6 | import android.graphics.RectF;
7 |
8 | import com.veinhorn.tagview.TagView;
9 | import com.veinhorn.tagview.Utils;
10 |
11 | import static com.veinhorn.tagview.Tags.SHARP_TAG_MULTIPLIER;
12 |
13 | /**
14 | * Created by veinhorn on 11.3.16.
15 | */
16 | public class ReversedModernSharpTagDrawer extends ReversedSharpTagDrawer {
17 | @Override
18 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
19 | RectF formattedBounds = Utils.toRectF(bounds);
20 | RectF rect = new RectF(formattedBounds);
21 | rect.left += data.tagRightPadding * SHARP_TAG_MULTIPLIER;
22 | float halfOfRectHeight = (rect.bottom - rect.top) / 2;
23 | canvas.drawRect(rect, data.backgroundPaint);
24 | float xPos = formattedBounds.right - data.tagRightPadding;
25 | float yPos = (formattedBounds.bottom - formattedBounds.top) / 2;
26 | canvas.drawCircle(xPos, yPos, data.tagCircleRadius, data.circlePaint);
27 | Path trianglePath = createTrianglePath(data, rect, halfOfRectHeight);
28 | canvas.drawPath(trianglePath, data.trianglePaint);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/ReversedModernTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 | import android.graphics.RectF;
6 |
7 | import com.veinhorn.tagview.TagView;
8 | import com.veinhorn.tagview.Utils;
9 |
10 | /**
11 | * Created by veinhorn on 11.3.16.
12 | */
13 | public class ReversedModernTagDrawer implements TagDrawer {
14 | @Override
15 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
16 | RectF rect = Utils.toRectF(bounds);
17 | canvas.drawRoundRect(rect, data.tagBorderRadius, data.tagBorderRadius, data.backgroundPaint);
18 | float xPos = rect.right - data.tagRightPadding;
19 | float yPos = (rect.bottom - rect.top) / 2;
20 | canvas.drawCircle(xPos, yPos, data.tagCircleRadius, data.circlePaint);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/ReversedSharpTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Path;
5 | import android.graphics.Rect;
6 | import android.graphics.RectF;
7 |
8 | import com.veinhorn.tagview.TagView;
9 | import com.veinhorn.tagview.Utils;
10 |
11 | import static com.veinhorn.tagview.Tags.*;
12 |
13 | /**
14 | * Created by veinhorn on 11.3.16.
15 | */
16 | public class ReversedSharpTagDrawer implements TagDrawer {
17 | @Override
18 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
19 | RectF formattedBounds = Utils.toRectF(bounds);
20 | RectF rect = new RectF(formattedBounds);
21 | rect.left += data.tagRightPadding * SHARP_TAG_MULTIPLIER;
22 | float halfOfRectHeight= (rect.bottom - rect.top) / 2;
23 | canvas.drawRect(rect, data.backgroundPaint);
24 | Path trianglePath = createTrianglePath(data, rect, halfOfRectHeight);
25 | canvas.drawPath(trianglePath, data.trianglePaint);
26 | }
27 |
28 | protected Path createTrianglePath(TagView.TagViewData data, RectF rect, float halfOfRectHeight) {
29 | Path path = new Path();
30 | path.setFillType(Path.FillType.EVEN_ODD);
31 | path.moveTo(rect.left, rect.top);
32 | path.lineTo(rect.left - data.tagLeftPadding * SHARP_TAG_MULTIPLIER, halfOfRectHeight);
33 | path.lineTo(rect.left, rect.bottom);
34 | path.lineTo(rect.left, rect.top);
35 | return path;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/SharpTagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Path;
5 | import android.graphics.Rect;
6 | import android.graphics.RectF;
7 |
8 | import com.veinhorn.tagview.TagView;
9 | import com.veinhorn.tagview.Utils;
10 |
11 | import static com.veinhorn.tagview.Tags.SHARP_TAG_MULTIPLIER;
12 |
13 | /**
14 | * Created by veinhorn on 11.3.16.
15 | */
16 | public class SharpTagDrawer implements TagDrawer {
17 | @Override
18 | public void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data) {
19 | RectF rect = Utils.toRectF(bounds);
20 | rect.right -= data.tagRightPadding * SHARP_TAG_MULTIPLIER;
21 | float halfOfRectHeight = (rect.bottom - rect.top) / 2;
22 | canvas.drawRect(rect, data.backgroundPaint);
23 | Path trianglePath = createTrianglePath(data, rect, halfOfRectHeight);
24 | canvas.drawPath(trianglePath, data.trianglePaint);
25 | }
26 |
27 | /**
28 | * Returns filled colored triangle that is used for drawing "sharp" tags
29 | */
30 | protected Path createTrianglePath(TagView.TagViewData data, RectF rect, float halfOfRectHeight) {
31 | Path path = new Path();
32 | path.setFillType(Path.FillType.EVEN_ODD);
33 | path.moveTo(rect.right, rect.top);
34 | path.lineTo(rect.right + data.tagRightPadding * SHARP_TAG_MULTIPLIER, halfOfRectHeight);
35 | path.lineTo(rect.right, rect.bottom);
36 | path.lineTo(rect.right, rect.top);
37 | return path;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/com/veinhorn/tagview/drawers/TagDrawer.java:
--------------------------------------------------------------------------------
1 | package com.veinhorn.tagview.drawers;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Rect;
5 |
6 | import com.veinhorn.tagview.TagView;
7 |
8 | /**
9 | * Created by veinhorn on 11.3.16.
10 | */
11 | public interface TagDrawer {
12 | // add java docs for this method
13 | void drawTag(Rect bounds, Canvas canvas, TagView.TagViewData data);
14 | }
15 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | tagview
3 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------