Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,20 @@ object V2ConversationItemUtils {

messageBody.getSpans(0, messageBody.length, URLSpan::class.java).forEach { urlSpan ->
val start = messageBody.getSpanStart(urlSpan)
val end = messageBody.getSpanEnd(urlSpan)
val span = InterceptableLongClickCopyLinkSpan(urlSpan.url, urlClickHandler)
var end = messageBody.getSpanEnd(urlSpan)
var url = urlSpan.url

while (end < messageBody.length && messageBody[end] == '-') {
val nextCharIndex = end + 1
if (nextCharIndex >= messageBody.length || messageBody[nextCharIndex] == ' ' || messageBody[nextCharIndex] == '\n') {
url += '-'
end++
} else {
break
}
}

val span = InterceptableLongClickCopyLinkSpan(url, urlClickHandler)

messageBody.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
messageBody.removeSpan(urlSpan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ConversationItemTest_linkifyUrlLinks(private val input: String, private va
arrayOf("https://www.google.com%d332", "https://www.google.com"),
// arrayOf("https://www.instagram.com/tv/CfImYdngccQ/?igshid=YmMyMTA2M2Y= ", "https://www.instagram.com/tv/CfImYdngccQ/?igshid=YmMyMTA2M2Y="),
arrayOf("https://www.instagram.com/tv/CfImYdngccQ/?igshid=YmMyMTA2M2Y=\n", "https://www.instagram.com/tv/CfImYdngccQ/?igshid=YmMyMTA2M2Y="),
arrayOf("https://example.com/link- word", "https://example.com/link-"),
arrayOf("https://example.com/link-\nword.", "https://example.com/link-"),
// arrayOf("https://fr.ulule.com/sapins-barbus-la-bd-/ ", "https://fr.ulule.com/sapins-barbus-la-bd-/"),
arrayOf("https://fr.ulule.com/sapins-barbus-la-bd-/\n", "https://fr.ulule.com/sapins-barbus-la-bd-/"),
arrayOf("https://de.m.wikipedia.org/wiki/Red_Dawn_(2012)", "https://de.m.wikipedia.org/wiki/Red_Dawn_(2012)")
Expand Down