From a120242b71372922ad949a56ffabdc8c1413ea31 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 21 Sep 2024 13:08:15 +0200 Subject: [PATCH] initialize emoji compat in application (cherry picked from commit fcd6f7c18ac67a0dfc6dc6fab77e7e63cea4e75e) --- .../services/EmojiInitializationService.java | 21 +++++++++++++++++-- .../eu/siacs/conversations/Conversations.java | 2 ++ .../siacs/conversations/ui/XmppActivity.java | 3 --- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/free/java/eu/siacs/conversations/services/EmojiInitializationService.java b/src/free/java/eu/siacs/conversations/services/EmojiInitializationService.java index 2618d38096..aae5e64094 100644 --- a/src/free/java/eu/siacs/conversations/services/EmojiInitializationService.java +++ b/src/free/java/eu/siacs/conversations/services/EmojiInitializationService.java @@ -1,14 +1,31 @@ package eu.siacs.conversations.services; import android.content.Context; +import android.util.Log; +import androidx.annotation.Nullable; import androidx.emoji2.bundled.BundledEmojiCompatConfig; import androidx.emoji2.text.EmojiCompat; +import eu.siacs.conversations.Config; + public class EmojiInitializationService { public static void execute(final Context context) { - EmojiCompat.init(new BundledEmojiCompatConfig(context).setReplaceAll(true)); - } + EmojiCompat.init(new BundledEmojiCompatConfig(context).setReplaceAll(true)) + .registerInitCallback( + new EmojiCompat.InitCallback() { + @Override + public void onInitialized() { + Log.d(Config.LOGTAG, "initialized EmojiCompat"); + super.onInitialized(); + } + @Override + public void onFailed(@Nullable Throwable throwable) { + Log.e(Config.LOGTAG, "failed to initialize EmojiCompat", throwable); + super.onFailed(throwable); + } + }); + } } diff --git a/src/main/java/eu/siacs/conversations/Conversations.java b/src/main/java/eu/siacs/conversations/Conversations.java index 36d2ea8dd8..f00540f620 100644 --- a/src/main/java/eu/siacs/conversations/Conversations.java +++ b/src/main/java/eu/siacs/conversations/Conversations.java @@ -11,6 +11,7 @@ import androidx.appcompat.app.AppCompatDelegate; import com.google.android.material.color.DynamicColors; import com.google.android.material.color.DynamicColorsOptions; +import eu.siacs.conversations.services.EmojiInitializationService; import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.ThemeHelper; @@ -27,6 +28,7 @@ public class Conversations extends Application { public void onCreate() { super.onCreate(); CONTEXT = this.getApplicationContext(); + EmojiInitializationService.execute(getApplicationContext()); ExceptionHelper.init(getApplicationContext()); applyThemeSettings(); } diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index c86ceb90b8..109a71869b 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -19,7 +19,6 @@ import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Point; @@ -86,7 +85,6 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.BarcodeProvider; -import eu.siacs.conversations.services.EmojiInitializationService; import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder; @@ -513,7 +511,6 @@ public abstract class XmppActivity extends ActionBarActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); metrics = getResources().getDisplayMetrics(); - EmojiInitializationService.execute(this); this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY); this.mCustomColors = ThemeHelper.applyCustomColors(this); }