WebView for chapter link (#8281)
* backup
* doing logic
* cleanup
* applying suggestion
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
* requested changes
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
(cherry picked from commit 37b7efbc87)
# Conflicts:
# app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
# app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt
This commit is contained in:
@@ -353,6 +353,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
*/
|
||||
/*override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_open_in_web_view -> {
|
||||
openChapterInWebview()
|
||||
}
|
||||
R.id.action_bookmark -> {
|
||||
presenter.bookmarkCurrentChapter(true)
|
||||
invalidateOptionsMenu()
|
||||
@@ -653,7 +656,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
setTooltip(R.string.action_open_in_web_view)
|
||||
|
||||
setOnClickListener {
|
||||
openMangaInBrowser()
|
||||
openChapterInWebview()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1020,25 +1023,6 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
}
|
||||
}
|
||||
|
||||
// SY -->
|
||||
fun openMangaInBrowser() {
|
||||
val source = sourceManager.getOrStub(presenter.manga!!.source) as? HttpSource ?: return
|
||||
val url = try {
|
||||
source.mangaDetailsRequest(presenter.manga!!).url.toString()
|
||||
} catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
|
||||
val intent = WebViewActivity.newIntent(
|
||||
applicationContext,
|
||||
url,
|
||||
source.id,
|
||||
presenter.manga!!.title,
|
||||
)
|
||||
startActivity(intent)
|
||||
}
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer
|
||||
* and the toolbar title.
|
||||
@@ -1146,6 +1130,15 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
startPostponedEnterTransition()
|
||||
}
|
||||
|
||||
private fun openChapterInWebview() {
|
||||
val manga = presenter.manga ?: return
|
||||
val source = presenter.getSource() ?: return
|
||||
val url = presenter.getChapterUrl() ?: return
|
||||
|
||||
val intent = WebViewActivity.newIntent(this, url, source.id, manga.title)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun showReadingModeToast(mode: Int) {
|
||||
try {
|
||||
val strings = resources.getStringArray(R.array.viewers_selector)
|
||||
|
||||
@@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.data.track.job.DelayedTrackingStore
|
||||
import eu.kanade.tachiyomi.data.track.job.DelayedTrackingUpdateJob
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.source.online.MetadataSource
|
||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
@@ -709,6 +710,15 @@ class ReaderPresenter(
|
||||
return viewerChaptersRelay.value?.currChapter
|
||||
}
|
||||
|
||||
fun getSource() = manga?.source?.let { sourceManager.getOrStub(it) } as? HttpSource
|
||||
|
||||
fun getChapterUrl(): String? {
|
||||
val sChapter = getCurrentChapter()?.chapter ?: return null
|
||||
val source = getSource() ?: return null
|
||||
|
||||
return source.getChapterUrl(sChapter)
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookmarks the currently active chapter.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user