Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: enofeb/Socially
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.5
Choose a base ref
...
head repository: enofeb/Socially
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dev
Choose a head ref
  • 14 commits
  • 10 files changed
  • 1 contributor

Commits on Sep 24, 2021

  1. remove application to deploy

    enofeb committed Sep 24, 2021
    Copy the full SHA
    5a3909c View commit details
  2. deploy settings were changed

    enofeb committed Sep 24, 2021
    Copy the full SHA
    7a2eace View commit details

Commits on Sep 25, 2021

  1. Read me was updated

    enofeb committed Sep 25, 2021
    Copy the full SHA
    ec7a9c6 View commit details

Commits on Sep 27, 2021

  1. Demo gif was added

    enofeb committed Sep 27, 2021
    Copy the full SHA
    8a5faa6 View commit details
  2. Sample activity was updated

    enofeb committed Sep 27, 2021
    Copy the full SHA
    a31e214 View commit details
  3. demo gif was updated

    enofeb committed Sep 27, 2021
    Copy the full SHA
    23b6d34 View commit details

Commits on Nov 11, 2021

  1. Copy the full SHA
    881e055 View commit details
  2. Read me was updated

    enofeb committed Nov 11, 2021
    Copy the full SHA
    8d12fd9 View commit details
  3. Read me was updated

    enofeb committed Nov 11, 2021
    Copy the full SHA
    898dc76 View commit details
  4. Read me version was updated

    enofeb committed Nov 11, 2021
    Copy the full SHA
    0604d46 View commit details
  5. Read me version was updated

    Read me was updated
    
    Read me was updated
    enofeb committed Nov 11, 2021
    Copy the full SHA
    073a7cb View commit details
  6. Copy the full SHA
    ce2a3dc View commit details

Commits on Dec 5, 2021

  1. Start index was updated

    enofeb committed Dec 5, 2021
    Copy the full SHA
    1401773 View commit details
  2. Read me was updated

    enofeb committed Dec 5, 2021
    Copy the full SHA
    c5e2837 View commit details
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ Socially
===============
[![](https://jitpack.io/v/enofeb/Socially.svg)](https://jitpack.io/#enofeb/Socially)
<a href="http://developer.android.com/index.html" target="_blank"><img src="https://img.shields.io/badge/platform-android-green.svg"/></a>
<a href="https://android-arsenal.com/api?level=15" target="_blank"><img src="https://img.shields.io/badge/API-21%2B-green.svg?style=flat"/></a>
<a href="https://android-arsenal.com/api?level=15" target="_blank"><img src="https://img.shields.io/badge/API-19%2B-green.svg?style=flat"/></a>
<a href="http://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat"/></a>

Socially is a textView which is able to create separate clickable views according to your requirements.
@@ -14,24 +14,23 @@ Socially is a textView which is able to create separate clickable views accordin
</p>

# Simple Usage

1) Add SocialTextView to your xml.
```kotlin
<com.enofeb.socially.view.SocialTextView
android:id="@+id/socialTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am #Spider @Enes99 +905512026461 eneszor95@gmail.com https://www.facebook.com/"
app:hashTagColor="@color/colorGreen"
app:mailColor="@color/colorOrange"
app:mentionColor="@color/colorBlue"
app:phoneNumberColor="@color/colorOrange"
app:webLinkColor="@color/colorRed" />
```

2) Add your rules.
```kotlin
socialTextView.addRules(
Rule.Hashtag,
Rule.Mention
Rule.Mention,
Rule.PhoneNumber,
Rule.Mail,
Rule.WebLink,
@@ -42,6 +41,12 @@ socialTextView.addRules(
)
)
```
3) And, finally set your text.
```kotlin
socialTextView.socialText = "I am #Spider @Enes99 +905512026461 eneszor95@gmail.com https://www.lichess.org"
```

NOTES: Please get follow these three steps while setting up this library.

## Features
* It already supports hashtag, mention, phone number, mail and weblinks. To enable them , you need to add rule which you want to use.
@@ -100,7 +105,7 @@ allprojects {
* Add Socially to your module dependencies.
```groovy
dependencies {
implementation 'com.github.enofeb:Socially:1.0'
implementation 'com.github.enofeb:Socially:1.0.9'
}
```

2 changes: 2 additions & 0 deletions app/src/main/java/com/example/socially/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@ class MainActivity : AppCompatActivity() {
)
)

socialTextView.socialText = "I am #Spider @Enes99 +905512026461 eneszor95@gmail.com https://www.lichess.org"


socialTextView.onTextClickListener = { word, rule ->
when (rule) {
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="I am #Spider @Enes99 +905512026461 eneszor95@gmail.com https://www.facebook.com/"
app:hashTagColor="@color/colorGreen"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
14 changes: 14 additions & 0 deletions socially/build.gradle
Original file line number Diff line number Diff line change
@@ -43,4 +43,18 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

groupId = 'com.enofeb.socially'
artifactId = 'social_text'
version = '1.0.9'
}
}
}
}
4 changes: 1 addition & 3 deletions socially/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.enofeb.socially">

</manifest>
package="com.enofeb.socially"/>
18 changes: 13 additions & 5 deletions socially/src/main/java/com/enofeb/socially/view/SocialTextView.kt
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ class SocialTextView @JvmOverloads constructor(

private val ruleList: MutableList<Rule> = mutableListOf()

private val spannableString = SpannableString(this.text)
private lateinit var spannableString: SpannableString

@ColorInt
private var _hashTagColor = Color.BLUE
@@ -41,7 +41,14 @@ class SocialTextView @JvmOverloads constructor(
@ColorInt
private var _webLinkColor = Color.BLUE

private var startIndexOfLink = -1
private var startIndexOfLink = 0

var socialText: CharSequence?
get() = this.text
set(value) {
this.text = value
start()
}

var hashTagColor: Int
@ColorInt get() = _hashTagColor
@@ -121,12 +128,14 @@ class SocialTextView @JvmOverloads constructor(
}

private fun start() {

spannableString = SpannableString(this.text)

val words = this.text.split("\\s+".toRegex()).map { word ->
word.replace("""^[,\.]|[,\.]$""".toRegex(), "")
}

words.forEach { word ->
startIndexOfLink = this.text.toString().indexOf(word, startIndexOfLink + 1)
startIndexOfLink = this.text.toString().indexOf(word)
checkRuleAndSpan(word)
}

@@ -197,6 +206,5 @@ class SocialTextView @JvmOverloads constructor(

fun addRules(vararg rules: Rule) {
ruleList.addAll(rules)
start()
}
}