Open links from messages in separate tabs in browsers

parent 7ec2b08d
Pipeline #498 passed with stages
in 40 minutes and 25 seconds
......@@ -19,8 +19,13 @@
package de.kuschku.quasseldroid.util.irc.format.spans
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.text.TextPaint
import android.text.style.URLSpan
import android.util.Log
import android.view.View
class QuasselURLSpan(text: String, private val highlight: Boolean) : URLSpan(text) {
override fun updateDrawState(ds: TextPaint?) {
......@@ -29,4 +34,14 @@ class QuasselURLSpan(text: String, private val highlight: Boolean) : URLSpan(tex
ds.isUnderlineText = true
}
}
override fun onClick(widget: View) {
try {
widget.context?.startActivity(Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(url)
})
} catch (e: ActivityNotFoundException) {
Log.w("QuasselURLSpan", "Actvity was not found for $url")
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment