Load urls inside webview
This commit is contained in:
parent
e7df172da1
commit
ba2194f435
@ -5,11 +5,11 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
|
import eu.kanade.tachiyomi.util.WebViewClientCompat
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class MangaWebViewController(bundle: Bundle? = null) : BaseController(bundle) {
|
class MangaWebViewController(bundle: Bundle? = null) : BaseController(bundle) {
|
||||||
@ -32,7 +32,12 @@ class MangaWebViewController(bundle: Bundle? = null) : BaseController(bundle) {
|
|||||||
val headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
val headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
||||||
|
|
||||||
val web = view as WebView
|
val web = view as WebView
|
||||||
web.webViewClient = WebViewClient()
|
web.webViewClient = object : WebViewClientCompat() {
|
||||||
|
override fun shouldOverrideUrlCompat(view: WebView, url: String): Boolean {
|
||||||
|
view.loadUrl(url)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
web.settings.javaScriptEnabled = true
|
web.settings.javaScriptEnabled = true
|
||||||
web.settings.userAgentString = source.headers["User-Agent"]
|
web.settings.userAgentString = source.headers["User-Agent"]
|
||||||
web.loadUrl(url, headers)
|
web.loadUrl(url, headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user