├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── io
│ │ └── github
│ │ └── armcha
│ │ ├── MainActivity.kt
│ │ ├── RecyclerViewActivity.kt
│ │ └── StaticTextActivity.kt
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── github_circle.xml
│ └── ic_launcher_background.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_recycler_view.xml
│ ├── activity_static_text.xml
│ └── recycler_item.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── autolinklibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── io
│ │ └── github
│ │ └── armcha
│ │ └── autolink
│ │ ├── AutoLinkItem.kt
│ │ ├── AutoLinkTextView.kt
│ │ ├── LinkTouchMovementMethod.kt
│ │ ├── Mode.kt
│ │ ├── Regex.kt
│ │ └── TouchableSpan.kt
│ └── res
│ └── values
│ └── colors.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screens
├── AutoLinkTextView.apk
├── custom.png
├── gmail.png
├── hashtag.png
├── mention.png
├── phone.png
├── recycler.png
├── recycler_gif.gif
├── static.png
├── static_gif.gif
├── transformation_after.png
├── transformation_before.png
└── url.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .DS_Store
5 | /build
6 | /captures
7 | .externalNativeBuild
8 | /.idea/
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AutoLinkTextView V2
2 |
3 | [1]: https://github.com/armcha/AutoLinkTextView
4 | AutoLinkTextViewV2 is the new version of the [AutoLinkTextView][1].
5 |
6 | **The main differences between the old and new version are**
7 | - Fully migration to Kotlin
8 | - Added several new features
9 | - Some improvements and fixes
10 |
11 | **It supports automatic detection and click handling for**
12 | * Hashtags (#)
13 | * Mentions (@)
14 | * URLs (https://)
15 | * Phone Numbers
16 | * Emails
17 | * Multiple Custom Regex
18 |
19 | .
20 |
21 |
22 | The current minSDK version is API level 16.
23 |
24 | ### Download sample [apk][77]
25 | [77]: https://github.com/armcha/AutoLinkTextViewV2/blob/master/screens/AutoLinkTextView.apk
26 |
27 | ### Features
28 |
29 | * Default support for **Hashtag, Mention, Link, Phone number and Email**
30 | * Support for **custom types** via regex
31 | * Transform url to short clickable text
32 | * Ability to apply **multiple spans** to any mode
33 | * Ability to set specific text color
34 | * Ability to set pressed state color
35 |
36 | -----------------------
37 |
38 | ### Download
39 |
40 | Gradle:
41 | ```groovy
42 | implementation 'com.github.armcha:AutoLinkTextViewV2:3.0.0'
43 | ```
44 |
45 | ### Setup and Usage
46 |
47 | Add AutoLinkTextView to your layout
48 | ```xml
49 |
53 | ```
54 |
55 | ```kotlin
56 | val autoLinkTextView = findViewById(R.id.autolinkTextView);
57 | ```
58 |
59 | Add one or multiple modes
60 | ```kotlin
61 | autoLinkTextView.addAutoLinkMode(
62 | MODE_HASHTAG,
63 | MODE_URL)
64 | ```
65 | -----------------------
66 | Add url transformations for transforming them to short clickable text
67 | ```kotlin
68 | autoLinkTextView.addUrlTransformations(
69 | "https://google.com" to "Google",
70 | "https://en.wikipedia.org/wiki/Wear_OS" to "Wear OS")
71 | ```
72 |
73 | Or you can attach urlProcessor and transform it
74 | ```kotlin
75 | autoLinkTextView.attachUrlProcessor { originalUrl: String ->
76 | when {
77 | originalUrl.startsWith("https://en.wikipedia") -> "Wiki"
78 | originalUrl.contains("android") -> "Android"
79 | else -> originalUrl
80 | }
81 | }
82 | ```
83 |
84 |
85 | -----------------------
86 | Add one or multiple spans to specific mode
87 | ```kotlin
88 | autoLinkTextView.addSpan(MODE_URL, StyleSpan(Typeface.ITALIC), UnderlineSpan())
89 | autoLinkTextView.addSpan(MODE_HASHTAG, UnderlineSpan(), TypefaceSpan("monospace"))
90 | ```
91 | -----------------------
92 | Set AutoLinkTextView click listener
93 | ```kotlin
94 | autoLinkTextView.onAutoLinkClick { item: AutoLinkItem ->
95 | }
96 | ```
97 | -----------------------
98 | Set text to AutoLinkTextView
99 | ```kotlin
100 | autoLinkTextView.text = getString(R.string.android_text)
101 | ```
102 |
103 |
104 | Customizing
105 | ---------
106 |
107 | All possible modes
108 |
109 | #### MODE_PHONE
110 |
111 |
112 |
113 | #### MODE_HASHTAG
114 |
115 |
116 |
117 | #### MODE_URL
118 |
119 |
120 |
121 | #### MODE_MENTION
122 |
123 |
124 |
125 | #### MODE_EMAIL
126 |
127 |
128 |
129 | #### MODE_CUSTOM
130 |
131 |
132 |
133 | For use of custom mode you can add multiple custom regex
134 |
135 | ```kotlin
136 | val custom = MODE_CUSTOM("\\sAndroid\\b", "\\sGoogle\\b")
137 | ```
138 | -------------------------
139 | You can change text color for the specific mode
140 | ```kotlin
141 | autoLinkTextView.hashTagModeColor = ContextCompat.getColor(this, R.color.color2)
142 | autoLinkTextView.phoneModeColor = ContextCompat.getColor(this, R.color.color3)
143 | ```
144 | -------------------------
145 | You can also change pressed text color
146 | ```kotlin
147 | autoLinkTextView.pressedTextColor = ContextCompat.getColor(this, R.color.pressedTextColor)
148 | ```
149 |
150 | ### Contact :book:
151 |
152 | :arrow_forward: **Email**: chatikyana@gmail.com
153 |
154 | :arrow_forward: **LinkedIn**: https://www.linkedin.com/in/chatikyan
155 |
156 | :arrow_forward: **Medium**: https://medium.com/@chatikyan
157 |
158 | :arrow_forward: **Twitter**: https://twitter.com/ChatikyanArman
159 |
160 | License
161 | --------
162 |
163 |
164 | Auto Link TextView V2 library for Android
165 | Copyright (c) 2021 Arman Chatikyan (https://github.com/armcha/AutoLinkTextViewV2).
166 |
167 | Licensed under the Apache License, Version 2.0 (the "License");
168 | you may not use this file except in compliance with the License.
169 | You may obtain a copy of the License at
170 |
171 | http://www.apache.org/licenses/LICENSE-2.0
172 |
173 | Unless required by applicable law or agreed to in writing, software
174 | distributed under the License is distributed on an "AS IS" BASIS,
175 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
176 | See the License for the specific language governing permissions and
177 | limitations under the License.
178 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.2"
8 |
9 | defaultConfig {
10 | applicationId "io.github.armcha"
11 | minSdkVersion 16
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 |
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
29 | androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | implementation 'androidx.appcompat:appcompat:1.1.0'
33 | implementation project(':autolinklibrary')
34 | testImplementation 'junit:junit:4.12'
35 | implementation 'androidx.core:core-ktx:+'
36 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
37 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
38 | implementation 'androidx.cardview:cardview:1.0.0'
39 | }
40 | repositories {
41 | mavenCentral()
42 | }
43 |
--------------------------------------------------------------------------------
/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\Chatikyan\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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/armcha/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.net.Uri
6 | import android.os.Bundle
7 | import androidx.appcompat.app.AlertDialog
8 | import androidx.appcompat.app.AppCompatActivity
9 | import kotlinx.android.synthetic.main.activity_main.*
10 |
11 |
12 | class MainActivity : AppCompatActivity() {
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContentView(R.layout.activity_main)
17 |
18 | staticTextButton.setOnClickListener {
19 | startActivity(Intent(this, StaticTextActivity::class.java))
20 | }
21 | recyclerViewButton.setOnClickListener {
22 | startActivity(Intent(this, RecyclerViewActivity::class.java))
23 | }
24 | githubIcon.setOnClickListener {
25 | browse("https://github.com/armcha/AutoLinkTextViewV2")
26 | }
27 | }
28 | }
29 |
30 | fun Context.showDialog(title: String, message: String, url: String? = null) {
31 | val builder = AlertDialog.Builder(this)
32 | .setMessage(message)
33 | .setTitle(title)
34 | .setPositiveButton("OK") { dialog, _ -> dialog.dismiss() }
35 | if (url != null) {
36 | builder.setNegativeButton("Browse") { dialog, _ -> browse(url);dialog.dismiss() }
37 | }
38 | builder.create().show()
39 | }
40 |
41 | fun Context.browse(url: String) {
42 | val intent = Intent(Intent.ACTION_VIEW)
43 | intent.data = Uri.parse(url)
44 | startActivity(intent)
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/armcha/RecyclerViewActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha
2 |
3 | import android.graphics.Color
4 | import android.graphics.Typeface
5 | import android.os.Bundle
6 | import android.text.style.BackgroundColorSpan
7 | import android.text.style.ForegroundColorSpan
8 | import android.text.style.StyleSpan
9 | import android.text.style.UnderlineSpan
10 | import android.view.ViewGroup
11 | import android.widget.Toast
12 | import androidx.appcompat.app.AppCompatActivity
13 | import androidx.core.content.ContextCompat
14 | import androidx.recyclerview.widget.RecyclerView
15 | import io.github.armcha.autolink.*
16 | import kotlinx.android.synthetic.main.activity_recycler_view.*
17 | import kotlinx.android.synthetic.main.recycler_item.view.*
18 |
19 |
20 | class RecyclerViewActivity : AppCompatActivity() {
21 |
22 | override fun onCreate(savedInstanceState: Bundle?) {
23 | super.onCreate(savedInstanceState)
24 | setContentView(R.layout.activity_recycler_view)
25 |
26 | recyclerView.adapter = object : RecyclerView.Adapter() {
27 |
28 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
29 | val view = layoutInflater.inflate(R.layout.recycler_item, parent, false)
30 | return object : RecyclerView.ViewHolder(view) {}
31 | }
32 |
33 | override fun getItemCount() = 200
34 |
35 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
36 |
37 | val autoLinkTextView = holder.itemView.autoLinkTextView
38 | val context = holder.itemView.context
39 | val custom = MODE_CUSTOM("\\sAndroid\\b")
40 |
41 | autoLinkTextView.addAutoLinkMode(
42 | MODE_HASHTAG,
43 | MODE_URL,
44 | MODE_PHONE,
45 | MODE_EMAIL,
46 | custom,
47 | MODE_MENTION)
48 |
49 | autoLinkTextView.addUrlTransformations(
50 | "https://google.com" to "Google",
51 | "https://en.wikipedia.org/wiki/Cyberpunk_2077" to "Cyberpunk",
52 | "https://en.wikipedia.org/wiki/Fire_OS" to "FIRE",
53 | "https://en.wikipedia.org/wiki/Wear_OS" to "Wear OS")
54 |
55 | autoLinkTextView.addSpan(MODE_URL, StyleSpan(Typeface.BOLD_ITALIC), UnderlineSpan())
56 | autoLinkTextView.addSpan(custom, StyleSpan(Typeface.BOLD))
57 | autoLinkTextView.addSpan(MODE_HASHTAG, BackgroundColorSpan(Color.GRAY), UnderlineSpan(), ForegroundColorSpan(Color.WHITE))
58 |
59 | autoLinkTextView.hashTagModeColor = ContextCompat.getColor(context, R.color.color2)
60 | autoLinkTextView.customModeColor = ContextCompat.getColor(context, R.color.color1)
61 | autoLinkTextView.mentionModeColor = ContextCompat.getColor(context, R.color.color3)
62 | autoLinkTextView.emailModeColor = ContextCompat.getColor(context, R.color.colorPrimary)
63 | autoLinkTextView.phoneModeColor = ContextCompat.getColor(context, R.color.colorAccent)
64 |
65 | val text = when {
66 | position % 3 == 1 -> R.string.android_text_short
67 | position % 3 == 2 -> R.string.android_text_short_second
68 | else -> R.string.text_third
69 | }
70 |
71 | autoLinkTextView.text = getString(text)
72 |
73 | autoLinkTextView.onAutoLinkClick {
74 | val message = if (it.originalText == it.transformedText) it.originalText
75 | else "Original text - ${it.originalText} \n\nTransformed text - ${it.transformedText}"
76 | val url = if (it.mode is MODE_URL) it.originalText else null
77 | showDialog(it.mode.modeName, message, url)
78 | }
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/armcha/StaticTextActivity.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha
2 |
3 | import android.graphics.Typeface
4 | import android.os.Bundle
5 | import android.text.style.StyleSpan
6 | import android.text.style.TypefaceSpan
7 | import android.text.style.UnderlineSpan
8 | import androidx.appcompat.app.AppCompatActivity
9 | import androidx.core.content.ContextCompat
10 | import io.github.armcha.autolink.*
11 | import kotlinx.android.synthetic.main.activity_static_text.*
12 |
13 | class StaticTextActivity : AppCompatActivity() {
14 |
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | setContentView(R.layout.activity_static_text)
18 |
19 | val custom = MODE_CUSTOM("\\sAndroid\\b", "\\smobile\\b")
20 | autoLinkTextView.addAutoLinkMode(
21 | MODE_HASHTAG,
22 | MODE_EMAIL,
23 | MODE_URL,
24 | MODE_PHONE,
25 | custom,
26 | MODE_MENTION)
27 |
28 | autoLinkTextView.addUrlTransformations(
29 | "https://en.wikipedia.org/wiki/Wear_OS" to "Wear OS",
30 | "https://en.wikipedia.org/wiki/Fire_OS" to "FIRE")
31 |
32 | autoLinkTextView.attachUrlProcessor {
33 | when {
34 | it.contains("google") -> "Google"
35 | it.contains("github") -> "Github"
36 | else -> it
37 | }
38 | }
39 |
40 | autoLinkTextView.addSpan(MODE_URL, StyleSpan(Typeface.ITALIC), UnderlineSpan())
41 | autoLinkTextView.addSpan(MODE_HASHTAG, UnderlineSpan(), TypefaceSpan("monospace"))
42 | autoLinkTextView.addSpan(custom, StyleSpan(Typeface.BOLD))
43 |
44 | autoLinkTextView.hashTagModeColor = ContextCompat.getColor(this, R.color.color5)
45 | autoLinkTextView.phoneModeColor = ContextCompat.getColor(this, R.color.color3)
46 | autoLinkTextView.customModeColor = ContextCompat.getColor(this, R.color.color1)
47 | autoLinkTextView.mentionModeColor = ContextCompat.getColor(this, R.color.color6)
48 | autoLinkTextView.emailModeColor = ContextCompat.getColor(this, R.color.colorPrimary)
49 |
50 | autoLinkTextView.text = getString(R.string.android_text)
51 |
52 | autoLinkTextView.onAutoLinkClick {
53 | val message = if (it.originalText == it.transformedText) it.originalText
54 | else "Original text - ${it.originalText} \n\nTransformed text - ${it.transformedText}"
55 | val url = if (it.mode is MODE_URL) it.originalText else null
56 | showDialog(it.mode.modeName, message, url)
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/github_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
28 |
29 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_static_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #FF4081
6 | #3DDC84
7 | #C2185B
8 | #ffa000
9 | #4285F4
10 | #FFDF00
11 | #33FFFFFF
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AutoLinkTextView
3 | Android is a mobile operating system developed by https://google.com.
4 | It is based on a modified version of the @Linux kernel and other open source software,
5 | and is designed @primarily for touchscreen mobile devices such as smartphones and #tablets.
6 | In addition, https://githttps://github.com/armcha/AutoLinkTextViewV2.github.com/armcha/AutoLinkTextViewV2 has developed Android TV for televisions, Android Auto for cars
7 | and https://en.wikipedia.org/wiki/Wear_OS for wearables, each with a specialized user #interface.
8 | Variants of Android are also used on game consoles, digital cameras, PCs and other #electronics.
9 | Android is also associated with a suite of proprietary software developed by Google,
10 | called Google Mobile Services (GMS) https://www.android.com/gms, that frequently comes pre-installed on devices.
11 | This includes core apps such as Gmail chatikyana@gmail.com ,
12 | the application store/digital +37493023017 distribution platform Google @Play and associated Google Play Services development platform,
13 | and usually includes the Google #Chrome web browser and Google @Search app.
14 | These apps are licensed by manufacturers of Android devices certified under standards imposed by Google,
15 | but AOSP has been used as the basis of competing Android ecosystems such as Amazons https://en.wikipedia.org/wiki/Fire_OS OS,
16 | which use 801-691-7894 their own equivalents to Google Mobile Services.
17 |
18 |
19 | Android is a mobile operating system developed by https://google.com.
20 | It is based on a modified version of the @Linux kernel and other open source software,
21 | and is designed @primarily for touchscreen mobile devices such as smartphones and #tablets.
22 | \n\n In addition, https://google.com has developed Android TV for televisions, Android Auto for cars
23 | and https://en.wikipedia.org/wiki/Wear_OS for wearables, each with a specialized user #interface.
24 | Variants of Android are also used on game consoles, digital cameras, PCs and other #electronics.
25 | Android is also associated with a suite of proprietary software developed by Google,
26 | called Google @Mobile Services (GMS),that frequently comes pre-installed on devices.
27 | This includes core apps such as Gmail chatikyana@gmail.com.
28 |
29 |
30 | The application store/digital +37493023017 distribution
31 | platform Google @Play and associated Google Play Services development platform,
32 | and usually includes the Google #Chrome web browser and Google @Search app.
33 | These apps are licensed by manufacturers of Android devices certified under standards sample@android.com imposed by Google,
34 | but AOSP has been used as the basis of competing Android ecosystems such as Amazons https://en.wikipedia.org/wiki/Fire_OS OS,
35 | which use 801-691-7894 their own equivalents to Google Mobile Services.
36 |
37 |
38 | #Cyberpunk 2077 is a 2020 action role-playing video game developed and published by CD Projekt.
39 | The story takes place in Night City, an open world set in the Cyberpunk https://en.wikipedia.org/wiki/Cyberpunk_2077 universe.
40 | Players assume the first-person perspective of a customisable mercenary known as V,
41 | who can acquire skills in hacking and machinery with options for melee and ranged combat.
42 | The game was developed using the #REDengine 4 by a team of around 500 people,
43 | exceeding the number that worked on the studios previous game The Witcher 3: Wild Hunt (2015).
44 | CD Projekt launched a new division in @Wrocław, @Poland, and partnered with Digital Scapes, Nvidia,
45 | QLOC, and Jali Research to aid the production chatikyana@gmail.com. #Cyberpunk creator Mike Pondsmith was a consultant,
46 | and actor Keanu Reeves has a starring role. The original score was led by Marcin Przybyłowicz,
47 | featuring the contributions of several licensed artists.
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/autolinklibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/autolinklibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android-extensions'
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'com.github.panpf.bintray-publish'
5 |
6 | android {
7 | compileSdkVersion 30
8 | buildToolsVersion "29.0.3"
9 |
10 | defaultConfig {
11 | minSdkVersion 16
12 | targetSdkVersion 30
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 | buildTypes {
17 | release {
18 | tasks.withType(Javadoc).all { enabled = false }
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation 'androidx.core:core-ktx:1.3.2'
28 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
29 | }
30 | repositories {
31 | mavenCentral()
32 | }
33 |
34 | publish {
35 | userOrg = 'armcha'
36 | groupId = 'com.github.armcha'
37 | artifactId = 'AutoLinkTextViewV2'
38 | publishVersion = '3.0.0'
39 | desc = 'AutoLinkTextViewV2'
40 | website = 'https://github.com/armcha/AutoLinkTextViewV2'
41 | }
42 |
--------------------------------------------------------------------------------
/autolinklibrary/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\Chatikyan\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 |
--------------------------------------------------------------------------------
/autolinklibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/autolinklibrary/src/main/java/io/github/armcha/autolink/AutoLinkItem.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha.autolink
2 |
3 | data class AutoLinkItem(var startPoint: Int,
4 | var endPoint: Int,
5 | val originalText: String,
6 | val transformedText: String,
7 | val mode: Mode)
8 |
--------------------------------------------------------------------------------
/autolinklibrary/src/main/java/io/github/armcha/autolink/AutoLinkTextView.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha.autolink
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.graphics.Typeface
6 | import android.graphics.Typeface.BOLD
7 | import android.os.Handler
8 | import android.text.DynamicLayout
9 | import android.text.SpannableString
10 | import android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
11 | import android.text.Spanned.SPAN_INCLUSIVE_INCLUSIVE
12 | import android.text.StaticLayout
13 | import android.text.style.CharacterStyle
14 | import android.text.style.ClickableSpan
15 | import android.text.style.StyleSpan
16 | import android.util.AttributeSet
17 | import android.util.Log
18 | import android.view.View
19 | import android.widget.TextView
20 | import java.lang.reflect.Field
21 |
22 | class AutoLinkTextView(context: Context, attrs: AttributeSet? = null) : TextView(context, attrs) {
23 |
24 | companion object {
25 | internal val TAG = AutoLinkTextView::class.java.simpleName
26 | private const val MIN_PHONE_NUMBER_LENGTH = 7
27 | private const val MAX_PHONE_NUMBER_LENGTH = 15
28 | private const val DEFAULT_COLOR = Color.RED
29 | }
30 |
31 | private val spanMap = mutableMapOf>()
32 | private val transformations = mutableMapOf()
33 | private val modes = mutableSetOf()
34 | private var onAutoLinkClick: ((AutoLinkItem) -> Unit)? = null
35 | private var urlProcessor: ((String) -> String)? = null
36 |
37 | var pressedTextColor = Color.LTGRAY
38 | var mentionModeColor = DEFAULT_COLOR
39 | var hashTagModeColor = DEFAULT_COLOR
40 | var customModeColor = DEFAULT_COLOR
41 | var phoneModeColor = DEFAULT_COLOR
42 | var emailModeColor = DEFAULT_COLOR
43 | var urlModeColor = DEFAULT_COLOR
44 |
45 | init {
46 | highlightColor = Color.TRANSPARENT
47 | movementMethod = LinkTouchMovementMethod()
48 | }
49 |
50 | override fun setText(text: CharSequence, type: BufferType) {
51 | if (text.isEmpty() || modes.isNullOrEmpty()) {
52 | super.setText(text, type)
53 | return
54 | }
55 | val spannableString = makeSpannableString(text)
56 | super.setText(spannableString, type)
57 | }
58 |
59 | fun addAutoLinkMode(vararg modes: Mode) {
60 | this.modes.addAll(modes)
61 | }
62 |
63 | fun addSpan(mode: Mode, vararg spans: CharacterStyle) {
64 | spanMap[mode] = spans.toHashSet()
65 | }
66 |
67 | fun onAutoLinkClick(body: (AutoLinkItem) -> Unit) {
68 | onAutoLinkClick = body
69 | }
70 |
71 | fun addUrlTransformations(vararg pairs: Pair) {
72 | transformations.putAll(pairs.toMap())
73 | }
74 |
75 | fun attachUrlProcessor(processor: (String) -> String) {
76 | urlProcessor = processor
77 | }
78 |
79 | private fun makeSpannableString(text: CharSequence): SpannableString {
80 |
81 | val autoLinkItems = matchedRanges(text)
82 | val transformedText = transformLinks(text, autoLinkItems)
83 | val spannableString = SpannableString(transformedText)
84 |
85 | for (autoLinkItem in autoLinkItems) {
86 | val mode = autoLinkItem.mode
87 | val currentColor = getColorByMode(mode)
88 |
89 | val clickableSpan = object : TouchableSpan(currentColor, pressedTextColor) {
90 | override fun onClick(widget: View) {
91 | onAutoLinkClick?.invoke(autoLinkItem)
92 | }
93 | }
94 |
95 | spannableString.addSpan(clickableSpan, autoLinkItem)
96 | spanMap[mode]?.forEach {
97 | spannableString.addSpan(CharacterStyle.wrap(it), autoLinkItem)
98 | }
99 | }
100 |
101 | return spannableString
102 | }
103 |
104 | private fun transformLinks(text: CharSequence, autoLinkItems: List): String {
105 | if (transformations.isEmpty())
106 | return text.toString()
107 |
108 | val stringBuilder = StringBuilder(text)
109 | var shift = 0
110 |
111 | autoLinkItems
112 | .sortedBy { it.startPoint }
113 | .forEach {
114 | if (it.mode is MODE_URL && it.originalText != it.transformedText) {
115 | val originalTextLength = it.originalText.length
116 | val transformedTextLength = it.transformedText.length
117 | val diff = originalTextLength - transformedTextLength
118 | shift += diff
119 | it.startPoint = it.startPoint - shift + diff
120 | it.endPoint = it.startPoint + transformedTextLength
121 | stringBuilder.replace(it.startPoint, it.startPoint + originalTextLength, it.transformedText)
122 | } else if (shift > 0) {
123 | it.startPoint = it.startPoint - shift
124 | it.endPoint = it.startPoint + it.originalText.length
125 | }
126 | }
127 | return stringBuilder.toString()
128 | }
129 |
130 | private fun matchedRanges(text: CharSequence): List {
131 | val autoLinkItems = mutableListOf()
132 | modes.forEach {
133 | val patterns = it.toPattern()
134 | patterns.forEach { pattern ->
135 | val matcher = pattern.matcher(text)
136 | while (matcher.find()) {
137 | var group = matcher.group()
138 | var startPoint = matcher.start()
139 | val endPoint = matcher.end()
140 | when (it) {
141 | is MODE_PHONE -> {
142 | val digits = group.replace("[^0-9]".toRegex(), "")
143 | if (digits.length in MIN_PHONE_NUMBER_LENGTH..MAX_PHONE_NUMBER_LENGTH) {
144 | val item = AutoLinkItem(startPoint, endPoint, group, group, it)
145 | autoLinkItems.add(item)
146 | }
147 | }
148 | else -> {
149 | val isUrl = it is MODE_URL
150 | if (isUrl) {
151 | if (startPoint > 0) {
152 | startPoint += 1
153 | }
154 | group = group.trimStart()
155 | if (urlProcessor != null) {
156 | val transformedUrl = urlProcessor?.invoke(group) ?: group
157 | if (transformedUrl != group)
158 | transformations[group] = transformedUrl
159 | }
160 | }
161 | val matchedText = if (isUrl && transformations.containsKey(group)) {
162 | transformations[group] ?: group
163 | } else {
164 | group
165 | }
166 | val item = AutoLinkItem(startPoint, endPoint, group,
167 | transformedText = matchedText, mode = it)
168 | autoLinkItems.add(item)
169 | }
170 | }
171 | }
172 | }
173 | }
174 | return autoLinkItems
175 | }
176 |
177 | private fun SpannableString.addSpan(span: Any, autoLinkItem: AutoLinkItem) {
178 | setSpan(span, autoLinkItem.startPoint, autoLinkItem.endPoint, SPAN_EXCLUSIVE_EXCLUSIVE)
179 | }
180 |
181 | private fun getColorByMode(mode: Mode): Int {
182 | return when (mode) {
183 | is MODE_HASHTAG -> hashTagModeColor
184 | is MODE_MENTION -> mentionModeColor
185 | is MODE_URL -> urlModeColor
186 | is MODE_PHONE -> phoneModeColor
187 | is MODE_EMAIL -> emailModeColor
188 | is MODE_CUSTOM -> customModeColor
189 | }
190 | }
191 |
192 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
193 | var field: Field? = null
194 | val staticField = DynamicLayout::class.java.getDeclaredField("sStaticLayout")
195 | staticField.isAccessible = true
196 | val layout: StaticLayout? = staticField.get(DynamicLayout::class.java) as? StaticLayout?
197 | if (layout != null) {
198 | field = StaticLayout::class.java.getDeclaredField("mMaximumVisibleLineCount")
199 | field.isAccessible = true
200 | field.setInt(layout, maxLines)
201 | }
202 | super.onMeasure(widthMeasureSpec, heightMeasureSpec)
203 | if (layout != null && field != null) {
204 | field.setInt(layout, Integer.MAX_VALUE)
205 | }
206 | }
207 | }
208 |
--------------------------------------------------------------------------------
/autolinklibrary/src/main/java/io/github/armcha/autolink/LinkTouchMovementMethod.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha.autolink
2 |
3 | import android.text.Selection
4 | import android.text.Spannable
5 | import android.text.method.LinkMovementMethod
6 | import android.view.MotionEvent
7 | import android.widget.TextView
8 |
9 | internal class LinkTouchMovementMethod : LinkMovementMethod() {
10 |
11 | private var pressedSpan: TouchableSpan? = null
12 |
13 | override fun onTouchEvent(textView: TextView, spannable: Spannable, event: MotionEvent): Boolean {
14 | when (event.action) {
15 | MotionEvent.ACTION_DOWN -> {
16 | pressedSpan = getPressedSpan(textView, spannable, event)
17 | if (pressedSpan != null) {
18 | pressedSpan?.isPressed = true
19 | Selection.setSelection(spannable, spannable.getSpanStart(pressedSpan),
20 | spannable.getSpanEnd(pressedSpan))
21 | }
22 | }
23 | MotionEvent.ACTION_MOVE -> {
24 | val touchedSpan = getPressedSpan(textView, spannable, event)
25 | if (pressedSpan != null && touchedSpan != pressedSpan) {
26 | pressedSpan?.isPressed = false
27 | pressedSpan = null
28 | Selection.removeSelection(spannable)
29 | }
30 | }
31 | else -> {
32 | if (pressedSpan != null) {
33 | pressedSpan?.isPressed = false
34 | super.onTouchEvent(textView, spannable, event)
35 | }
36 | pressedSpan = null
37 | Selection.removeSelection(spannable)
38 | }
39 | }
40 | return true
41 | }
42 |
43 | private fun getPressedSpan(textView: TextView, spannable: Spannable, event: MotionEvent): TouchableSpan? {
44 |
45 | var x = event.x.toInt()
46 | var y = event.y.toInt()
47 |
48 | x -= textView.totalPaddingLeft
49 | y -= textView.totalPaddingTop
50 |
51 | x += textView.scrollX
52 | y += textView.scrollY
53 |
54 | val layout = textView.layout
55 | val verticalLine = layout.getLineForVertical(y)
56 | val horizontalOffset = layout.getOffsetForHorizontal(verticalLine, x.toFloat())
57 |
58 | val link = spannable.getSpans(horizontalOffset, horizontalOffset, TouchableSpan::class.java)
59 | return link.getOrNull(0)
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/autolinklibrary/src/main/java/io/github/armcha/autolink/Mode.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha.autolink
2 |
3 | import android.util.Log
4 | import java.util.regex.Pattern
5 |
6 | sealed class Mode(val modeName: String)
7 |
8 | object MODE_HASHTAG : Mode("Hashtag")
9 | object MODE_MENTION : Mode("Mention")
10 | object MODE_URL : Mode("Url")
11 | object MODE_PHONE : Mode("Phone")
12 | object MODE_EMAIL : Mode("Email")
13 | class MODE_CUSTOM(vararg val regex: String) : Mode("Custom")
14 |
15 | fun Mode.toPattern(): List {
16 | return when (this) {
17 | is MODE_HASHTAG -> listOf(HASH_TAG_PATTERN)
18 | is MODE_MENTION -> listOf(MENTION_PATTERN)
19 | is MODE_PHONE -> listOf(PHONE_PATTERN)
20 | is MODE_EMAIL -> listOf(EMAIL_PATTERN)
21 | is MODE_URL -> listOf(URL_PATTERN)
22 | is MODE_CUSTOM -> {
23 | regex.map {
24 | if (it.length > 2) {
25 | Pattern.compile(it)
26 | } else {
27 | Log.w(AutoLinkTextView.TAG, "Your custom regex is null, returning URL_PATTERN")
28 | URL_PATTERN
29 | }
30 | }
31 | }
32 | }
33 | }
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/autolinklibrary/src/main/java/io/github/armcha/autolink/Regex.kt:
--------------------------------------------------------------------------------
1 | package io.github.armcha.autolink
2 |
3 | import android.util.Patterns
4 | import java.util.regex.Pattern
5 |
6 | internal val URL_PATTERN = Pattern.compile("(^|[\\s.:;?\\-\\]<\\(])" +
7 | "((https?://|www\\.|pic\\.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?)" +
8 | "(?=$|[\\s',\\|\\(\\).:;?\\-\\[\\]>\\)])")
9 | internal val PHONE_PATTERN: Pattern = Patterns.PHONE
10 | internal val EMAIL_PATTERN: Pattern = Patterns.EMAIL_ADDRESS
11 | internal val MENTION_PATTERN: Pattern = Pattern.compile("(?:^|\\s|$|[.])@[\\p{L}0-9_]*")
12 | internal val HASH_TAG_PATTERN: Pattern = Pattern.compile("(?
2 |
3 | #d50000
4 | #ff5252
5 |
6 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.4.21'
3 | repositories {
4 | jcenter()
5 | google()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:4.1.1'
9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
10 | classpath "com.github.panpf.bintray-publish:bintray-publish:1.0.0"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | google()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
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 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jan 04 00:59:33 AMT 2021
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-6.5-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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/screens/AutoLinkTextView.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/AutoLinkTextView.apk
--------------------------------------------------------------------------------
/screens/custom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/custom.png
--------------------------------------------------------------------------------
/screens/gmail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/gmail.png
--------------------------------------------------------------------------------
/screens/hashtag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/hashtag.png
--------------------------------------------------------------------------------
/screens/mention.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/mention.png
--------------------------------------------------------------------------------
/screens/phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/phone.png
--------------------------------------------------------------------------------
/screens/recycler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/recycler.png
--------------------------------------------------------------------------------
/screens/recycler_gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/recycler_gif.gif
--------------------------------------------------------------------------------
/screens/static.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/static.png
--------------------------------------------------------------------------------
/screens/static_gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/static_gif.gif
--------------------------------------------------------------------------------
/screens/transformation_after.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/transformation_after.png
--------------------------------------------------------------------------------
/screens/transformation_before.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/transformation_before.png
--------------------------------------------------------------------------------
/screens/url.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/armcha/AutoLinkTextViewV2/3e316620fc66e091d45dd8d61ac32a10140ef72d/screens/url.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':autolinklibrary'
2 |
--------------------------------------------------------------------------------