Use emoji2 library

This commit is contained in:
Benoit Marty 2021-12-13 12:36:46 +01:00
parent b701bb7c1a
commit df3f8bd88e
4 changed files with 8 additions and 5 deletions

View File

@ -449,7 +449,7 @@ dependencies {
// OSS License, gplay flavor only // OSS License, gplay flavor only
gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation "androidx.emoji:emoji-appcompat:1.1.0" implementation "androidx.emoji2:emoji2:1.0.0"
implementation('com.github.BillCarsonFr:JsonViewer:0.7') implementation('com.github.BillCarsonFr:JsonViewer:0.7')
// WebRTC // WebRTC

View File

@ -398,6 +398,9 @@
android:name="androidx.work.WorkManagerInitializer" android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup" android:value="androidx.startup"
tools:node="remove" /> tools:node="remove" />
<!-- We init the lib ourself in EmojiCompatWrapper -->
<meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
tools:node="remove" />
</provider> </provider>
<provider <provider

View File

@ -17,8 +17,8 @@ package im.vector.app
import android.content.Context import android.content.Context
import androidx.core.provider.FontRequest import androidx.core.provider.FontRequest
import androidx.emoji.text.EmojiCompat import androidx.emoji2.text.EmojiCompat
import androidx.emoji.text.FontRequestEmojiCompatConfig import androidx.emoji2.text.FontRequestEmojiCompatConfig
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -52,7 +52,7 @@ class EmojiCompatWrapper @Inject constructor(private val context: Context) {
fun safeEmojiSpanify(sequence: CharSequence): CharSequence { fun safeEmojiSpanify(sequence: CharSequence): CharSequence {
if (initialized) { if (initialized) {
try { try {
return EmojiCompat.get().process(sequence) return EmojiCompat.get().process(sequence) ?: sequence
} catch (throwable: Throwable) { } catch (throwable: Throwable) {
// Defensive coding against error (should not happend as it is initialized) // Defensive coding against error (should not happend as it is initialized)
Timber.e(throwable, "Failed to init EmojiCompat") Timber.e(throwable, "Failed to init EmojiCompat")

View File

@ -21,7 +21,7 @@ import android.text.Spanned
import android.text.style.MetricAffectingSpan import android.text.style.MetricAffectingSpan
import android.text.style.StrikethroughSpan import android.text.style.StrikethroughSpan
import android.text.style.UnderlineSpan import android.text.style.UnderlineSpan
import androidx.emoji.text.EmojiCompat import androidx.emoji2.text.EmojiCompat
import javax.inject.Inject import javax.inject.Inject
class SpanUtils @Inject constructor() { class SpanUtils @Inject constructor() {