├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── cuneyt
│ │ │ └── example
│ │ │ └── com
│ │ │ └── tagview
│ │ │ ├── Models
│ │ │ └── TagClass.java
│ │ │ ├── Activity
│ │ │ └── MainActivity.java
│ │ │ └── Constants.java
│ └── androidTest
│ │ └── java
│ │ └── cuneyt
│ │ └── example
│ │ └── com
│ │ └── tagview
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── library
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── tagview_attr.xml
│ │ │ └── layout
│ │ │ │ └── tagview_item.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── cunoraz
│ │ │ └── tagview
│ │ │ ├── Utils.java
│ │ │ ├── Constants.java
│ │ │ ├── Tag.java
│ │ │ └── TagView.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── cunoraz
│ │ │ └── tagview
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── cunoraz
│ │ └── tagview
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── library.iml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle.properties
├── TagView.iml
├── .gitignore
├── gradlew.bat
├── gradlew
├── README.md
└── LICENSE.txt
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cutta/TagView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cutta/TagView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cutta/TagView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cutta/TagView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cutta/TagView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TagView
3 |
4 | Hello world!
5 | Settings
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Oct 29 11:12:44 KST 2018
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-4.6-all.zip
7 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/library/src/test/java/com/cunoraz/tagview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.cunoraz.tagview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/cunoraz/tagview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.cunoraz.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 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/cuneyt/example/com/tagview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package cuneyt.example.com.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 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/values/tagview_attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cunoraz/tagview/Utils.java:
--------------------------------------------------------------------------------
1 | package com.cunoraz.tagview;
2 |
3 | import android.content.Context;
4 | import android.util.DisplayMetrics;
5 | import android.util.TypedValue;
6 |
7 | public class Utils {
8 |
9 | private Utils() throws InstantiationException {
10 | throw new InstantiationException("This class is not for instantiation");
11 | }
12 |
13 | public static int dipToPx(Context c,float dipValue) {
14 | DisplayMetrics metrics = c.getResources().getDisplayMetrics();
15 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/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 C:\Users\lnvo\AppData\Local\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/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 /Users/cuneytcarikci/Library/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 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion '28.0.3'
7 |
8 | defaultConfig {
9 | applicationId "cuneyt.example.com.tagview"
10 | minSdkVersion 15
11 | targetSdkVersion 23
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation fileTree(dir: 'libs', include: ['*.jar'])
25 | implementation 'com.android.support:appcompat-v7:23.1.1'
26 | implementation project(':library')
27 | }
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | PUBLISH_GROUP_ID = 'com.cunoraz.tagview'
5 | PUBLISH_ARTIFACT_ID = 'android-tagview'
6 | PUBLISH_VERSION = '1.3'
7 | }
8 | android {
9 | compileSdkVersion 23
10 | buildToolsVersion '28.0.3'
11 |
12 | defaultConfig {
13 | minSdkVersion 15
14 | targetSdkVersion 23
15 | versionCode 13
16 | versionName "1.3"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | testImplementation 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/tagview_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/TagView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Mac
2 | .DS_Store
3 | # Built application files
4 | *.apk
5 | *.ap_
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # IntelliJ
38 | *.iml
39 | .idea/workspace.xml
40 | .idea/tasks.xml
41 | .idea/gradle.xml
42 | .idea/assetWizardSettings.xml
43 | .idea/dictionaries
44 | .idea/libraries
45 | .idea/caches
46 | .idea
47 |
48 | # Keystore files
49 | # Uncomment the following line if you do not want check your keystore files in.
50 | #*.jks
51 |
52 | # External native build folder generated in Android Studio 2.2 and later
53 | .externalNativeBuild
54 |
55 | # Google Services (e.g. APIs or Firebase)
56 | google-services.json
57 |
58 | # Freeline
59 | freeline.py
60 | freeline/
61 | freeline_project_description.json
62 |
63 | # fastlane
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 | fastlane/readme.md
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
16 |
17 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/cuneyt/example/com/tagview/Models/TagClass.java:
--------------------------------------------------------------------------------
1 | package cuneyt.example.com.tagview.Models;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Random;
5 |
6 |
7 | /**
8 | * Created by Cuneyt on 21.8.2015.
9 | *
10 | */
11 | public class TagClass {
12 |
13 | private String code;
14 | private String name;
15 | private String color;
16 |
17 | public TagClass() {
18 |
19 | }
20 |
21 | public TagClass(String sinif, String name) {
22 | this.code = sinif;
23 | this.name = name;
24 | this.color = getRandomColor();
25 |
26 | }
27 |
28 | public String getRandomColor() {
29 | ArrayList colors = new ArrayList<>();
30 | colors.add("#ED7D31");
31 | colors.add("#00B0F0");
32 | colors.add("#FF0000");
33 | colors.add("#D0CECE");
34 | colors.add("#00B050");
35 | colors.add("#9999FF");
36 | colors.add("#FF5FC6");
37 | colors.add("#FFC000");
38 | colors.add("#7F7F7F");
39 | colors.add("#4800FF");
40 |
41 | return colors.get(new Random().nextInt(colors.size()));
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public String getColor() {
53 | return color;
54 | }
55 |
56 | public void setColor(String color) {
57 | this.color = color;
58 | }
59 |
60 | public String getSinif() {
61 | return code;
62 | }
63 |
64 | public void setSinif(String code) {
65 | this.code = code;
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cunoraz/tagview/Constants.java:
--------------------------------------------------------------------------------
1 | package com.cunoraz.tagview;
2 |
3 | import android.graphics.Color;
4 |
5 | public class Constants {
6 |
7 | //use dp and sp, not px
8 |
9 | //----------------- separator TagView-----------------//
10 | public static final float DEFAULT_LINE_MARGIN = 5;
11 | public static final float DEFAULT_TAG_MARGIN = 5;
12 | public static final float DEFAULT_TAG_TEXT_PADDING_LEFT = 8;
13 | public static final float DEFAULT_TAG_TEXT_PADDING_TOP = 5;
14 | public static final float DEFAULT_TAG_TEXT_PADDING_RIGHT = 8;
15 | public static final float DEFAULT_TAG_TEXT_PADDING_BOTTOM = 5;
16 |
17 | public static final float LAYOUT_WIDTH_OFFSET = 2;
18 |
19 | //----------------- separator Tag Item-----------------//
20 | public static final float DEFAULT_TAG_TEXT_SIZE = 14f;
21 | public static final float DEFAULT_TAG_DELETE_INDICATOR_SIZE = 14f;
22 | public static final float DEFAULT_TAG_LAYOUT_BORDER_SIZE = 0f;
23 | public static final float DEFAULT_TAG_RADIUS = 100;
24 | public static final int DEFAULT_TAG_LAYOUT_COLOR = Color.parseColor("#AED374");
25 | public static final int DEFAULT_TAG_LAYOUT_COLOR_PRESS = Color.parseColor("#88363636");
26 | public static final int DEFAULT_TAG_TEXT_COLOR = Color.parseColor("#ffffff");
27 | public static final int DEFAULT_TAG_DELETE_INDICATOR_COLOR = Color.parseColor("#ffffff");
28 | public static final int DEFAULT_TAG_LAYOUT_BORDER_COLOR = Color.parseColor("#ffffff");
29 | public static final String DEFAULT_TAG_DELETE_ICON = "×";
30 | public static final boolean DEFAULT_TAG_IS_DELETABLE = false;
31 |
32 |
33 | private Constants() throws InstantiationException {
34 | throw new InstantiationException("This class is not for instantiation");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Android > Lint > Correctness
39 |
40 |
41 | Android > Lint > Internationalization
42 |
43 |
44 | Android > Lint > Performance
45 |
46 |
47 | Android > Lint > Usability
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | 1.8
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cunoraz/tagview/Tag.java:
--------------------------------------------------------------------------------
1 | package com.cunoraz.tagview;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 |
6 | public class Tag {
7 |
8 | private int id;
9 | private String text;
10 | private int tagTextColor;
11 | private float tagTextSize;
12 | private int layoutColor;
13 | private int layoutColorPress;
14 | private boolean isDeletable;
15 | private int deleteIndicatorColor;
16 | private float deleteIndicatorSize;
17 | private float radius;
18 | private String deleteIcon;
19 | private float layoutBorderSize;
20 | private int layoutBorderColor;
21 | private Drawable background;
22 |
23 |
24 | public Tag(String text) {
25 | init(0, text, Constants.DEFAULT_TAG_TEXT_COLOR, Constants.DEFAULT_TAG_TEXT_SIZE, Constants.DEFAULT_TAG_LAYOUT_COLOR, Constants.DEFAULT_TAG_LAYOUT_COLOR_PRESS,
26 | Constants.DEFAULT_TAG_IS_DELETABLE, Constants.DEFAULT_TAG_DELETE_INDICATOR_COLOR, Constants.DEFAULT_TAG_DELETE_INDICATOR_SIZE, Constants.DEFAULT_TAG_RADIUS, Constants.DEFAULT_TAG_DELETE_ICON, Constants.DEFAULT_TAG_LAYOUT_BORDER_SIZE, Constants.DEFAULT_TAG_LAYOUT_BORDER_COLOR);
27 | }
28 |
29 | private void init(int id, String text, int tagTextColor, float tagTextSize,
30 | int layoutColor, int layoutColorPress, boolean isDeletable,
31 | int deleteIndicatorColor,float deleteIndicatorSize, float radius,
32 | String deleteIcon, float layoutBorderSize, int layoutBorderColor) {
33 | this.id = id;
34 | this.text = text;
35 | this.tagTextColor = tagTextColor;
36 | this.tagTextSize = tagTextSize;
37 | this.layoutColor = layoutColor;
38 | this.layoutColorPress = layoutColorPress;
39 | this.isDeletable = isDeletable;
40 | this.deleteIndicatorColor = deleteIndicatorColor;
41 | this.deleteIndicatorSize = deleteIndicatorSize;
42 | this.radius = radius;
43 | this.deleteIcon = deleteIcon;
44 | this.layoutBorderSize = layoutBorderSize;
45 | this.layoutBorderColor = layoutBorderColor;
46 | }
47 |
48 | public void setTagTextColor(int tagTextColor) {
49 | this.tagTextColor = tagTextColor;
50 | }
51 |
52 | public void setTagTextSize(float tagTextSize) {
53 | this.tagTextSize = tagTextSize;
54 | }
55 |
56 | public void setLayoutColor(int layoutColor) {
57 | this.layoutColor = layoutColor;
58 | }
59 |
60 | public void setLayoutColorPress(int layoutColorPress) {
61 | this.layoutColorPress = layoutColorPress;
62 | }
63 |
64 | public void setDeletable(boolean deletable) {
65 | isDeletable = deletable;
66 | }
67 |
68 | public void setDeleteIndicatorColor(int deleteIndicatorColor) {
69 | this.deleteIndicatorColor = deleteIndicatorColor;
70 | }
71 |
72 | public void setDeleteIndicatorSize(float deleteIndicatorSize) {
73 | this.deleteIndicatorSize = deleteIndicatorSize;
74 | }
75 |
76 | public void setRadius(float radius) {
77 | this.radius = radius;
78 | }
79 |
80 | public void setDeleteIcon(String deleteIcon) {
81 | this.deleteIcon = deleteIcon;
82 | }
83 |
84 | public void setLayoutBorderSize(float layoutBorderSize) {
85 | this.layoutBorderSize = layoutBorderSize;
86 | }
87 |
88 | public void setLayoutBorderColor(int layoutBorderColor) {
89 | this.layoutBorderColor = layoutBorderColor;
90 | }
91 |
92 | public void setBackground(Drawable background) {
93 | this.background = background;
94 | }
95 |
96 | public String getText() {
97 | return text;
98 | }
99 |
100 | public int getTagTextColor() {
101 | return tagTextColor;
102 | }
103 |
104 | public float getTagTextSize() {
105 | return tagTextSize;
106 | }
107 |
108 | public int getLayoutColor() {
109 | return layoutColor;
110 | }
111 |
112 | public int getLayoutColorPress() {
113 | return layoutColorPress;
114 | }
115 |
116 | public boolean isDeletable() {
117 | return isDeletable;
118 | }
119 |
120 | public int getDeleteIndicatorColor() {
121 | return deleteIndicatorColor;
122 | }
123 |
124 | public float getDeleteIndicatorSize() {
125 | return deleteIndicatorSize;
126 | }
127 |
128 | public float getRadius() {
129 | return radius;
130 | }
131 |
132 | public String getDeleteIcon() {
133 | return deleteIcon;
134 | }
135 |
136 | public float getLayoutBorderSize() {
137 | return layoutBorderSize;
138 | }
139 |
140 | public int getLayoutBorderColor() {
141 | return layoutBorderColor;
142 | }
143 |
144 | public Drawable getBackground() {
145 | return background;
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/cuneyt/example/com/tagview/Activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cuneyt.example.com.tagview.Activity;
2 |
3 | import android.content.DialogInterface;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AlertDialog;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.text.Editable;
9 | import android.text.TextWatcher;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.EditText;
14 | import android.widget.Toast;
15 |
16 | import com.cunoraz.tagview.Tag;
17 | import com.cunoraz.tagview.TagView;
18 |
19 | import org.json.JSONArray;
20 | import org.json.JSONObject;
21 |
22 | import java.util.ArrayList;
23 |
24 | import cuneyt.example.com.tagview.Constants;
25 | import cuneyt.example.com.tagview.Models.TagClass;
26 | import cuneyt.example.com.tagview.R;
27 |
28 | public class MainActivity extends AppCompatActivity {
29 |
30 | private TagView tagGroup;
31 |
32 | private EditText editText;
33 |
34 |
35 | /**
36 | * sample country list
37 | */
38 | private ArrayList tagList;
39 |
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_main);
45 | tagGroup = (TagView) findViewById(R.id.tag_group);
46 | editText = (EditText) findViewById(R.id.editText);
47 |
48 | prepareTags();
49 |
50 | editText.addTextChangedListener(new TextWatcher() {
51 | @Override
52 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
53 |
54 | }
55 |
56 | @Override
57 | public void onTextChanged(CharSequence s, int start, int before, int count) {
58 | setTags(s);
59 | }
60 |
61 | @Override
62 | public void afterTextChanged(Editable s) {
63 |
64 | }
65 | });
66 |
67 | tagGroup.setOnTagLongClickListener(new TagView.OnTagLongClickListener() {
68 | @Override
69 | public void onTagLongClick(Tag tag, int position) {
70 | Toast.makeText(MainActivity.this, "Long Click: " + tag.getText(), Toast.LENGTH_SHORT).show();
71 | }
72 | });
73 |
74 | tagGroup.setOnTagClickListener(new TagView.OnTagClickListener() {
75 | @Override
76 | public void onTagClick(Tag tag, int position) {
77 | editText.setText(tag.getText());
78 | editText.setSelection(tag.getText().length());//to set cursor position
79 |
80 | }
81 | });
82 | tagGroup.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
83 |
84 | @Override
85 | public void onTagDeleted(final TagView view, final Tag tag, final int position) {
86 | AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
87 | builder.setMessage("\"" + tag.getText() + "\" will be delete. Are you sure?");
88 | builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
89 | @Override
90 | public void onClick(DialogInterface dialog, int which) {
91 | view.remove(position);
92 | Toast.makeText(MainActivity.this, "\"" + tag.getText() + "\" deleted", Toast.LENGTH_SHORT).show();
93 | }
94 | });
95 | builder.setNegativeButton("No", null);
96 | builder.show();
97 |
98 | }
99 | });
100 |
101 |
102 | }
103 |
104 | private void prepareTags() {
105 | tagList = new ArrayList<>();
106 | JSONArray jsonArray;
107 | JSONObject temp;
108 | try {
109 | jsonArray = new JSONArray(Constants.COUNTRIES);
110 | for (int i = 0; i < jsonArray.length(); i++) {
111 | temp = jsonArray.getJSONObject(i);
112 | tagList.add(new TagClass(temp.getString("code"), temp.getString("name")));
113 |
114 | }
115 | } catch (Exception e) {
116 | e.printStackTrace();
117 | }
118 |
119 | }
120 |
121 | private void setTags(CharSequence cs) {
122 | /**
123 | * for empty edittext
124 | */
125 | if (cs.toString().equals("")) {
126 | tagGroup.addTags(new ArrayList());
127 | return;
128 | }
129 |
130 | String text = cs.toString();
131 | ArrayList tags = new ArrayList<>();
132 | Tag tag;
133 |
134 |
135 | for (int i = 0; i < tagList.size(); i++) {
136 | if (tagList.get(i).getName().toLowerCase().startsWith(text.toLowerCase())) {
137 | tag = new Tag(tagList.get(i).getName());
138 | tag.setRadius(10f);
139 | tag.setLayoutColor(Color.parseColor(tagList.get(i).getColor()));
140 | if (i % 2 == 0) // you can set deletable or not
141 | tag.setDeletable(true);
142 | tags.add(tag);
143 | }
144 | }
145 | tagGroup.addTags(tags);
146 |
147 | }
148 |
149 | @Override
150 | public boolean onCreateOptionsMenu(Menu menu) {
151 | // Inflate the menu; this adds items to the action bar if it is present.
152 | getMenuInflater().inflate(R.menu.menu_main, menu);
153 | return true;
154 | }
155 |
156 | @Override
157 | public boolean onOptionsItemSelected(MenuItem item) {
158 | // Handle action bar item clicks here. The action bar will
159 | // automatically handle clicks on the Home/Up button, so long
160 | // as you specify a parent activity in AndroidManifest.xml.
161 | int id = item.getItemId();
162 |
163 | //noinspection SimplifiableIfStatement
164 | if (id == R.id.action_settings) {
165 | return true;
166 | }
167 |
168 | return super.onOptionsItemSelected(item);
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android TagView
2 | Android TagView-HashTagView
3 |
4 | [](https://android-arsenal.com/details/1/2566)
5 |
Xamarin version, written by @fernandolopes
6 | https://github.com/fernandolopes/Xamarin.Android.TagView
7 |
8 | Simple android view to display collection of colorful tags efficiently.
9 | You can edit the tag's style, and set listener of selecting or deleting tag.
10 | Example usages can be found in example project.
11 |
12 | # Screen
13 |
14 |
15 |
16 |
17 | # Feature
18 | * Editable Style of Text, such as Font size and color.
19 | * Editable Style of Tag, Background/Pressed Color, Radius effect, Custom Background, Delete mode.
20 | * Listener of tag selecting and deleting.
21 | * Can be created from XML file or Java code.
22 |
23 | # Gradle
24 | ``` java
25 | repositories {
26 | maven {
27 | url "https://jitpack.io"
28 | }
29 | }
30 | ```
31 | ``` java
32 | dependencies {
33 | compile 'com.github.Cutta:TagView:1.3'
34 | }
35 | ```
36 | # Usage
37 | <com.cunoraz.tagview.TagView
38 | xmlns:tagview="http://schemas.android.com/apk/res-auto"
39 | android:id="@+id/tag_group"
40 | android:layout_width="match_parent"
41 | android:layout_height="match_parent"
42 | android:layout_margin="10dp"
43 | tagview:lineMargin="5dp"
44 | tagview:tagMargin="5dp"
45 | tagview:textPaddingLeft="8dp"
46 | tagview:textPaddingTop="5dp"
47 | tagview:textPaddingRight="8dp"
48 | tagview:textPaddingBottom="5dp" />
49 |
50 |
51 | ``` java
52 | TagView tagGroup = (TagView)findviewById(R.id.tag_view);
53 | //You can add one tag
54 | tagGroup.addTag(Tag tag);
55 | //You can add multiple tag via ArrayList
56 | tagGroup.addTags(ArrayList tags);
57 | //Via string array
58 | addTags(String[] tags);
59 |
60 |
61 | //set click listener
62 | tagGroup.setOnTagClickListener(new OnTagClickListener() {
63 | @Override
64 | public void onTagClick(Tag tag, int position) {
65 | }
66 | });
67 |
68 | //set delete listener
69 | tagGroup.setOnTagDeleteListener(new OnTagDeleteListener() {
70 | @Override
71 | public void onTagDeleted(final TagView view, final Tag tag, final int position) {
72 | }
73 | });
74 |
75 | //set long click listener
76 | tagGroup.setOnTagLongClickListener(new OnTagLongClickListener() {
77 | @Override
78 | public void onTagLongClick(Tag tag, int position) {
79 | }
80 | });
81 | ```
82 |
83 | # Sample APK
84 | https://www.dropbox.com/s/m1y1npssj5b4bck/app-debug.apk?dl=0
85 |
86 | # Credits
87 |
88 |
89 |
90 |
91 | # License
92 | Copyright 2015 Cüneyt Çarıkçi.
93 |
94 | Licensed under the Apache License, Version 2.0 (the "License");
95 | you may not use this file except in compliance with the License.
96 | You may obtain a copy of the License at
97 |
98 | http://www.apache.org/licenses/LICENSE-2.0
99 |
100 | Unless required by applicable law or agreed to in writing, software
101 | distributed under the License is distributed on an "AS IS" BASIS,
102 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
103 | See the License for the specific language governing permissions and
104 | limitations under the License.
105 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cunoraz/tagview/TagView.java:
--------------------------------------------------------------------------------
1 | package com.cunoraz.tagview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.drawable.Drawable;
7 | import android.graphics.drawable.GradientDrawable;
8 | import android.graphics.drawable.StateListDrawable;
9 | import android.os.Build;
10 | import android.util.AttributeSet;
11 | import android.util.TypedValue;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.view.ViewTreeObserver;
16 | import android.widget.LinearLayout;
17 | import android.widget.RelativeLayout;
18 | import android.widget.TextView;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | public class TagView extends RelativeLayout {
24 |
25 | /**
26 | * tag list
27 | */
28 | private List mTags = new ArrayList<>();
29 |
30 | /**
31 | * System Service
32 | */
33 | private LayoutInflater mInflater;
34 | private ViewTreeObserver mViewTreeObserber;
35 |
36 | /**
37 | * listeners
38 | */
39 | private OnTagClickListener mClickListener;
40 | private OnTagDeleteListener mDeleteListener;
41 | private OnTagLongClickListener mTagLongClickListener;
42 |
43 | /**
44 | * view size param
45 | */
46 | private int mWidth;
47 |
48 | /**
49 | * layout initialize flag
50 | */
51 | private boolean mInitialized = false;
52 |
53 | /**
54 | * custom layout param
55 | */
56 | private int lineMargin;
57 | private int tagMargin;
58 | private int textPaddingLeft;
59 | private int textPaddingRight;
60 | private int textPaddingTop;
61 | private int textPaddingBottom;
62 |
63 |
64 | /**
65 | * constructor
66 | *
67 | * @param ctx
68 | */
69 | public TagView(Context ctx) {
70 | super(ctx, null);
71 | initialize(ctx, null, 0);
72 | }
73 |
74 | /**
75 | * constructor
76 | *
77 | * @param ctx
78 | * @param attrs
79 | */
80 | public TagView(Context ctx, AttributeSet attrs) {
81 | super(ctx, attrs);
82 | initialize(ctx, attrs, 0);
83 | }
84 |
85 | /**
86 | * constructor
87 | *
88 | * @param ctx
89 | * @param attrs
90 | * @param defStyle
91 | */
92 | public TagView(Context ctx, AttributeSet attrs, int defStyle) {
93 | super(ctx, attrs, defStyle);
94 | initialize(ctx, attrs, defStyle);
95 | }
96 |
97 | /**
98 | * initalize instance
99 | *
100 | * @param ctx
101 | * @param attrs
102 | * @param defStyle
103 | */
104 | private void initialize(Context ctx, AttributeSet attrs, int defStyle) {
105 | mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
106 | mViewTreeObserber = getViewTreeObserver();
107 | mViewTreeObserber.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
108 | @Override
109 | public void onGlobalLayout() {
110 | if (!mInitialized) {
111 | mInitialized = true;
112 | drawTags();
113 | }
114 | }
115 | });
116 |
117 | // get AttributeSet
118 | TypedArray typeArray = ctx.obtainStyledAttributes(attrs, R.styleable.TagView, defStyle, defStyle);
119 | this.lineMargin = (int) typeArray.getDimension(R.styleable.TagView_lineMargin, Utils.dipToPx(this.getContext(), Constants.DEFAULT_LINE_MARGIN));
120 | this.tagMargin = (int) typeArray.getDimension(R.styleable.TagView_tagMargin, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_MARGIN));
121 | this.textPaddingLeft = (int) typeArray.getDimension(R.styleable.TagView_textPaddingLeft, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_LEFT));
122 | this.textPaddingRight = (int) typeArray.getDimension(R.styleable.TagView_textPaddingRight, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_RIGHT));
123 | this.textPaddingTop = (int) typeArray.getDimension(R.styleable.TagView_textPaddingTop, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_TOP));
124 | this.textPaddingBottom = (int) typeArray.getDimension(R.styleable.TagView_textPaddingBottom, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_BOTTOM));
125 | typeArray.recycle();
126 | }
127 |
128 | /**
129 | * onSizeChanged
130 | *
131 | * @param w
132 | * @param h
133 | * @param oldw
134 | * @param oldh
135 | */
136 | @Override
137 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
138 | super.onSizeChanged(w, h, oldw, oldh);
139 | mWidth = w;
140 | }
141 |
142 | @Override
143 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
144 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
145 | int width = getMeasuredWidth();
146 | if (width <= 0)
147 | return;
148 | mWidth = getMeasuredWidth();
149 | }
150 |
151 | @Override
152 | protected void onDraw(Canvas canvas) {
153 | super.onDraw(canvas);
154 | drawTags();
155 | }
156 |
157 | /**
158 | * tag draw
159 | */
160 | private void drawTags() {
161 |
162 | if (!mInitialized) {
163 | return;
164 | }
165 |
166 | // clear all tag
167 | removeAllViews();
168 |
169 | // layout padding left & layout padding right
170 | float total = getPaddingLeft() + getPaddingRight();
171 |
172 | int listIndex = 1;// List Index
173 | int indexBottom = 1;// The Tag to add below
174 | int indexHeader = 1;// The header tag of this line
175 | Tag tagPre = null;
176 | for (Tag item : mTags) {
177 | final int position = listIndex - 1;
178 | final Tag tag = item;
179 |
180 | // inflate tag layout
181 | View tagLayout = mInflater.inflate(R.layout.tagview_item, null);
182 | tagLayout.setId(listIndex);
183 |
184 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
185 | tagLayout.setBackgroundDrawable(getSelector(tag));
186 | } else {
187 | tagLayout.setBackground(getSelector(tag));
188 | }
189 |
190 | // tag text
191 | TextView tagView = (TextView) tagLayout.findViewById(R.id.tv_tag_item_contain);
192 | tagView.setText(tag.getText());
193 | LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tagView.getLayoutParams();
194 | params.setMargins(textPaddingLeft, textPaddingTop, textPaddingRight, textPaddingBottom);
195 | tagView.setLayoutParams(params);
196 | tagView.setTextColor(tag.getTagTextColor());
197 | tagView.setTextSize(TypedValue.COMPLEX_UNIT_SP, tag.getTagTextSize());
198 |
199 | tagLayout.setOnClickListener(new OnClickListener() {
200 | @Override
201 | public void onClick(View v) {
202 | if (mClickListener != null) {
203 | mClickListener.onTagClick(tag, position);
204 | }
205 | }
206 | });
207 |
208 | tagLayout.setOnLongClickListener(new OnLongClickListener() {
209 | @Override
210 | public boolean onLongClick(View v) {
211 | if (mTagLongClickListener != null) {
212 | mTagLongClickListener.onTagLongClick(tag, position);
213 | }
214 | return true;
215 | }
216 | });
217 |
218 | // calculate of tag layout width
219 | float tagWidth = tagView.getPaint().measureText(tag.getText()) + textPaddingLeft + textPaddingRight;
220 | // tagView padding (left & right)
221 |
222 | // deletable text
223 | TextView deletableView = (TextView) tagLayout.findViewById(R.id.tv_tag_item_delete);
224 |
225 | if (tag.isDeletable()) {
226 | deletableView.setVisibility(View.VISIBLE);
227 | deletableView.setText(tag.getDeleteIcon());
228 | int offset = Utils.dipToPx(getContext(), 2f);
229 | deletableView.setPadding(offset, textPaddingTop, textPaddingRight + offset, textPaddingBottom);
230 | deletableView.setTextColor(tag.getDeleteIndicatorColor());
231 | deletableView.setTextSize(TypedValue.COMPLEX_UNIT_SP, tag.getDeleteIndicatorSize());
232 | deletableView.setOnClickListener(new OnClickListener() {
233 | @Override
234 | public void onClick(View v) {
235 | if (mDeleteListener != null) {
236 | mDeleteListener.onTagDeleted(TagView.this, tag, position);
237 | }
238 | }
239 | });
240 | tagWidth += deletableView.getPaint().measureText(tag.getDeleteIcon()) + textPaddingLeft + textPaddingRight;
241 | // deletableView Padding (left & right)
242 | } else {
243 | deletableView.setVisibility(View.GONE);
244 | }
245 |
246 | LayoutParams tagParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
247 |
248 | //add margin of each line
249 | tagParams.bottomMargin = lineMargin;
250 |
251 | if (mWidth <= total + tagWidth + Utils.dipToPx(this.getContext(), Constants.LAYOUT_WIDTH_OFFSET)) {
252 | //need to add in new line
253 | if (tagPre != null) tagParams.addRule(RelativeLayout.BELOW, indexBottom);
254 | // initialize total param (layout padding left & layout padding right)
255 | total = getPaddingLeft() + getPaddingRight();
256 | indexBottom = listIndex;
257 | indexHeader = listIndex;
258 | } else {
259 | //no need to new line
260 | tagParams.addRule(RelativeLayout.ALIGN_TOP, indexHeader);
261 | //not header of the line
262 | if (listIndex != indexHeader) {
263 | tagParams.addRule(RelativeLayout.RIGHT_OF, listIndex - 1);
264 | tagParams.leftMargin = tagMargin;
265 | total += tagMargin;
266 | if (tagPre.getTagTextSize() < tag.getTagTextSize()) {
267 | indexBottom = listIndex;
268 | }
269 | }
270 |
271 |
272 | }
273 | total += tagWidth;
274 | addView(tagLayout, tagParams);
275 | tagPre = tag;
276 | listIndex++;
277 |
278 | }
279 |
280 | }
281 |
282 | private Drawable getSelector(Tag tag) {
283 | if (tag.getBackground() != null)
284 | return tag.getBackground();
285 |
286 | StateListDrawable states = new StateListDrawable();
287 | GradientDrawable gdNormal = new GradientDrawable();
288 | gdNormal.setColor(tag.getLayoutColor());
289 | gdNormal.setCornerRadius(tag.getRadius());
290 | if (tag.getLayoutBorderSize() > 0) {
291 | gdNormal.setStroke(Utils.dipToPx(getContext(), tag.getLayoutBorderSize()), tag.getLayoutBorderColor());
292 | }
293 | GradientDrawable gdPress = new GradientDrawable();
294 | gdPress.setColor(tag.getLayoutColorPress());
295 | gdPress.setCornerRadius(tag.getRadius());
296 | states.addState(new int[]{android.R.attr.state_pressed}, gdPress);
297 | //must add state_pressed first,or state_pressed will not take effect
298 | states.addState(new int[]{}, gdNormal);
299 | return states;
300 | }
301 |
302 |
303 | //public methods
304 | //----------------- separator -----------------//
305 |
306 | /**
307 | * @param tag
308 | */
309 | public void addTag(Tag tag) {
310 |
311 | mTags.add(tag);
312 | drawTags();
313 | }
314 |
315 | public void addTags(List tags) {
316 | if (tags == null) return;
317 | mTags = new ArrayList<>();
318 | if (tags.isEmpty())
319 | drawTags();
320 | for (Tag item : tags) {
321 | mTags.add(item);
322 | }
323 | drawTags();
324 | }
325 |
326 |
327 | public void addTags(String[] tags) {
328 | if (tags == null) return;
329 | for (String item : tags) {
330 | Tag tag = new Tag(item);
331 | mTags.add(tag);
332 | }
333 | drawTags();
334 | }
335 |
336 |
337 | /**
338 | * get tag list
339 | *
340 | * @return mTags TagObject List
341 | */
342 | public List getTags() {
343 | return mTags;
344 | }
345 |
346 | /**
347 | * remove tag
348 | *
349 | * @param position
350 | */
351 | public void remove(int position) {
352 | if (position < mTags.size()) {
353 | mTags.remove(position);
354 | drawTags();
355 | }
356 | }
357 |
358 | /**
359 | * remove all views
360 | */
361 | public void removeAll() {
362 | mTags.clear(); //clear all of tags
363 | removeAllViews();
364 | }
365 |
366 | public int getLineMargin() {
367 | return lineMargin;
368 | }
369 |
370 | public void setLineMargin(float lineMargin) {
371 | this.lineMargin = Utils.dipToPx(getContext(), lineMargin);
372 | }
373 |
374 | public int getTagMargin() {
375 | return tagMargin;
376 | }
377 |
378 | public void setTagMargin(float tagMargin) {
379 | this.tagMargin = Utils.dipToPx(getContext(), tagMargin);
380 | }
381 |
382 | public int getTextPaddingLeft() {
383 | return textPaddingLeft;
384 | }
385 |
386 | public void setTextPaddingLeft(float textPaddingLeft) {
387 | this.textPaddingLeft = Utils.dipToPx(getContext(), textPaddingLeft);
388 | }
389 |
390 | public int getTextPaddingRight() {
391 | return textPaddingRight;
392 | }
393 |
394 | public void setTextPaddingRight(float textPaddingRight) {
395 | this.textPaddingRight = Utils.dipToPx(getContext(), textPaddingRight);
396 | }
397 |
398 | public int getTextPaddingTop() {
399 | return textPaddingTop;
400 | }
401 |
402 | public void setTextPaddingTop(float textPaddingTop) {
403 | this.textPaddingTop = Utils.dipToPx(getContext(), textPaddingTop);
404 | }
405 |
406 | public int gettextPaddingBottom() {
407 | return textPaddingBottom;
408 | }
409 |
410 | public void settextPaddingBottom(float textPaddingBottom) {
411 | this.textPaddingBottom = Utils.dipToPx(getContext(), textPaddingBottom);
412 | }
413 |
414 |
415 | /**
416 | * setter for OnTagLongClickListener
417 | *
418 | * @param longClickListener
419 | */
420 | public void setOnTagLongClickListener(OnTagLongClickListener longClickListener) {
421 | mTagLongClickListener = longClickListener;
422 | }
423 |
424 | /**
425 | * setter for OnTagSelectListener
426 | *
427 | * @param clickListener
428 | */
429 | public void setOnTagClickListener(OnTagClickListener clickListener) {
430 | mClickListener = clickListener;
431 | }
432 |
433 | /**
434 | * setter for OnTagDeleteListener
435 | *
436 | * @param deleteListener
437 | */
438 | public void setOnTagDeleteListener(OnTagDeleteListener deleteListener) {
439 | mDeleteListener = deleteListener;
440 | }
441 |
442 | /**
443 | * Listeners
444 | */
445 | public interface OnTagDeleteListener {
446 | void onTagDeleted(TagView view, Tag tag, int position);
447 | }
448 |
449 | public interface OnTagClickListener {
450 | void onTagClick(Tag tag, int position);
451 | }
452 |
453 | public interface OnTagLongClickListener {
454 | void onTagLongClick(Tag tag, int position);
455 | }
456 | }
457 |
--------------------------------------------------------------------------------
/app/src/main/java/cuneyt/example/com/tagview/Constants.java:
--------------------------------------------------------------------------------
1 | package cuneyt.example.com.tagview;
2 |
3 | /**
4 | * Created by cuneytcarikci on 29/07/16.
5 | */
6 | public class Constants {
7 |
8 | /**
9 | * list from:
10 | * https://gist.github.com/Keeguon/2310008
11 | */
12 | public static final String COUNTRIES = "[ \n" +
13 | "{\"name\": \"Afghanistan\", \"code\": \"AF\"}, \n" +
14 | "{\"name\": \"Åland Islands\", \"code\": \"AX\"}, \n" +
15 | "{\"name\": \"Albania\", \"code\": \"AL\"}, \n" +
16 | "{\"name\": \"Algeria\", \"code\": \"DZ\"}, \n" +
17 | "{\"name\": \"American Samoa\", \"code\": \"AS\"}, \n" +
18 | "{\"name\": \"AndorrA\", \"code\": \"AD\"}, \n" +
19 | "{\"name\": \"Angola\", \"code\": \"AO\"}, \n" +
20 | "{\"name\": \"Anguilla\", \"code\": \"AI\"}, \n" +
21 | "{\"name\": \"Antarctica\", \"code\": \"AQ\"}, \n" +
22 | "{\"name\": \"Antigua and Barbuda\", \"code\": \"AG\"}, \n" +
23 | "{\"name\": \"Argentina\", \"code\": \"AR\"}, \n" +
24 | "{\"name\": \"Armenia\", \"code\": \"AM\"}, \n" +
25 | "{\"name\": \"Aruba\", \"code\": \"AW\"}, \n" +
26 | "{\"name\": \"Australia\", \"code\": \"AU\"}, \n" +
27 | "{\"name\": \"Austria\", \"code\": \"AT\"}, \n" +
28 | "{\"name\": \"Azerbaijan\", \"code\": \"AZ\"}, \n" +
29 | "{\"name\": \"Bahamas\", \"code\": \"BS\"}, \n" +
30 | "{\"name\": \"Bahrain\", \"code\": \"BH\"}, \n" +
31 | "{\"name\": \"Bangladesh\", \"code\": \"BD\"}, \n" +
32 | "{\"name\": \"Barbados\", \"code\": \"BB\"}, \n" +
33 | "{\"name\": \"Belarus\", \"code\": \"BY\"}, \n" +
34 | "{\"name\": \"Belgium\", \"code\": \"BE\"}, \n" +
35 | "{\"name\": \"Belize\", \"code\": \"BZ\"}, \n" +
36 | "{\"name\": \"Benin\", \"code\": \"BJ\"}, \n" +
37 | "{\"name\": \"Bermuda\", \"code\": \"BM\"}, \n" +
38 | "{\"name\": \"Bhutan\", \"code\": \"BT\"}, \n" +
39 | "{\"name\": \"Bolivia\", \"code\": \"BO\"}, \n" +
40 | "{\"name\": \"Bosnia and Herzegovina\", \"code\": \"BA\"}, \n" +
41 | "{\"name\": \"Botswana\", \"code\": \"BW\"}, \n" +
42 | "{\"name\": \"Bouvet Island\", \"code\": \"BV\"}, \n" +
43 | "{\"name\": \"Brazil\", \"code\": \"BR\"}, \n" +
44 | "{\"name\": \"British Indian Ocean Territory\", \"code\": \"IO\"}, \n" +
45 | "{\"name\": \"Brunei Darussalam\", \"code\": \"BN\"}, \n" +
46 | "{\"name\": \"Bulgaria\", \"code\": \"BG\"}, \n" +
47 | "{\"name\": \"Burkina Faso\", \"code\": \"BF\"}, \n" +
48 | "{\"name\": \"Burundi\", \"code\": \"BI\"}, \n" +
49 | "{\"name\": \"Cambodia\", \"code\": \"KH\"}, \n" +
50 | "{\"name\": \"Cameroon\", \"code\": \"CM\"}, \n" +
51 | "{\"name\": \"Canada\", \"code\": \"CA\"}, \n" +
52 | "{\"name\": \"Cape Verde\", \"code\": \"CV\"}, \n" +
53 | "{\"name\": \"Cayman Islands\", \"code\": \"KY\"}, \n" +
54 | "{\"name\": \"Central African Republic\", \"code\": \"CF\"}, \n" +
55 | "{\"name\": \"Chad\", \"code\": \"TD\"}, \n" +
56 | "{\"name\": \"Chile\", \"code\": \"CL\"}, \n" +
57 | "{\"name\": \"China\", \"code\": \"CN\"}, \n" +
58 | "{\"name\": \"Christmas Island\", \"code\": \"CX\"}, \n" +
59 | "{\"name\": \"Cocos (Keeling) Islands\", \"code\": \"CC\"}, \n" +
60 | "{\"name\": \"Colombia\", \"code\": \"CO\"}, \n" +
61 | "{\"name\": \"Comoros\", \"code\": \"KM\"}, \n" +
62 | "{\"name\": \"Congo\", \"code\": \"CG\"}, \n" +
63 | "{\"name\": \"Congo, The Democratic Republic of the\", \"code\": \"CD\"}, \n" +
64 | "{\"name\": \"Cook Islands\", \"code\": \"CK\"}, \n" +
65 | "{\"name\": \"Costa Rica\", \"code\": \"CR\"}, \n" +
66 | "{\"name\": \"Cote D\\\"Ivoire\", \"code\": \"CI\"}, \n" +
67 | "{\"name\": \"Croatia\", \"code\": \"HR\"}, \n" +
68 | "{\"name\": \"Cuba\", \"code\": \"CU\"}, \n" +
69 | "{\"name\": \"Cyprus\", \"code\": \"CY\"}, \n" +
70 | "{\"name\": \"Czech Republic\", \"code\": \"CZ\"}, \n" +
71 | "{\"name\": \"Denmark\", \"code\": \"DK\"}, \n" +
72 | "{\"name\": \"Djibouti\", \"code\": \"DJ\"}, \n" +
73 | "{\"name\": \"Dominica\", \"code\": \"DM\"}, \n" +
74 | "{\"name\": \"Dominican Republic\", \"code\": \"DO\"}, \n" +
75 | "{\"name\": \"Ecuador\", \"code\": \"EC\"}, \n" +
76 | "{\"name\": \"Egypt\", \"code\": \"EG\"}, \n" +
77 | "{\"name\": \"El Salvador\", \"code\": \"SV\"}, \n" +
78 | "{\"name\": \"Equatorial Guinea\", \"code\": \"GQ\"}, \n" +
79 | "{\"name\": \"Eritrea\", \"code\": \"ER\"}, \n" +
80 | "{\"name\": \"Estonia\", \"code\": \"EE\"}, \n" +
81 | "{\"name\": \"Ethiopia\", \"code\": \"ET\"}, \n" +
82 | "{\"name\": \"Falkland Islands (Malvinas)\", \"code\": \"FK\"}, \n" +
83 | "{\"name\": \"Faroe Islands\", \"code\": \"FO\"}, \n" +
84 | "{\"name\": \"Fiji\", \"code\": \"FJ\"}, \n" +
85 | "{\"name\": \"Finland\", \"code\": \"FI\"}, \n" +
86 | "{\"name\": \"France\", \"code\": \"FR\"}, \n" +
87 | "{\"name\": \"French Guiana\", \"code\": \"GF\"}, \n" +
88 | "{\"name\": \"French Polynesia\", \"code\": \"PF\"}, \n" +
89 | "{\"name\": \"French Southern Territories\", \"code\": \"TF\"}, \n" +
90 | "{\"name\": \"Gabon\", \"code\": \"GA\"}, \n" +
91 | "{\"name\": \"Gambia\", \"code\": \"GM\"}, \n" +
92 | "{\"name\": \"Georgia\", \"code\": \"GE\"}, \n" +
93 | "{\"name\": \"Germany\", \"code\": \"DE\"}, \n" +
94 | "{\"name\": \"Ghana\", \"code\": \"GH\"}, \n" +
95 | "{\"name\": \"Gibraltar\", \"code\": \"GI\"}, \n" +
96 | "{\"name\": \"Greece\", \"code\": \"GR\"}, \n" +
97 | "{\"name\": \"Greenland\", \"code\": \"GL\"}, \n" +
98 | "{\"name\": \"Grenada\", \"code\": \"GD\"}, \n" +
99 | "{\"name\": \"Guadeloupe\", \"code\": \"GP\"}, \n" +
100 | "{\"name\": \"Guam\", \"code\": \"GU\"}, \n" +
101 | "{\"name\": \"Guatemala\", \"code\": \"GT\"}, \n" +
102 | "{\"name\": \"Guernsey\", \"code\": \"GG\"}, \n" +
103 | "{\"name\": \"Guinea\", \"code\": \"GN\"}, \n" +
104 | "{\"name\": \"Guinea-Bissau\", \"code\": \"GW\"}, \n" +
105 | "{\"name\": \"Guyana\", \"code\": \"GY\"}, \n" +
106 | "{\"name\": \"Haiti\", \"code\": \"HT\"}, \n" +
107 | "{\"name\": \"Heard Island and Mcdonald Islands\", \"code\": \"HM\"}, \n" +
108 | "{\"name\": \"Holy See (Vatican City State)\", \"code\": \"VA\"}, \n" +
109 | "{\"name\": \"Honduras\", \"code\": \"HN\"}, \n" +
110 | "{\"name\": \"Hong Kong\", \"code\": \"HK\"}, \n" +
111 | "{\"name\": \"Hungary\", \"code\": \"HU\"}, \n" +
112 | "{\"name\": \"Iceland\", \"code\": \"IS\"}, \n" +
113 | "{\"name\": \"India\", \"code\": \"IN\"}, \n" +
114 | "{\"name\": \"Indonesia\", \"code\": \"ID\"}, \n" +
115 | "{\"name\": \"Iran, Islamic Republic Of\", \"code\": \"IR\"}, \n" +
116 | "{\"name\": \"Iraq\", \"code\": \"IQ\"}, \n" +
117 | "{\"name\": \"Ireland\", \"code\": \"IE\"}, \n" +
118 | "{\"name\": \"Isle of Man\", \"code\": \"IM\"}, \n" +
119 | "{\"name\": \"Israel\", \"code\": \"IL\"}, \n" +
120 | "{\"name\": \"Italy\", \"code\": \"IT\"}, \n" +
121 | "{\"name\": \"Jamaica\", \"code\": \"JM\"}, \n" +
122 | "{\"name\": \"Japan\", \"code\": \"JP\"}, \n" +
123 | "{\"name\": \"Jersey\", \"code\": \"JE\"}, \n" +
124 | "{\"name\": \"Jordan\", \"code\": \"JO\"}, \n" +
125 | "{\"name\": \"Kazakhstan\", \"code\": \"KZ\"}, \n" +
126 | "{\"name\": \"Kenya\", \"code\": \"KE\"}, \n" +
127 | "{\"name\": \"Kiribati\", \"code\": \"KI\"}, \n" +
128 | "{\"name\": \"Korea, Democratic People\\\"S Republic of\", \"code\": \"KP\"}, \n" +
129 | "{\"name\": \"Korea, Republic of\", \"code\": \"KR\"}, \n" +
130 | "{\"name\": \"Kuwait\", \"code\": \"KW\"}, \n" +
131 | "{\"name\": \"Kyrgyzstan\", \"code\": \"KG\"}, \n" +
132 | "{\"name\": \"Lao People\\\"S Democratic Republic\", \"code\": \"LA\"}, \n" +
133 | "{\"name\": \"Latvia\", \"code\": \"LV\"}, \n" +
134 | "{\"name\": \"Lebanon\", \"code\": \"LB\"}, \n" +
135 | "{\"name\": \"Lesotho\", \"code\": \"LS\"}, \n" +
136 | "{\"name\": \"Liberia\", \"code\": \"LR\"}, \n" +
137 | "{\"name\": \"Libyan Arab Jamahiriya\", \"code\": \"LY\"}, \n" +
138 | "{\"name\": \"Liechtenstein\", \"code\": \"LI\"}, \n" +
139 | "{\"name\": \"Lithuania\", \"code\": \"LT\"}, \n" +
140 | "{\"name\": \"Luxembourg\", \"code\": \"LU\"}, \n" +
141 | "{\"name\": \"Macao\", \"code\": \"MO\"}, \n" +
142 | "{\"name\": \"Macedonia, The Former Yugoslav Republic of\", \"code\": \"MK\"}, \n" +
143 | "{\"name\": \"Madagascar\", \"code\": \"MG\"}, \n" +
144 | "{\"name\": \"Malawi\", \"code\": \"MW\"}, \n" +
145 | "{\"name\": \"Malaysia\", \"code\": \"MY\"}, \n" +
146 | "{\"name\": \"Maldives\", \"code\": \"MV\"}, \n" +
147 | "{\"name\": \"Mali\", \"code\": \"ML\"}, \n" +
148 | "{\"name\": \"Malta\", \"code\": \"MT\"}, \n" +
149 | "{\"name\": \"Marshall Islands\", \"code\": \"MH\"}, \n" +
150 | "{\"name\": \"Martinique\", \"code\": \"MQ\"}, \n" +
151 | "{\"name\": \"Mauritania\", \"code\": \"MR\"}, \n" +
152 | "{\"name\": \"Mauritius\", \"code\": \"MU\"}, \n" +
153 | "{\"name\": \"Mayotte\", \"code\": \"YT\"}, \n" +
154 | "{\"name\": \"Mexico\", \"code\": \"MX\"}, \n" +
155 | "{\"name\": \"Micronesia, Federated States of\", \"code\": \"FM\"}, \n" +
156 | "{\"name\": \"Moldova, Republic of\", \"code\": \"MD\"}, \n" +
157 | "{\"name\": \"Monaco\", \"code\": \"MC\"}, \n" +
158 | "{\"name\": \"Mongolia\", \"code\": \"MN\"}, \n" +
159 | "{\"name\": \"Montserrat\", \"code\": \"MS\"}, \n" +
160 | "{\"name\": \"Morocco\", \"code\": \"MA\"}, \n" +
161 | "{\"name\": \"Mozambique\", \"code\": \"MZ\"}, \n" +
162 | "{\"name\": \"Myanmar\", \"code\": \"MM\"}, \n" +
163 | "{\"name\": \"Namibia\", \"code\": \"NA\"}, \n" +
164 | "{\"name\": \"Nauru\", \"code\": \"NR\"}, \n" +
165 | "{\"name\": \"Nepal\", \"code\": \"NP\"}, \n" +
166 | "{\"name\": \"Netherlands\", \"code\": \"NL\"}, \n" +
167 | "{\"name\": \"Netherlands Antilles\", \"code\": \"AN\"}, \n" +
168 | "{\"name\": \"New Caledonia\", \"code\": \"NC\"}, \n" +
169 | "{\"name\": \"New Zealand\", \"code\": \"NZ\"}, \n" +
170 | "{\"name\": \"Nicaragua\", \"code\": \"NI\"}, \n" +
171 | "{\"name\": \"Niger\", \"code\": \"NE\"}, \n" +
172 | "{\"name\": \"Nigeria\", \"code\": \"NG\"}, \n" +
173 | "{\"name\": \"Niue\", \"code\": \"NU\"}, \n" +
174 | "{\"name\": \"Norfolk Island\", \"code\": \"NF\"}, \n" +
175 | "{\"name\": \"Northern Mariana Islands\", \"code\": \"MP\"}, \n" +
176 | "{\"name\": \"Norway\", \"code\": \"NO\"}, \n" +
177 | "{\"name\": \"Oman\", \"code\": \"OM\"}, \n" +
178 | "{\"name\": \"Pakistan\", \"code\": \"PK\"}, \n" +
179 | "{\"name\": \"Palau\", \"code\": \"PW\"}, \n" +
180 | "{\"name\": \"Palestinian Territory, Occupied\", \"code\": \"PS\"}, \n" +
181 | "{\"name\": \"Panama\", \"code\": \"PA\"}, \n" +
182 | "{\"name\": \"Papua New Guinea\", \"code\": \"PG\"}, \n" +
183 | "{\"name\": \"Paraguay\", \"code\": \"PY\"}, \n" +
184 | "{\"name\": \"Peru\", \"code\": \"PE\"}, \n" +
185 | "{\"name\": \"Philippines\", \"code\": \"PH\"}, \n" +
186 | "{\"name\": \"Pitcairn\", \"code\": \"PN\"}, \n" +
187 | "{\"name\": \"Poland\", \"code\": \"PL\"}, \n" +
188 | "{\"name\": \"Portugal\", \"code\": \"PT\"}, \n" +
189 | "{\"name\": \"Puerto Rico\", \"code\": \"PR\"}, \n" +
190 | "{\"name\": \"Qatar\", \"code\": \"QA\"}, \n" +
191 | "{\"name\": \"Reunion\", \"code\": \"RE\"}, \n" +
192 | "{\"name\": \"Romania\", \"code\": \"RO\"}, \n" +
193 | "{\"name\": \"Russian Federation\", \"code\": \"RU\"}, \n" +
194 | "{\"name\": \"RWANDA\", \"code\": \"RW\"}, \n" +
195 | "{\"name\": \"Saint Helena\", \"code\": \"SH\"}, \n" +
196 | "{\"name\": \"Saint Kitts and Nevis\", \"code\": \"KN\"}, \n" +
197 | "{\"name\": \"Saint Lucia\", \"code\": \"LC\"}, \n" +
198 | "{\"name\": \"Saint Pierre and Miquelon\", \"code\": \"PM\"}, \n" +
199 | "{\"name\": \"Saint Vincent and the Grenadines\", \"code\": \"VC\"}, \n" +
200 | "{\"name\": \"Samoa\", \"code\": \"WS\"}, \n" +
201 | "{\"name\": \"San Marino\", \"code\": \"SM\"}, \n" +
202 | "{\"name\": \"Sao Tome and Principe\", \"code\": \"ST\"}, \n" +
203 | "{\"name\": \"Saudi Arabia\", \"code\": \"SA\"}, \n" +
204 | "{\"name\": \"Senegal\", \"code\": \"SN\"}, \n" +
205 | "{\"name\": \"Serbia and Montenegro\", \"code\": \"CS\"}, \n" +
206 | "{\"name\": \"Seychelles\", \"code\": \"SC\"}, \n" +
207 | "{\"name\": \"Sierra Leone\", \"code\": \"SL\"}, \n" +
208 | "{\"name\": \"Singapore\", \"code\": \"SG\"}, \n" +
209 | "{\"name\": \"Slovakia\", \"code\": \"SK\"}, \n" +
210 | "{\"name\": \"Slovenia\", \"code\": \"SI\"}, \n" +
211 | "{\"name\": \"Solomon Islands\", \"code\": \"SB\"}, \n" +
212 | "{\"name\": \"Somalia\", \"code\": \"SO\"}, \n" +
213 | "{\"name\": \"South Africa\", \"code\": \"ZA\"}, \n" +
214 | "{\"name\": \"South Georgia and the South Sandwich Islands\", \"code\": \"GS\"}, \n" +
215 | "{\"name\": \"Spain\", \"code\": \"ES\"}, \n" +
216 | "{\"name\": \"Sri Lanka\", \"code\": \"LK\"}, \n" +
217 | "{\"name\": \"Sudan\", \"code\": \"SD\"}, \n" +
218 | "{\"name\": \"Suriname\", \"code\": \"SR\"}, \n" +
219 | "{\"name\": \"Svalbard and Jan Mayen\", \"code\": \"SJ\"}, \n" +
220 | "{\"name\": \"Swaziland\", \"code\": \"SZ\"}, \n" +
221 | "{\"name\": \"Sweden\", \"code\": \"SE\"}, \n" +
222 | "{\"name\": \"Switzerland\", \"code\": \"CH\"}, \n" +
223 | "{\"name\": \"Syrian Arab Republic\", \"code\": \"SY\"}, \n" +
224 | "{\"name\": \"Taiwan, Province of China\", \"code\": \"TW\"}, \n" +
225 | "{\"name\": \"Tajikistan\", \"code\": \"TJ\"}, \n" +
226 | "{\"name\": \"Tanzania, United Republic of\", \"code\": \"TZ\"}, \n" +
227 | "{\"name\": \"Thailand\", \"code\": \"TH\"}, \n" +
228 | "{\"name\": \"Timor-Leste\", \"code\": \"TL\"}, \n" +
229 | "{\"name\": \"Togo\", \"code\": \"TG\"}, \n" +
230 | "{\"name\": \"Tokelau\", \"code\": \"TK\"}, \n" +
231 | "{\"name\": \"Tonga\", \"code\": \"TO\"}, \n" +
232 | "{\"name\": \"Trinidad and Tobago\", \"code\": \"TT\"}, \n" +
233 | "{\"name\": \"Tunisia\", \"code\": \"TN\"}, \n" +
234 | "{\"name\": \"Turkey\", \"code\": \"TR\"}, \n" +
235 | "{\"name\": \"Turkmenistan\", \"code\": \"TM\"}, \n" +
236 | "{\"name\": \"Turks and Caicos Islands\", \"code\": \"TC\"}, \n" +
237 | "{\"name\": \"Tuvalu\", \"code\": \"TV\"}, \n" +
238 | "{\"name\": \"Uganda\", \"code\": \"UG\"}, \n" +
239 | "{\"name\": \"Ukraine\", \"code\": \"UA\"}, \n" +
240 | "{\"name\": \"United Arab Emirates\", \"code\": \"AE\"}, \n" +
241 | "{\"name\": \"United Kingdom\", \"code\": \"GB\"}, \n" +
242 | "{\"name\": \"United States\", \"code\": \"US\"}, \n" +
243 | "{\"name\": \"United States Minor Outlying Islands\", \"code\": \"UM\"}, \n" +
244 | "{\"name\": \"Uruguay\", \"code\": \"UY\"}, \n" +
245 | "{\"name\": \"Uzbekistan\", \"code\": \"UZ\"}, \n" +
246 | "{\"name\": \"Vanuatu\", \"code\": \"VU\"}, \n" +
247 | "{\"name\": \"Venezuela\", \"code\": \"VE\"}, \n" +
248 | "{\"name\": \"Viet Nam\", \"code\": \"VN\"}, \n" +
249 | "{\"name\": \"Virgin Islands, British\", \"code\": \"VG\"}, \n" +
250 | "{\"name\": \"Virgin Islands, U.S.\", \"code\": \"VI\"}, \n" +
251 | "{\"name\": \"Wallis and Futuna\", \"code\": \"WF\"}, \n" +
252 | "{\"name\": \"Western Sahara\", \"code\": \"EH\"}, \n" +
253 | "{\"name\": \"Yemen\", \"code\": \"YE\"}, \n" +
254 | "{\"name\": \"Zambia\", \"code\": \"ZM\"}, \n" +
255 | "{\"name\": \"Zimbabwe\", \"code\": \"ZW\"} \n" +
256 | "]";
257 | }
258 |
--------------------------------------------------------------------------------