From c5994e057b37484fec3a5300491946afe377a90a Mon Sep 17 00:00:00 2001 From: Catting <5874051+mm12@users.noreply.github.com> Date: Sun, 11 Aug 2024 16:52:47 -0500 Subject: [PATCH] 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> --- .../kanade/presentation/reader/appbars/ReaderAppBars.kt | 9 +++++++++ .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt b/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt index 964172483..124f3a6c3 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt @@ -45,6 +45,7 @@ fun ReaderAppBars( onClickTopAppBar: () -> Unit, bookmarked: Boolean, onToggleBookmarked: () -> Unit, + onOpenInBrowser: (() -> Unit)?, onOpenInWebView: (() -> Unit)?, onShare: (() -> Unit)?, @@ -119,6 +120,14 @@ fun ReaderAppBars( onClick = onToggleBookmarked, ), ) + onOpenInBrowser?.let { + add( + AppBar.OverflowAction( + title = stringResource(MR.strings.action_open_in_browser), + onClick = it, + ), + ) + } onOpenInWebView?.let { add( AppBar.OverflowAction( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 1a177e211..7f0b3ab35 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -75,6 +75,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.hasDisplayCutout 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.toast import eu.kanade.tachiyomi.util.view.setComposeContent @@ -389,6 +390,7 @@ class ReaderActivity : BaseActivity() { onClickTopAppBar = ::openMangaScreen, bookmarked = state.bookmarked, onToggleBookmarked = viewModel::toggleChapterBookmark, + onOpenInBrowser = ::openChapterInBrowser.takeIf { isHttpSource }, onOpenInWebView = ::openChapterInWebView.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() { val manga = viewModel.manga ?: return val source = viewModel.getSource() ?: return