From 0e41fa767f197ac4a628de187c03dbea856122e5 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 21 Sep 2023 09:12:39 +0200 Subject: [PATCH] Load emoji by default --- .../java/eu/faircode/email/ApplicationEx.java | 21 ++++++------- .../email/FragmentOptionsPrivacy.java | 2 +- app/src/main/java/eu/faircode/email/Log.java | 30 +++++++++++++++++++ 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 3b8d9cd977..79341b258b 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -175,7 +175,7 @@ public class ApplicationEx extends Application SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final boolean crash_reports = prefs.getBoolean("crash_reports", false); final boolean leak_canary = prefs.getBoolean("leak_canary", false); - final boolean load_emoji = prefs.getBoolean("load_emoji", false); + final boolean load_emoji = prefs.getBoolean("load_emoji", true); prev = Thread.getDefaultUncaughtExceptionHandler(); @@ -225,16 +225,17 @@ public class ApplicationEx extends Application // https://issuetracker.google.com/issues/233525229 Log.i("Load emoji=" + load_emoji); - if (!load_emoji) - try { - FontRequestEmojiCompatConfig crying = DefaultEmojiCompatConfig.create(this); - if (crying != null) { - crying.setMetadataLoadStrategy(EmojiCompat.LOAD_STRATEGY_MANUAL); - EmojiCompat.init(crying); - } - } catch (Throwable ex) { - Log.e(ex); + try { + FontRequestEmojiCompatConfig crying = DefaultEmojiCompatConfig.create(this); + if (crying != null) { + crying.setMetadataLoadStrategy(EmojiCompat.LOAD_STRATEGY_MANUAL); + EmojiCompat.init(crying); + if (load_emoji) + EmojiCompat.get().load(); } + } catch (Throwable ex) { + Log.e(ex); + } EmailProvider.init(this); EncryptionHelper.init(this); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java index 3876c77ff7..b3741642dd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java @@ -646,7 +646,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer tvGenericUserAgent.setText(WebViewEx.getUserAgent(getContext())); swGenericUserAgent.setChecked(prefs.getBoolean("generic_ua", false)); swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", false)); - swLoadEmoji.setChecked(prefs.getBoolean("load_emoji", false)); + swLoadEmoji.setChecked(prefs.getBoolean("load_emoji", true)); long time = prefs.getLong("disconnect_last", -1); DateFormat DF = SimpleDateFormat.getDateTimeInstance(); diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index e2977f1c3d..083962165a 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -96,6 +96,7 @@ import androidx.annotation.RequiresApi; import androidx.appcompat.app.AlertDialog; import androidx.browser.customtabs.CustomTabsClient; import androidx.browser.customtabs.CustomTabsServiceConnection; +import androidx.emoji2.text.EmojiCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.preference.PreferenceManager; @@ -2096,6 +2097,35 @@ public class Log { String charset = MimeUtility.getDefaultJavaCharset(); sb.append(String.format("Default charset: %s/%s\r\n", charset, MimeUtility.mimeCharset(charset))); + String emoji; + try { + if (EmojiCompat.isConfigured()) { + int emojiState = EmojiCompat.get().getLoadState(); + switch (emojiState) { + case EmojiCompat.LOAD_STATE_LOADING: + emoji = "Loading"; + break; + case EmojiCompat.LOAD_STATE_SUCCEEDED: + emoji = "Loaded"; + break; + case EmojiCompat.LOAD_STATE_FAILED: + emoji = "Failed"; + break; + case EmojiCompat.LOAD_STATE_DEFAULT: + emoji = "Not loaded"; + break; + default: + emoji = "?" + emojiState; + } + } else + emoji = "Disabled"; + } catch (Throwable ex) { + Log.e(ex); + emoji = ex.toString(); + } + + sb.append("Emoji: ").append(emoji).append("\r\n"); + sb.append("Transliterate: ") .append(TextHelper.canTransliterate()) .append("\r\n");