Add an "open in browser" button to reader menu (#1110)

* Add an "open in browser" button to reader menu

Signed-off-by: Catting <5874051+mm12@users.noreply.github.com>

* fixup! Add an "open in browser" button to reader menu

Signed-off-by: Catting <5874051+mm12@users.noreply.github.com>

---------

Signed-off-by: Catting <5874051+mm12@users.noreply.github.com>
This commit is contained in:
Catting 2024-08-11 16:52:47 -05:00 committed by GitHub
parent 3f1d28c383
commit c5994e057b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -45,6 +45,7 @@ fun ReaderAppBars(
onClickTopAppBar: () -> Unit, onClickTopAppBar: () -> Unit,
bookmarked: Boolean, bookmarked: Boolean,
onToggleBookmarked: () -> Unit, onToggleBookmarked: () -> Unit,
onOpenInBrowser: (() -> Unit)?,
onOpenInWebView: (() -> Unit)?, onOpenInWebView: (() -> Unit)?,
onShare: (() -> Unit)?, onShare: (() -> Unit)?,
@ -119,6 +120,14 @@ fun ReaderAppBars(
onClick = onToggleBookmarked, onClick = onToggleBookmarked,
), ),
) )
onOpenInBrowser?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_browser),
onClick = it,
),
)
}
onOpenInWebView?.let { onOpenInWebView?.let {
add( add(
AppBar.OverflowAction( AppBar.OverflowAction(

View file

@ -75,6 +75,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.hasDisplayCutout import eu.kanade.tachiyomi.util.system.hasDisplayCutout
import eu.kanade.tachiyomi.util.system.isNightMode import eu.kanade.tachiyomi.util.system.isNightMode
import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toShareIntent
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.setComposeContent import eu.kanade.tachiyomi.util.view.setComposeContent
@ -389,6 +390,7 @@ class ReaderActivity : BaseActivity() {
onClickTopAppBar = ::openMangaScreen, onClickTopAppBar = ::openMangaScreen,
bookmarked = state.bookmarked, bookmarked = state.bookmarked,
onToggleBookmarked = viewModel::toggleChapterBookmark, onToggleBookmarked = viewModel::toggleChapterBookmark,
onOpenInBrowser = ::openChapterInBrowser.takeIf { isHttpSource },
onOpenInWebView = ::openChapterInWebView.takeIf { isHttpSource }, onOpenInWebView = ::openChapterInWebView.takeIf { isHttpSource },
onShare = ::shareChapter.takeIf { isHttpSource }, onShare = ::shareChapter.takeIf { isHttpSource },
@ -563,6 +565,12 @@ class ReaderActivity : BaseActivity() {
} }
} }
private fun openChapterInBrowser() {
assistUrl?.let {
openInBrowser(it.toUri(), forceDefaultBrowser = false)
}
}
private fun openChapterInWebView() { private fun openChapterInWebView() {
val manga = viewModel.manga ?: return val manga = viewModel.manga ?: return
val source = viewModel.getSource() ?: return val source = viewModel.getSource() ?: return