don't load custom emojis in their full size (#4429)

This should save quite some memory, but most importantly it gets rid of
this crash:

```
java.lang.RuntimeException: Canvas: trying to draw too large(121969936bytes) bitmap.
           at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:266)
           at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:94)
           at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:549)
           at com.keylesspalace.tusky.util.EmojiSpan.draw(CustomEmojiHelper.kt:131)
           ...
```
This commit is contained in:
Konrad Pozniak 2024-05-10 12:22:07 +02:00 committed by GitHub
commit 4dec228926
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 28 additions and 14 deletions

View file

@ -16,7 +16,7 @@
package com.keylesspalace.tusky.adapter
import android.graphics.Typeface
import android.text.SpannableStringBuilder
import android.text.SpannableString
import android.text.Spanned
import android.text.style.StyleSpan
import androidx.recyclerview.widget.RecyclerView
@ -67,7 +67,7 @@ class FollowRequestViewHolder(
val wrappedName = account.name.unicodeWrap()
val emojifiedName: CharSequence = wrappedName.emojify(
account.emojis,
itemView,
binding.displayNameTextView,
animateEmojis
)
binding.displayNameTextView.text = emojifiedName
@ -76,9 +76,9 @@ class FollowRequestViewHolder(
R.string.notification_follow_request_format,
wrappedName
)
binding.notificationTextView.text = SpannableStringBuilder(wholeMessage).apply {
binding.notificationTextView.text = SpannableString(wholeMessage).apply {
setSpan(StyleSpan(Typeface.BOLD), 0, wrappedName.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}.emojify(account.emojis, itemView, animateEmojis)
}.emojify(account.emojis, binding.notificationTextView, animateEmojis)
}
binding.notificationTextView.visible(showHeader)
val formattedUsername = itemView.context.getString(