diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt index 4f5b5e944..fd6cb395c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt @@ -302,7 +302,7 @@ open class BrowseCatalogueController(bundle: Bundle) : val source = presenter.source as? HttpSource ?: return val activity = activity ?: return - val intent = WebViewActivity.newIntent(activity, source.id, source.baseUrl, presenter.source.name) + val intent = WebViewActivity.newIntent(activity, source.baseUrl, source.id, presenter.source.name) startActivity(intent) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index ac98197d6..9ba600ab6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -315,7 +315,7 @@ class MangaInfoController : NucleusController(), } val activity = activity ?: return - val intent = WebViewActivity.newIntent(activity, source.id, url, presenter.manga.title) + val intent = WebViewActivity.newIntent(activity, url, source.id, presenter.manga.title) startActivity(intent) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 1a31e9a26..88304ffc7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -1,10 +1,8 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager import android.annotation.SuppressLint -import android.content.Intent import android.graphics.PointF import android.graphics.drawable.Drawable -import android.net.Uri import android.view.GestureDetector import android.view.Gravity import android.view.MotionEvent @@ -32,6 +30,7 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.ZoomType +import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.gone @@ -417,9 +416,9 @@ class PagerPageHolder( layoutParams = FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply { setMargins(margins, margins, margins, margins) } - setText(R.string.action_open_in_browser) + setText(R.string.action_open_in_web_view) setOnClickListener { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(imageUrl)) + val intent = WebViewActivity.newIntent(context, imageUrl!!) context.startActivity(intent) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 16506b28a..d72cacb05 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -1,10 +1,8 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon import android.annotation.SuppressLint -import android.content.Intent import android.content.res.Resources import android.graphics.drawable.Drawable -import android.net.Uri import android.view.Gravity import android.view.ViewGroup import android.view.ViewGroup.LayoutParams.MATCH_PARENT @@ -30,6 +28,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar +import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.gone @@ -460,9 +459,9 @@ class WebtoonPageHolder( layoutParams = FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply { setMargins(0, margins, 0, margins) } - setText(R.string.action_open_in_browser) + setText(R.string.action_open_in_web_view) setOnClickListener { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(imageUrl)) + val intent = WebViewActivity.newIntent(context, imageUrl!!) context.startActivity(intent) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt index c12eb7e3b..36c0fcd1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt @@ -55,15 +55,17 @@ class WebViewActivity : BaseActivity() { } if (bundle == null) { - val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource - ?: return val url = intent.extras!!.getString(URL_KEY) ?: return - val headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" } + var headers = emptyMap() + + val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource + if (source != null) { + headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" } + binding.webview.settings.userAgentString = source.headers["User-Agent"] + } supportActionBar?.subtitle = url - binding.webview.settings.javaScriptEnabled = true - binding.webview.settings.userAgentString = source.headers["User-Agent"] binding.webview.webChromeClient = object : WebChromeClient() { override fun onProgressChanged(view: WebView?, newProgress: Int) { @@ -166,14 +168,14 @@ class WebViewActivity : BaseActivity() { } companion object { - private const val SOURCE_KEY = "source_key" private const val URL_KEY = "url_key" + private const val SOURCE_KEY = "source_key" private const val TITLE_KEY = "title_key" - fun newIntent(context: Context, sourceId: Long, url: String, title: String?): Intent { + fun newIntent(context: Context, url: String, sourceId: Long? = null, title: String? = null): Intent { val intent = Intent(context, WebViewActivity::class.java) - intent.putExtra(SOURCE_KEY, sourceId) intent.putExtra(URL_KEY, url) + intent.putExtra(SOURCE_KEY, sourceId) intent.putExtra(TITLE_KEY, title) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) return intent diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9bcec82d5..eeb5294ff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -500,7 +500,7 @@ Chapter %1$s Next chapter not found Previous chapter not found - The image could not be decoded + The image couldn\'t be loaded Use this image as cover art? Viewer for this series Finished: