fix link parsing
This commit is contained in:
parent
58b668e09a
commit
af63fc8990
|
@ -60,7 +60,7 @@ fun parseHTMLText(
|
||||||
// Convert text to spannable
|
// Convert text to spannable
|
||||||
val content = fromHtml(text)
|
val content = fromHtml(text)
|
||||||
|
|
||||||
//Retrive all links that should be made clickable
|
// Retrieve all links that should be made clickable
|
||||||
val builder = SpannableStringBuilder(content)
|
val builder = SpannableStringBuilder(content)
|
||||||
val urlSpans = content.getSpans(0, content.length, URLSpan::class.java)
|
val urlSpans = content.getSpans(0, content.length, URLSpan::class.java)
|
||||||
|
|
||||||
|
@ -78,12 +78,13 @@ fun parseHTMLText(
|
||||||
override fun onClick(widget: View) {
|
override fun onClick(widget: View) {
|
||||||
openTag(context, tag)
|
openTag(context, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
builder.removeSpan(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle mentions
|
// Handle mentions
|
||||||
if(text[0] == '@' && !mentions.isNullOrEmpty()) {
|
else if(text[0] == '@') {
|
||||||
|
if (!mentions.isNullOrEmpty()){
|
||||||
val accountUsername = text.subSequence(1, text.length).toString()
|
val accountUsername = text.subSequence(1, text.length).toString()
|
||||||
var id: String? = null
|
var id: String? = null
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ fun parseHTMLText(
|
||||||
val accountId: String = id
|
val accountId: String = id
|
||||||
customSpan = object : ClickableSpanNoUnderline() {
|
customSpan = object : ClickableSpanNoUnderline() {
|
||||||
override fun onClick(widget: View) {
|
override fun onClick(widget: View) {
|
||||||
Log.e("MENTION", "CLICKED")
|
|
||||||
// Retrieve the account for the given profile
|
// Retrieve the account for the given profile
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||||
|
@ -115,8 +116,10 @@ fun parseHTMLText(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.removeSpan(span)
|
builder.removeSpan(span)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
builder.setSpan(customSpan, start, end, flags)
|
builder.setSpan(customSpan, start, end, flags)
|
||||||
|
|
||||||
// Add zero-width space after links in end of line to fix its too large hitbox.
|
// Add zero-width space after links in end of line to fix its too large hitbox.
|
||||||
|
|
Loading…
Reference in New Issue