From a2cc622683073862f8842ceb9ed764d32ccf2a47 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Tue, 3 May 2022 19:15:59 +0200 Subject: [PATCH] fix EmojiCompat.get().process crash in polls (#2494) --- .../com/keylesspalace/tusky/adapter/PollAdapter.kt | 10 +++------- .../tusky/components/account/AccountActivity.kt | 10 +--------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt index 9ffeca9e..ef366795 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt @@ -19,7 +19,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat -import androidx.emoji2.text.EmojiCompat import androidx.recyclerview.widget.RecyclerView import com.keylesspalace.tusky.R import com.keylesspalace.tusky.databinding.ItemPollBinding @@ -87,9 +86,8 @@ class PollAdapter : RecyclerView.Adapter>() { when (mode) { RESULT -> { val percent = calculatePercent(option.votesCount, votersCount, voteCount) - val emojifiedPollOptionText = buildDescription(option.title, percent, option.voted, resultTextView.context) + resultTextView.text = buildDescription(option.title, percent, option.voted, resultTextView.context) .emojify(emojis, resultTextView, animateEmojis) - resultTextView.text = EmojiCompat.get().process(emojifiedPollOptionText) val level = percent * 100 val optionColor = if (option.voted) { @@ -103,8 +101,7 @@ class PollAdapter : RecyclerView.Adapter>() { resultTextView.setOnClickListener(resultClickListener) } SINGLE -> { - val emojifiedPollOptionText = option.title.emojify(emojis, radioButton, animateEmojis) - radioButton.text = EmojiCompat.get().process(emojifiedPollOptionText) + radioButton.text = option.title.emojify(emojis, radioButton, animateEmojis) radioButton.isChecked = option.selected radioButton.setOnClickListener { pollOptions.forEachIndexed { index, pollOption -> @@ -114,8 +111,7 @@ class PollAdapter : RecyclerView.Adapter>() { } } MULTIPLE -> { - val emojifiedPollOptionText = option.title.emojify(emojis, checkBox, animateEmojis) - checkBox.text = EmojiCompat.get().process(emojifiedPollOptionText) + checkBox.text = option.title.emojify(emojis, checkBox, animateEmojis) checkBox.isChecked = option.selected checkBox.setOnCheckedChangeListener { _, isChecked -> pollOptions[holder.bindingAdapterPosition].selected = isChecked diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt index cc8719bb..6a8bc7dc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt @@ -37,7 +37,6 @@ import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat.Type.systemBars import androidx.core.view.updatePadding -import androidx.emoji2.text.EmojiCompat import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.viewpager2.widget.MarginPageTransformer @@ -459,14 +458,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI */ private fun updateToolbar() { loadedAccount?.let { account -> - - val emojifiedName = account.name.emojify(account.emojis, binding.accountToolbar, animateEmojis) - - try { - supportActionBar?.title = EmojiCompat.get().process(emojifiedName) - } catch (e: IllegalStateException) { - supportActionBar?.title = emojifiedName - } + supportActionBar?.title = account.name.emojify(account.emojis, binding.accountToolbar, animateEmojis) supportActionBar?.subtitle = String.format(getString(R.string.post_username_format), account.username) } }