Add an "open in browser" button to reader menu (mihonapp/mihon#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> (cherry picked from commit c5994e057b37484fec3a5300491946afe377a90a)
This commit is contained in:
parent
40d2350576
commit
a827601186
4 changed files with 84 additions and 22 deletions
|
|
@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.FormatListNumbered
|
||||
import androidx.compose.material.icons.outlined.OpenInBrowser
|
||||
import androidx.compose.material.icons.outlined.Public
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.Share
|
||||
|
|
@ -46,6 +47,9 @@ fun BottomReaderBar(
|
|||
dualPageSplitEnabled: Boolean,
|
||||
doublePages: Boolean,
|
||||
onClickChapterList: () -> Unit,
|
||||
// KMK -->
|
||||
onClickBrowser: (() -> Unit)?,
|
||||
// KMK <--
|
||||
onClickWebView: (() -> Unit)?,
|
||||
onClickShare: (() -> Unit)?,
|
||||
onClickPageLayout: () -> Unit,
|
||||
|
|
@ -76,6 +80,20 @@ fun BottomReaderBar(
|
|||
}
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
if (ReaderBottomButton.Browser.isIn(enabledButtons) && onClickBrowser != null) {
|
||||
IconButton(onClick = onClickBrowser) {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.OpenInBrowser,
|
||||
contentDescription = stringResource(MR.strings.action_open_in_browser),
|
||||
// KMK -->
|
||||
tint = iconColor,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
}
|
||||
// KMK <--
|
||||
|
||||
if (ReaderBottomButton.WebView.isIn(enabledButtons) && onClickWebView != null) {
|
||||
IconButton(onClick = onClickWebView) {
|
||||
Icon(
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ fun ReaderAppBars(
|
|||
onClickTopAppBar: () -> Unit,
|
||||
// bookmarked: Boolean,
|
||||
// onToggleBookmarked: () -> Unit,
|
||||
onOpenInBrowser: (() -> Unit)?,
|
||||
onOpenInWebView: (() -> Unit)?,
|
||||
onShare: (() -> Unit)?,
|
||||
|
||||
|
|
@ -212,31 +213,57 @@ fun ReaderAppBars(
|
|||
title = mangaTitle,
|
||||
subtitle = chapterTitle,
|
||||
navigateUp = navigateUp,
|
||||
/* SY --> actions = {
|
||||
/* SY -->
|
||||
actions = {
|
||||
AppBarActions(
|
||||
listOfNotNull(
|
||||
AppBar.Action(
|
||||
title = stringResource(
|
||||
if (bookmarked) MR.strings.action_remove_bookmark else MR.strings.action_bookmark
|
||||
),
|
||||
icon = if (bookmarked) Icons.Outlined.Bookmark else Icons.Outlined.BookmarkBorder,
|
||||
onClick = onToggleBookmarked,
|
||||
),
|
||||
onOpenInWebView?.let {
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_open_in_web_view),
|
||||
onClick = it,
|
||||
actions = persistentListOf<AppBar.AppBarAction>().builder()
|
||||
.apply {
|
||||
add(
|
||||
AppBar.Action(
|
||||
title = stringResource(
|
||||
if (bookmarked) {
|
||||
MR.strings.action_remove_bookmark
|
||||
} else {
|
||||
MR.strings.action_bookmark
|
||||
},
|
||||
),
|
||||
icon = if (bookmarked) {
|
||||
Icons.Outlined.Bookmark
|
||||
} else {
|
||||
Icons.Outlined.BookmarkBorder
|
||||
},
|
||||
onClick = onToggleBookmarked,
|
||||
),
|
||||
)
|
||||
},
|
||||
onShare?.let {
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_share),
|
||||
onClick = it,
|
||||
)
|
||||
},
|
||||
),
|
||||
onOpenInBrowser?.let {
|
||||
add(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_open_in_browser),
|
||||
onClick = it,
|
||||
),
|
||||
)
|
||||
}
|
||||
onOpenInWebView?.let {
|
||||
add(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_open_in_web_view),
|
||||
onClick = it,
|
||||
),
|
||||
)
|
||||
}
|
||||
onShare?.let {
|
||||
add(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_share),
|
||||
onClick = it,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
.build(),
|
||||
)
|
||||
}, SY <-- */
|
||||
},
|
||||
SY <-- */
|
||||
)
|
||||
// SY -->
|
||||
ExhUtils(
|
||||
|
|
@ -307,10 +334,14 @@ fun ReaderAppBars(
|
|||
dualPageSplitEnabled = dualPageSplitEnabled,
|
||||
doublePages = doublePages,
|
||||
onClickChapterList = onClickChapterList,
|
||||
// KMK -->
|
||||
onClickBrowser = onOpenInBrowser,
|
||||
// KMK <--
|
||||
onClickWebView = onOpenInWebView,
|
||||
onClickShare = onShare,
|
||||
onClickPageLayout = onClickPageLayout,
|
||||
onClickShiftPage = onClickShiftPage,
|
||||
// SY <--
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
|||
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
|
||||
|
|
@ -514,6 +515,7 @@ class ReaderActivity : BaseActivity() {
|
|||
onClickTopAppBar = ::openMangaScreen,
|
||||
// bookmarked = state.bookmarked,
|
||||
// onToggleBookmarked = viewModel::toggleChapterBookmark,
|
||||
onOpenInBrowser = ::openChapterInBrowser.takeIf { isHttpSource },
|
||||
onOpenInWebView = ::openChapterInWebView.takeIf { isHttpSource },
|
||||
onShare = ::shareChapter.takeIf { isHttpSource },
|
||||
|
||||
|
|
@ -1022,6 +1024,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
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ import tachiyomi.i18n.sy.SYMR
|
|||
|
||||
enum class ReaderBottomButton(val value: String, val stringRes: StringResource) {
|
||||
ViewChapters("vc", MR.strings.action_view_chapters),
|
||||
|
||||
// KMK -->
|
||||
Browser("br", MR.strings.action_open_in_browser),
|
||||
// KMK <--
|
||||
|
||||
WebView("wb", MR.strings.action_open_in_web_view),
|
||||
Share("sh", MR.strings.action_share),
|
||||
ReadingMode("rm", MR.strings.viewer),
|
||||
|
|
|
|||
Loading…
Reference in a new issue