Add placeholder for text post thumbs.

This commit is contained in:
Alex Hart 2022-03-25 09:14:12 -03:00 committed by Greyson Parrelli
parent 5faa497821
commit 2549c1f97d
2 changed files with 13 additions and 0 deletions

View file

@ -399,6 +399,7 @@ public class ThumbnailView extends FrameLayout {
GlideRequest request = glideRequests.load(model)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.placeholder(model.getPlaceholder())
.transition(withCrossFade());
if (width > 0 && height > 0) {

View file

@ -1,6 +1,9 @@
package org.thoughtcrime.securesms.stories
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.view.View
import androidx.core.graphics.scale
import androidx.core.view.drawToBitmap
@ -9,6 +12,7 @@ import com.bumptech.glide.load.Options
import com.bumptech.glide.load.ResourceDecoder
import com.bumptech.glide.load.engine.Resource
import com.bumptech.glide.load.resource.SimpleResource
import org.thoughtcrime.securesms.conversation.colors.ChatColors
import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
@ -36,6 +40,14 @@ data class StoryTextPostModel(
val text: String = storyTextPost.body
fun getPlaceholder(): Drawable {
return if (storyTextPost.hasBackground()) {
ChatColors.forChatColor(ChatColors.Id.NotSet, storyTextPost.background).chatBubbleMask
} else {
ColorDrawable(Color.TRANSPARENT)
}
}
companion object {
fun parseFrom(messageRecord: MessageRecord): StoryTextPostModel {