Fix rendering when editing a message with spoilers.

This commit is contained in:
Cody Henthorne
2023-06-21 13:08:00 -04:00
parent 1d0a87f52a
commit 15035f4eb3
2 changed files with 18 additions and 0 deletions

View File

@@ -261,6 +261,22 @@ object MessageStyler {
}
}
@JvmStatic
fun convertSpoilersToComposeMode(text: Spannable) {
SpoilerAnnotation.getSpoilerAndClickAnnotations(text)
.forEach { (spoiler, clickSpan) ->
val start = text.getSpanStart(spoiler)
val end = text.getSpanEnd(spoiler)
val convertedSpoiler = copyStyleSpan(spoiler, start, end - start)
text.removeSpan(spoiler)
text.setSpan(convertedSpoiler, start, end, SPAN_FLAGS)
if (clickSpan != null) {
text.removeSpan(clickSpan)
}
}
}
fun Any.isSupportedStyle(): Boolean {
return when (this) {
is CharacterStyle -> isSupportedCharacterStyle()