Add support's library custom tabs

This commit is contained in:
len 2016-05-25 17:33:58 +02:00
parent a4b6003e58
commit bc3d5dc863
2 changed files with 8 additions and 3 deletions

View file

@ -110,6 +110,7 @@ dependencies {
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION" compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:preference-v7:$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:preference-v14:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:customtabs:$SUPPORT_LIBRARY_VERSION"
// ReactiveX // ReactiveX
compile 'io.reactivex:rxandroid:1.2.0' compile 'io.reactivex:rxandroid:1.2.0'

View file

@ -1,8 +1,8 @@
package eu.kanade.tachiyomi.ui.manga.info package eu.kanade.tachiyomi.ui.manga.info
import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.support.customtabs.CustomTabsIntent
import android.view.* import android.view.*
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy 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.database.models.Manga
import eu.kanade.tachiyomi.data.source.base.Source import eu.kanade.tachiyomi.data.source.base.Source
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
import eu.kanade.tachiyomi.util.getResourceColor
import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.toast
import kotlinx.android.synthetic.main.fragment_manga_info.* import kotlinx.android.synthetic.main.fragment_manga_info.*
import nucleus.factory.RequiresPresenter import nucleus.factory.RequiresPresenter
@ -140,8 +141,11 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
*/ */
fun openInBrowser() { fun openInBrowser() {
try { try {
val url = presenter.source.baseUrl + presenter.manga.url val url = Uri.parse(presenter.source.baseUrl + presenter.manga.url)
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) val intent = CustomTabsIntent.Builder()
.setToolbarColor(context.theme.getResourceColor(R.attr.colorPrimary))
.build()
intent.launchUrl(activity, url)
} catch (e: Exception) { } catch (e: Exception) {
context.toast(e.message) context.toast(e.message)
} }