Load emoji by default

This commit is contained in:
M66B 2023-09-21 09:12:39 +02:00
parent 199c5d8b14
commit 0e41fa767f
3 changed files with 42 additions and 11 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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");