From 030a201da622f30f4e03d97d64cdf0ef58e4bc1d Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 1 Jul 2018 10:18:00 +0200 Subject: [PATCH] disable emoji fonts on Android 5 (#698) --- app/build.gradle | 2 +- .../main/java/com/keylesspalace/tusky/AccountActivity.kt | 7 ++++++- .../keylesspalace/tusky/fragment/PreferencesFragment.java | 7 +++++++ app/src/main/res/xml/preferences.xml | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3c10d64e6..012b2b50f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ dependencies { // EmojiCompat implementation "com.android.support:support-emoji:$supportLibraryVersion" implementation "com.android.support:support-emoji-appcompat:$supportLibraryVersion" - implementation "de.c1710:filemojicompat:1.0.5" + implementation "de.c1710:filemojicompat:1.0.9" // architecture components implementation 'android.arch.lifecycle:extensions:1.1.1' //room diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt index 24edd1736..be1c5353d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.kt @@ -299,7 +299,12 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportF accountUsernameTextView.text = usernameFormatted accountDisplayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, accountDisplayNameTextView) if (supportActionBar != null) { - supportActionBar?.title = EmojiCompat.get().process(account.name) + try { + supportActionBar?.title = EmojiCompat.get().process(account.name) + } catch (e: IllegalStateException) { + // some Android versions seem to have problems with custom emoji fonts + supportActionBar?.title = account.name + } val subtitle = String.format(getString(R.string.status_username_format), account.username) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/PreferencesFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/PreferencesFragment.java index e36d7cb61..46ce25508 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/PreferencesFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/PreferencesFragment.java @@ -23,6 +23,7 @@ import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; +import android.preference.PreferenceCategory; import android.preference.PreferenceFragment; import android.support.annotation.XmlRes; import android.text.Editable; @@ -67,6 +68,12 @@ public class PreferencesFragment extends PreferenceFragment implements SharedPre addPreferencesFromResource(preference); + Preference emojiPreference = findPreference("emojiCompat"); + if(emojiPreference != null && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) { + //disable emoji fonts on Android 5 because they cause problems + ((PreferenceCategory)findPreference("categoryAppearance")).removePreference(emojiPreference); + } + Preference regexPref = findPreference("tabFilterRegex"); if (regexPref != null) regexPref.setOnPreferenceClickListener(pref -> { // Reset the error dialog when shown; if the dialog was closed with the cancel button diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 1dd472b85..e4d721599 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -2,7 +2,8 @@ - +