Optionally load emoji

pull/194/merge
M66B 3 years ago
parent a7d9e68a97
commit afb8ecf287

@ -293,6 +293,7 @@ dependencies {
def core_version = "1.6.0" // 1.7.0
def shortcuts_version = "1.0.0"
def appcompat_version = "1.3.1"
def emoji_version = "1.0.0-beta01"
def activity_version = "1.4.0"
def fragment_version = "1.4.0-beta01"
def webkit_version = "1.4.0"
@ -350,9 +351,11 @@ dependencies {
implementation "androidx.core:core-google-shortcuts:$shortcuts_version"
// https://mvnrepository.com/artifact/androidx.appcompat/appcompat
// https://mvnrepository.com/artifact/androidx.emoji2/emoji2
// https://mvnrepository.com/artifact/androidx.activity/activity
// https://mvnrepository.com/artifact/androidx.fragment/fragment
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.emoji2:emoji2:$emoji_version"
implementation "androidx.activity:activity:$activity_version"
implementation "androidx.fragment:fragment:$fragment_version"

@ -39,6 +39,9 @@ import android.webkit.CookieManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.emoji2.text.DefaultEmojiCompatConfig;
import androidx.emoji2.text.EmojiCompat;
import androidx.emoji2.text.FontRequestEmojiCompatConfig;
import androidx.preference.PreferenceManager;
import androidx.work.WorkManager;
@ -147,6 +150,7 @@ public class ApplicationEx extends Application
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
final boolean crash_reports = prefs.getBoolean("crash_reports", false);
final boolean load_emoji = prefs.getBoolean("load_emoji", BuildConfig.PLAY_STORE_RELEASE);
prev = Thread.getDefaultUncaughtExceptionHandler();
@ -190,6 +194,18 @@ public class ApplicationEx extends Application
if (Helper.hasWebView(this))
CookieManager.getInstance().setAcceptCookie(false);
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);
}
EncryptionHelper.init(this);
MessageHelper.setSystemProperties(this);
@ -244,6 +260,7 @@ public class ApplicationEx extends Application
ServiceSynchronize.scheduleWatchdog(this);
break;
case "secure": // privacy
case "load_emoji": // privacy
case "shortcuts": // misc
case "language": // misc
case "wal": // misc

@ -83,6 +83,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private TextView tvGenericUserAgent;
private SwitchCompat swSafeBrowsing;
private ImageButton ibSafeBrowsing;
private SwitchCompat swLoadEmoji;
private ImageButton ibDisconnectBlacklist;
private Button btnDisconnectBlacklist;
private TextView tvDisconnectBlacklistTime;
@ -98,7 +99,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
"disable_tracking", "hide_timezone",
"pin", "biometrics", "biometrics_timeout", "autolock",
"client_id", "display_hidden", "incognito_keyboard", "secure",
"generic_ua", "safe_browsing",
"generic_ua", "safe_browsing", "load_emoji",
"disconnect_auto_update", "disconnect_links", "disconnect_images"
};
@ -136,6 +137,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
tvGenericUserAgent = view.findViewById(R.id.tvGenericUserAgent);
swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing);
ibSafeBrowsing = view.findViewById(R.id.ibSafeBrowsing);
swLoadEmoji = view.findViewById(R.id.swLoadEmoji);
ibDisconnectBlacklist = view.findViewById(R.id.ibDisconnectBlacklist);
btnDisconnectBlacklist = view.findViewById(R.id.btnDisconnectBlacklist);
tvDisconnectBlacklistTime = view.findViewById(R.id.tvDisconnectBlacklistTime);
@ -344,6 +346,13 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
grpSafeBrowsing.setEnabled(WebViewEx.isFeatureSupported(WebViewFeature.SAFE_BROWSING_ENABLE));
swLoadEmoji.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("load_emoji", checked).commit(); // apply won't work here
}
});
ibDisconnectBlacklist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -488,6 +497,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
tvGenericUserAgent.setText(WebViewEx.getUserAgent(getContext()));
swGenericUserAgent.setChecked(prefs.getBoolean("generic_ua", true));
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", false));
swLoadEmoji.setChecked(prefs.getBoolean("load_emoji", BuildConfig.PLAY_STORE_RELEASE));
long time = prefs.getLong("disconnect_last", -1);
DateFormat DF = SimpleDateFormat.getDateTimeInstance();

@ -489,6 +489,29 @@
app:layout_constraintTop_toBottomOf="@id/tvSafeBrowsingHint"
app:srcCompat="@drawable/twotone_info_24" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLoadEmoji"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_load_emoji"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSafeBrowsing"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvLoadEmojiHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_english_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLoadEmoji" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvDisconnectBlacklist"
android:layout_width="0dp"
@ -501,7 +524,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSafeBrowsing" />
app:layout_constraintTop_toBottomOf="@id/tvLoadEmojiHint" />
<ImageButton
android:id="@+id/ibDisconnectBlacklist"

@ -603,6 +603,7 @@
<string name="title_advanced_autolock">Lock on screen off</string>
<string name="title_advanced_generic_user_agent">Use generic browser user agent</string>
<string name="title_advanced_safe_browsing" translatable="false">Google Safe browsing (Android 8+)</string>
<string name="title_advanced_load_emoji">Load updated Emoji from Google Play Services</string>
<string name="title_advanced_disconnect_blacklist" translatable="false">Disconnect\'s tracker protection lists</string>
<string name="title_advanced_disconnect_auto_update">Automatically update lists weekly</string>
<string name="title_advanced_disconnect_links">Use lists to warn about tracking links</string>

Loading…
Cancel
Save