mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:05:28 +00:00
Also linkify emails.
This commit is contained in:
committed by
Benoit Marty
parent
d800b225b6
commit
ff2fc7ff3a
+2
-2
@@ -230,7 +230,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||||||
Pair(start, end)
|
Pair(start, end)
|
||||||
}
|
}
|
||||||
// Find and set as URLSpans any links present in the text
|
// Find and set as URLSpans any links present in the text
|
||||||
LinkifyCompat.addLinks(this, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
|
LinkifyCompat.addLinks(this, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
|
||||||
// Restore old spans if they don't conflict with the new ones
|
// Restore old spans if they don't conflict with the new ones
|
||||||
for ((urlSpan, location) in oldURLSpans) {
|
for ((urlSpan, location) in oldURLSpans) {
|
||||||
val (start, end) = location
|
val (start, end) = location
|
||||||
@@ -244,6 +244,6 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||||||
|
|
||||||
private fun String.withLinks(): CharSequence? {
|
private fun String.withLinks(): CharSequence? {
|
||||||
val spannable = toSpannable()
|
val spannable = toSpannable()
|
||||||
val addedLinks = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
|
val addedLinks = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
|
||||||
return spannable.takeIf { addedLinks }
|
return spannable.takeIf { addedLinks }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ fun ClickableLinkText(
|
|||||||
fun AnnotatedString.linkify(linkStyle: SpanStyle): AnnotatedString {
|
fun AnnotatedString.linkify(linkStyle: SpanStyle): AnnotatedString {
|
||||||
val original = this
|
val original = this
|
||||||
val spannable = SpannableString(this.text)
|
val spannable = SpannableString(this.text)
|
||||||
LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
|
LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
|
||||||
|
|
||||||
val spans = spannable.getSpans(0, spannable.length, URLSpan::class.java)
|
val spans = spannable.getSpans(0, spannable.length, URLSpan::class.java)
|
||||||
return buildAnnotatedString {
|
return buildAnnotatedString {
|
||||||
|
|||||||
Reference in New Issue
Block a user