forked from GitHub-Mirror/riotX-android
Merge pull request #161 from vector-im/feature/fix_timeline_clicks
Fix / click|longclick link interference
This commit is contained in:
@ -91,7 +91,7 @@ dependencies {
|
||||
def moshi_version = '1.8.0'
|
||||
def lifecycle_version = '2.0.0'
|
||||
def coroutines_version = "1.0.1"
|
||||
def markwon_version = '3.0.0-SNAPSHOT'
|
||||
def markwon_version = '3.0.0'
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.aar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
@ -17,9 +17,6 @@
|
||||
package im.vector.matrix.android.api.permalinks
|
||||
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.widget.TextView
|
||||
import im.vector.matrix.android.api.MatrixPatterns
|
||||
|
||||
/**
|
||||
@ -56,37 +53,5 @@ object MatrixLinkify {
|
||||
}
|
||||
return hasMatch
|
||||
}
|
||||
|
||||
fun addLinks(textView: TextView, callback: MatrixPermalinkSpan.Callback?): Boolean {
|
||||
val text = textView.text
|
||||
if (text is Spannable) {
|
||||
if (addLinks(text, callback)) {
|
||||
addLinkMovementMethod(textView)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
} else {
|
||||
val spannableString = SpannableString.valueOf(text)
|
||||
if (addLinks(spannableString, callback)) {
|
||||
addLinkMovementMethod(textView)
|
||||
textView.text = spannableString
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add linkMovementMethod on textview if not already set
|
||||
* @param textView the textView on which the movementMethod is set
|
||||
*/
|
||||
fun addLinkMovementMethod(textView: TextView) {
|
||||
val movementMethod = textView.movementMethod
|
||||
if (movementMethod == null || movementMethod !is LinkMovementMethod) {
|
||||
if (textView.linksClickable) {
|
||||
textView.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user