mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Comments added to explain why we should check if the url is valid.
This commit is contained in:
parent
6c4e71d7d4
commit
626eb4d06b
1 changed files with 2 additions and 0 deletions
|
@ -60,6 +60,7 @@ fun CharSequence.linkify(callback: TimelineEventController.UrlClickCallback?): C
|
|||
fun createLinkMovementMethod(urlClickCallback: TimelineEventController.UrlClickCallback?): EvenBetterLinkMovementMethod {
|
||||
return EvenBetterLinkMovementMethod(object : EvenBetterLinkMovementMethod.OnLinkClickListener {
|
||||
override fun onLinkClicked(textView: TextView, span: ClickableSpan, url: String, actualText: String): Boolean {
|
||||
// Always return false if the url is not valid, so the EvenBetterLinkMovementMethod can fallback to default click listener.
|
||||
return url.isValidUrl() && urlClickCallback?.onUrlClicked(url, actualText) == true
|
||||
}
|
||||
})
|
||||
|
@ -67,6 +68,7 @@ fun createLinkMovementMethod(urlClickCallback: TimelineEventController.UrlClickC
|
|||
// We need also to fix the case when long click on link will trigger long click on cell
|
||||
setOnLinkLongClickListener { tv, url ->
|
||||
// Long clicks are handled by parent, return true to block android to do something with url
|
||||
// Always return false if the url is not valid, so the EvenBetterLinkMovementMethod can fallback to default click listener.
|
||||
if (url.isValidUrl() && urlClickCallback?.onUrlLongClicked(url) == true) {
|
||||
tv.dispatchTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0f, 0f, 0))
|
||||
true
|
||||
|
|
Loading…
Reference in a new issue