From 6e646b12b5520c355bb5bd8f468fd485937315b1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 13 Dec 2021 20:34:44 +0100 Subject: [PATCH] Add some comments and default values --- .../home/room/detail/timeline/item/BindingOptions.kt | 6 ++++-- .../main/java/im/vector/app/features/html/SpanUtils.kt | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BindingOptions.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BindingOptions.kt index 317b8423a8..e50f141af1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BindingOptions.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/BindingOptions.kt @@ -17,6 +17,8 @@ package im.vector.app.features.home.room.detail.timeline.item data class BindingOptions( - val canUseTextFuture: Boolean, - val preventMutation: Boolean + // Allowed by default + val canUseTextFuture: Boolean = true, + // No need to prevent mutation by default + val preventMutation: Boolean = false ) diff --git a/vector/src/main/java/im/vector/app/features/html/SpanUtils.kt b/vector/src/main/java/im/vector/app/features/html/SpanUtils.kt index 175e595b37..27c966e33e 100644 --- a/vector/src/main/java/im/vector/app/features/html/SpanUtils.kt +++ b/vector/src/main/java/im/vector/app/features/html/SpanUtils.kt @@ -30,15 +30,12 @@ class SpanUtils @Inject constructor() { val emojiCharSequence = EmojiCompat.get().process(charSequence) if (emojiCharSequence !is Spanned) { - return BindingOptions( - canUseTextFuture = true, - preventMutation = false - ) + return BindingOptions() } return BindingOptions( canUseTextFuture = canUseTextFuture(emojiCharSequence), - preventMutation = preventMutation(emojiCharSequence) + preventMutation = mustPreventMutation(emojiCharSequence) ) } @@ -55,7 +52,7 @@ class SpanUtils @Inject constructor() { } // Workaround for setting text during binding which mutate the text itself - private fun preventMutation(spanned: Spanned): Boolean { + private fun mustPreventMutation(spanned: Spanned): Boolean { return spanned .getSpans(0, spanned.length, Any::class.java) .any { it is MetricAffectingSpan }