Skip to content
Snippets Groups Projects
Verified Commit 5ac008f5 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Open links from messages in separate tabs in browsers

parent 7ec2b08d
Branches
Tags v1.2.4
No related merge requests found
Pipeline #498 passed
......@@ -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")
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment