mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 12:44:38 +00:00
Fix styling issues when covering mentions.
This commit is contained in:
@@ -12,10 +12,14 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.spoiler.SpoilerAnnotation;
|
||||
import org.thoughtcrime.securesms.util.ContextUtil;
|
||||
import org.thoughtcrime.securesms.util.DrawableUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Encapsulates the logic for determining the type of mention rendering needed (single vs multi-line) and then
|
||||
* passing that information to the appropriate {@link MentionRenderer}.
|
||||
@@ -57,6 +61,12 @@ public class MentionRendererDelegate {
|
||||
if (MentionAnnotation.isMentionAnnotation(annotation)) {
|
||||
int spanStart = text.getSpanStart(annotation);
|
||||
int spanEnd = text.getSpanEnd(annotation);
|
||||
|
||||
List<Annotation> spoilerAnnotations = SpoilerAnnotation.getSpoilerAnnotations(text, spanStart, spanEnd, true);
|
||||
if (Util.hasItems(spoilerAnnotations)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int startLine = layout.getLineForOffset(spanStart);
|
||||
int endLine = layout.getLineForOffset(spanEnd);
|
||||
|
||||
|
||||
@@ -45,10 +45,11 @@ object SpoilerAnnotation {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSpoilerAnnotations(spanned: Spanned, start: Int, end: Int): List<Annotation> {
|
||||
@JvmOverloads
|
||||
fun getSpoilerAnnotations(spanned: Spanned, start: Int, end: Int, unrevealedOnly: Boolean = false): List<Annotation> {
|
||||
return spanned
|
||||
.getSpans(start, end, Annotation::class.java)
|
||||
.filter { isSpoilerAnnotation(it) }
|
||||
.filter { isSpoilerAnnotation(it) && !(unrevealedOnly && revealedSpoilers.contains(it.value)) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.color.ViewColorSet
|
||||
import org.thoughtcrime.securesms.conversation.ConversationMessage
|
||||
import org.thoughtcrime.securesms.conversation.MessageStyler
|
||||
import org.thoughtcrime.securesms.conversation.mutiselect.Multiselect
|
||||
import org.thoughtcrime.securesms.conversation.mutiselect.MultiselectPart
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
@@ -117,7 +118,6 @@ data class MultiselectForwardFragmentArgs @JvmOverloads constructor(
|
||||
.withMentions(conversationMessage.mentions)
|
||||
.withTimestamp(conversationMessage.messageRecord.timestamp)
|
||||
.withExpiration(conversationMessage.messageRecord.expireStarted + conversationMessage.messageRecord.expiresIn)
|
||||
.withBodyRanges(conversationMessage.messageRecord.messageRanges)
|
||||
|
||||
if (conversationMessage.multiselectCollection.isTextSelected(selectedParts)) {
|
||||
val mediaMessage: MmsMessageRecord? = conversationMessage.messageRecord as? MmsMessageRecord
|
||||
@@ -126,10 +126,14 @@ data class MultiselectForwardFragmentArgs @JvmOverloads constructor(
|
||||
PartAuthority.getAttachmentStream(context, textSlideUri).use {
|
||||
val body = StreamUtil.readFullyAsString(it)
|
||||
val msg = ConversationMessage.ConversationMessageFactory.createWithUnresolvedData(context, mediaMessage, body, conversationMessage.threadRecipient)
|
||||
builder.withDraftText(msg.getDisplayBody(context).toString())
|
||||
val displayText = msg.getDisplayBody(context)
|
||||
builder.withDraftText(displayText.toString())
|
||||
.withBodyRanges(MessageStyler.getStyling(displayText))
|
||||
}
|
||||
} else {
|
||||
builder.withDraftText(conversationMessage.getDisplayBody(context).toString())
|
||||
val displayText = conversationMessage.getDisplayBody(context)
|
||||
builder.withDraftText(displayText.toString())
|
||||
.withBodyRanges(MessageStyler.getStyling(displayText))
|
||||
}
|
||||
|
||||
val linkPreview = mediaMessage?.linkPreviews?.firstOrNull()
|
||||
|
||||
Reference in New Issue
Block a user