diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/PbContentRender.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/PbContentRender.kt index dd546ff2..691a22a3 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/PbContentRender.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/PbContentRender.kt @@ -302,9 +302,9 @@ fun PbContentText( awaitEachGesture { val change = awaitFirstDown() val annotation = - layoutResult.value?.getOffsetForPosition(change.position)?.let { - text.getStringAnnotations(start = it, end = it) - .firstOrNull() + layoutResult.value?.getOffsetForPosition(change.position)?.let { offset -> + text.getStringAnnotations(start = offset, end = offset) + .firstOrNull { it.tag == "url" || it.tag == "user" } } if (annotation != null) { if (change.pressed != change.previousPressed) change.consume() diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonUtil.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonUtil.kt index e056a6a1..731e0bc5 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonUtil.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonUtil.kt @@ -146,6 +146,7 @@ object EmoticonUtil { } } + @OptIn(ExperimentalTextApi::class) val AnnotatedString.emoticonString: AnnotatedString get() { if (hasStringAnnotations("Emoticon", 0, length)) { @@ -154,7 +155,9 @@ object EmoticonUtil { val regexPattern = Pattern.compile(getRegex(EMOTICON_ALL_TYPE)) val matcher = regexPattern.matcher(this.text) return buildAnnotatedString { - append(this@emoticonString) + withAnnotation("Emoticon", "true") { + append(this@emoticonString) + } while (matcher.find()) { val start = matcher.start() val end = matcher.end()