From bc3d5dc8633f5081b22286dd99dd961dcb324f4e Mon Sep 17 00:00:00 2001 From: len Date: Wed, 25 May 2016 17:33:58 +0200 Subject: [PATCH] Add support's library custom tabs --- app/build.gradle | 1 + .../tachiyomi/ui/manga/info/MangaInfoFragment.kt | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9da1ba5737..c98daf7f33 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -110,6 +110,7 @@ dependencies { compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:preference-v7:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:preference-v14:$SUPPORT_LIBRARY_VERSION" + compile "com.android.support:customtabs:$SUPPORT_LIBRARY_VERSION" // ReactiveX compile 'io.reactivex:rxandroid:1.2.0' diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt index 6ff56d8b63..c8cad099f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt @@ -1,8 +1,8 @@ package eu.kanade.tachiyomi.ui.manga.info -import android.content.Intent import android.net.Uri import android.os.Bundle +import android.support.customtabs.CustomTabsIntent import android.view.* import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.source.base.Source import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment +import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.toast import kotlinx.android.synthetic.main.fragment_manga_info.* import nucleus.factory.RequiresPresenter @@ -140,8 +141,11 @@ class MangaInfoFragment : BaseRxFragment() { */ fun openInBrowser() { try { - val url = presenter.source.baseUrl + presenter.manga.url - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) + val url = Uri.parse(presenter.source.baseUrl + presenter.manga.url) + val intent = CustomTabsIntent.Builder() + .setToolbarColor(context.theme.getResourceColor(R.attr.colorPrimary)) + .build() + intent.launchUrl(activity, url) } catch (e: Exception) { context.toast(e.message) }