Fix styling issues when covering mentions.

This commit is contained in:
Cody Henthorne
2023-06-06 11:35:05 -04:00
parent 71aa17bad6
commit eae066b3a2
3 changed files with 20 additions and 5 deletions

View File

@@ -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);

View File

@@ -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