Unverified Commit 4b9fc144 authored by Leonardo Aramaki's avatar Leonardo Aramaki Committed by GitHub

Merge branch 'develop-2.x' into emoji-empty-view

parents 873d6580 1456a347
...@@ -110,6 +110,8 @@ dependencies { ...@@ -110,6 +110,8 @@ dependencies {
androidTestImplementation(libraries.expressoCore, { androidTestImplementation(libraries.expressoCore, {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
implementation 'com.android.support:customtabs:27.0.2'
} }
kotlin { kotlin {
......
...@@ -7,6 +7,7 @@ import android.content.Intent ...@@ -7,6 +7,7 @@ import android.content.Intent
import android.graphics.* import android.graphics.*
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.support.customtabs.CustomTabsIntent
import android.provider.Browser import android.provider.Browser
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v4.content.res.ResourcesCompat import android.support.v4.content.res.ResourcesCompat
...@@ -171,16 +172,12 @@ class MessageParser @Inject constructor(val context: Application, private val co ...@@ -171,16 +172,12 @@ class MessageParser @Inject constructor(val context: Application, private val co
if (!link.startsWith("@") && link !in consumed) { if (!link.startsWith("@") && link !in consumed) {
builder.setSpan(object : ClickableSpan() { builder.setSpan(object : ClickableSpan() {
override fun onClick(view: View) { override fun onClick(view: View) {
val uri = getUri(link) with (view) {
val context = view.context val tabsbuilder = CustomTabsIntent.Builder()
val intent = Intent(Intent.ACTION_VIEW, uri) tabsbuilder.setToolbarColor(ResourcesCompat.getColor(context.resources, R.color.colorPrimary, context.theme))
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.packageName) val customTabsIntent = tabsbuilder.build()
try { customTabsIntent.launchUrl(context, getUri(link))
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Timber.e("Actvity was not found for intent, $intent")
} }
} }
}, matcher.start(0), matcher.end(0)) }, matcher.start(0), matcher.end(0))
consumed.add(link) consumed.add(link)
......
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