Commit 28ce73af authored by dev-ritik's avatar dev-ritik

Fixes custom emoji alias issue

parent cf7ffd51
...@@ -41,6 +41,7 @@ dependencies { ...@@ -41,6 +41,7 @@ dependencies {
implementation libraries.recyclerview implementation libraries.recyclerview
implementation libraries.material implementation libraries.material
implementation libraries.glide implementation libraries.glide
implementation libraries.timber
kapt libraries.glideProcessor kapt libraries.glideProcessor
implementation libraries.room implementation libraries.room
kapt libraries.roomProcessor kapt libraries.roomProcessor
......
...@@ -7,13 +7,13 @@ import android.text.Spannable ...@@ -7,13 +7,13 @@ import android.text.Spannable
import android.text.SpannableString import android.text.SpannableString
import android.text.Spanned import android.text.Spanned
import android.text.style.ImageSpan import android.text.style.ImageSpan
import android.util.Log
import chat.rocket.android.emoji.internal.GlideApp import chat.rocket.android.emoji.internal.GlideApp
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.gif.GifDrawable import com.bumptech.glide.load.resource.gif.GifDrawable
import kotlinx.coroutines.experimental.CommonPool import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.Deferred import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.experimental.async import kotlinx.coroutines.experimental.async
import timber.log.Timber
class EmojiParser { class EmojiParser {
...@@ -81,7 +81,7 @@ class EmojiParser { ...@@ -81,7 +81,7 @@ class EmojiParser {
return spannable.also { sp -> return spannable.also { sp ->
regex.findAll(spannable).iterator().forEach { match -> regex.findAll(spannable).iterator().forEach { match ->
customEmojis.find { it.shortname.toLowerCase() == match.value.toLowerCase() }?.let { emoji -> customEmojis.find { matchEmoji(it, match.value) }?.let { emoji ->
emoji.url?.let { url -> emoji.url?.let { url ->
try { try {
val glideRequest = if (url.endsWith("gif", true)) { val glideRequest = if (url.endsWith("gif", true)) {
...@@ -107,7 +107,7 @@ class EmojiParser { ...@@ -107,7 +107,7 @@ class EmojiParser {
} }
} }
} catch (ex: Throwable) { } catch (ex: Throwable) {
Log.e("EmojiParser", "", ex) Timber.e( ex)
} }
} }
} }
...@@ -115,6 +115,19 @@ class EmojiParser { ...@@ -115,6 +115,19 @@ class EmojiParser {
} }
} }
private fun matchEmoji(it: Emoji, text: String): Boolean {
if (it.shortname== text) {
return true
} else {
it.shortnameAlternates.forEach {
if (":$it:" == text) {
return true
}
}
return false
}
}
fun parseAsync( fun parseAsync(
context: Context, context: Context,
text: CharSequence, text: CharSequence,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment