initialize emoji compat in application

(cherry picked from commit fcd6f7c18ac67a0dfc6dc6fab77e7e63cea4e75e)
This commit is contained in:
Daniel Gultsch 2024-09-21 13:08:15 +02:00 committed by Arne
parent 52801eeda7
commit 66746e0e1e
3 changed files with 21 additions and 5 deletions

View file

@ -1,14 +1,31 @@
package eu.siacs.conversations.services; package eu.siacs.conversations.services;
import android.content.Context; import android.content.Context;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.emoji2.bundled.BundledEmojiCompatConfig; import androidx.emoji2.bundled.BundledEmojiCompatConfig;
import androidx.emoji2.text.EmojiCompat; import androidx.emoji2.text.EmojiCompat;
import eu.siacs.conversations.Config;
public class EmojiInitializationService { public class EmojiInitializationService {
public static void execute(final Context context) { 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);
}
});
}
} }

View file

@ -11,6 +11,7 @@ import androidx.appcompat.app.AppCompatDelegate;
import com.google.android.material.color.DynamicColors; import com.google.android.material.color.DynamicColors;
import com.google.android.material.color.DynamicColorsOptions; import com.google.android.material.color.DynamicColorsOptions;
import eu.siacs.conversations.services.EmojiInitializationService;
import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.ThemeHelper; import eu.siacs.conversations.utils.ThemeHelper;
@ -27,6 +28,7 @@ public class Conversations extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
CONTEXT = this.getApplicationContext(); CONTEXT = this.getApplicationContext();
EmojiInitializationService.execute(getApplicationContext());
ExceptionHelper.init(getApplicationContext()); ExceptionHelper.init(getApplicationContext());
applyThemeSettings(); applyThemeSettings();
} }

View file

@ -19,7 +19,6 @@ import android.content.ServiceConnection;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point; import android.graphics.Point;
@ -86,7 +85,6 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.services.BarcodeProvider; import eu.siacs.conversations.services.BarcodeProvider;
import eu.siacs.conversations.services.EmojiInitializationService;
import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.QuickConversationsService;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder; import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
@ -513,7 +511,6 @@ public abstract class XmppActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
metrics = getResources().getDisplayMetrics(); metrics = getResources().getDisplayMetrics();
EmojiInitializationService.execute(this);
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY); this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
this.mCustomColors = ThemeHelper.applyCustomColors(this); this.mCustomColors = ThemeHelper.applyCustomColors(this);
} }