From 922293bd8739c55f9a37312523f763745baaf1a8 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 10 Dec 2023 11:58:20 -0500 Subject: [PATCH] feat(app): Always show trackers action in MangaScreen Goes to tracker settings to log in if none are set up. --- .../presentation/entries/anime/AnimeScreen.kt | 6 +-- .../anime/components/AnimeInfoHeader.kt | 29 ++++++-------- .../presentation/entries/manga/MangaScreen.kt | 6 +-- .../manga/components/MangaInfoHeader.kt | 28 ++++++------- .../tachiyomi/ui/entries/anime/AnimeScreen.kt | 9 ++++- .../tachiyomi/ui/entries/manga/MangaScreen.kt | 9 ++++- .../eu/kanade/tachiyomi/ui/more/MoreTab.kt | 8 ++-- .../tachiyomi/ui/more/OnboardingScreen.kt | 2 +- .../tachiyomi/ui/setting/SettingsScreen.kt | 39 +++++++++---------- 9 files changed, 68 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt index 3d75e65b7..eae0b5754 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt @@ -112,7 +112,7 @@ fun AnimeScreen( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, // For tags menu onTagSearch: (String) -> Unit, @@ -262,7 +262,7 @@ private fun AnimeScreenSmallImpl( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, // For tags menu onTagSearch: (String) -> Unit, @@ -559,7 +559,7 @@ fun AnimeScreenLargeImpl( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, // For tags menu onTagSearch: (String) -> Unit, diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt index 3e5273882..53c7f9a99 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/components/AnimeInfoHeader.kt @@ -172,7 +172,7 @@ fun AnimeActionRow( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, onEditIntervalClicked: (() -> Unit)?, onEditCategory: (() -> Unit)?, ) { @@ -202,22 +202,17 @@ fun AnimeActionRow( onClick = onEditIntervalClicked, ) } - if (onTrackingClicked != null) { - AnimeActionButton( - title = if (trackingCount == 0) { - stringResource(MR.strings.manga_tracking_tab) - } else { - pluralStringResource( - MR.plurals.num_trackers, - count = trackingCount, - trackingCount, - ) - }, - icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done, - color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, - onClick = onTrackingClicked, - ) - } + AnimeActionButton( + title = if (trackingCount == 0) { + stringResource(MR.strings.manga_tracking_tab) + } else { + pluralStringResource(MR.plurals.num_trackers, count = trackingCount, trackingCount) + }, + icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done, + color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, + onClick = onTrackingClicked, + ) + if (onWebViewClicked != null) { AnimeActionButton( title = stringResource(MR.strings.action_web_view), diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt index 8c32343fe..c75fde78e 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt @@ -102,7 +102,7 @@ fun MangaScreen( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, // For tags menu onTagSearch: (String) -> Unit, @@ -242,7 +242,7 @@ private fun MangaScreenSmallImpl( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, // For tags menu onTagSearch: (String) -> Unit, @@ -499,7 +499,7 @@ fun MangaScreenLargeImpl( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, // For tags menu onTagSearch: (String) -> Unit, diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt index 82d91f011..0c1a4b927 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/components/MangaInfoHeader.kt @@ -171,7 +171,7 @@ fun MangaActionRow( onAddToLibraryClicked: () -> Unit, onWebViewClicked: (() -> Unit)?, onWebViewLongClicked: (() -> Unit)?, - onTrackingClicked: (() -> Unit)?, + onTrackingClicked: () -> Unit, onEditIntervalClicked: (() -> Unit)?, onEditCategory: (() -> Unit)?, modifier: Modifier = Modifier, @@ -202,22 +202,16 @@ fun MangaActionRow( onClick = onEditIntervalClicked, ) } - if (onTrackingClicked != null) { - MangaActionButton( - title = if (trackingCount == 0) { - stringResource(MR.strings.manga_tracking_tab) - } else { - pluralStringResource( - MR.plurals.num_trackers, - count = trackingCount, - trackingCount, - ) - }, - icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done, - color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, - onClick = onTrackingClicked, - ) - } + MangaActionButton( + title = if (trackingCount == 0) { + stringResource(MR.strings.manga_tracking_tab) + } else { + pluralStringResource(MR.plurals.num_trackers, count = trackingCount, trackingCount) + }, + icon = if (trackingCount == 0) Icons.Outlined.Sync else Icons.Outlined.Done, + color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary, + onClick = onTrackingClicked, + ) if (onWebViewClicked != null) { MangaActionButton( title = stringResource(MR.strings.action_web_view), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt index eb3d75eab..4df57bcbe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt @@ -47,6 +47,7 @@ import eu.kanade.tachiyomi.ui.entries.anime.track.AnimeTrackInfoDialogHomeScreen import eu.kanade.tachiyomi.ui.home.HomeScreen import eu.kanade.tachiyomi.ui.library.anime.AnimeLibraryTab import eu.kanade.tachiyomi.ui.main.MainActivity +import eu.kanade.tachiyomi.ui.setting.SettingsScreen import eu.kanade.tachiyomi.ui.player.settings.dialogs.SkipIntroLengthDialog import eu.kanade.tachiyomi.ui.webview.WebViewScreen import eu.kanade.tachiyomi.util.system.copyToClipboard @@ -140,7 +141,13 @@ class AnimeScreen( screenModel.source, ) }.takeIf { isAnimeHttpSource }, - onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable }, + onTrackingClicked = { + if (successState.trackingCount == 0) { + navigator.push(SettingsScreen(SettingsScreen.Destination.Tracking)) + } else { + screenModel.showTrackDialog() + } + }, onTagSearch = { scope.launch { performGenreSearch(navigator, it, screenModel.source!!) } }, onFilterButtonClicked = screenModel::showSettingsDialog, onRefresh = screenModel::fetchAllFromSource, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt index d6530a821..26d93253f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt @@ -48,6 +48,7 @@ import eu.kanade.tachiyomi.ui.entries.manga.track.MangaTrackInfoDialogHomeScreen import eu.kanade.tachiyomi.ui.home.HomeScreen import eu.kanade.tachiyomi.ui.library.manga.MangaLibraryTab import eu.kanade.tachiyomi.ui.reader.ReaderActivity +import eu.kanade.tachiyomi.ui.setting.SettingsScreen import eu.kanade.tachiyomi.ui.webview.WebViewScreen import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.toShareIntent @@ -131,7 +132,13 @@ class MangaScreen( screenModel.source, ) }.takeIf { isHttpSource }, - onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable }, + onTrackingClicked = { + if (successState.trackingCount == 0) { + navigator.push(SettingsScreen(SettingsScreen.Destination.Tracking)) + } else { + screenModel.showTrackDialog() + } + }, onTagSearch = { scope.launch { performGenreSearch(navigator, it, screenModel.source!!) } }, onFilterButtonClicked = screenModel::showSettingsDialog, onRefresh = screenModel::fetchAllFromSource, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt index 30c8f1585..b9adbb8b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt @@ -60,7 +60,7 @@ object MoreTab : Tab() { } override suspend fun onReselect(navigator: Navigator) { - navigator.push(SettingsScreen.toMainScreen()) + navigator.push(SettingsScreen()) } @Composable @@ -81,9 +81,9 @@ object MoreTab : Tab() { onClickCategories = { navigator.push(CategoriesTab()) }, onClickStats = { navigator.push(StatsTab()) }, onClickStorage = { navigator.push(StorageTab()) }, - onClickDataAndStorage = { navigator.push(SettingsScreen.toDataAndStorageScreen()) }, - onClickSettings = { navigator.push(SettingsScreen.toMainScreen()) }, - onClickAbout = { navigator.push(SettingsScreen.toAboutScreen()) }, + onClickDataAndStorage = { navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage)) }, + onClickSettings = { navigator.push(SettingsScreen()) }, + onClickAbout = { navigator.push(SettingsScreen(SettingsScreen.Destination.About)) }, ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt index 037edd9f5..72e091954 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/OnboardingScreen.kt @@ -34,7 +34,7 @@ class OnboardingScreen : Screen() { onComplete = { finishOnboarding() }, onRestoreBackup = { finishOnboarding() - navigator.push(SettingsScreen.toDataAndStorageScreen()) + navigator.push(SettingsScreen(SettingsScreen.Destination.DataAndStorage)) }, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt index 5b2dcedb2..5ac3e0716 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsScreen.kt @@ -15,6 +15,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.presentation.more.settings.screen.SettingsAppearanceScreen import eu.kanade.presentation.more.settings.screen.SettingsDataScreen import eu.kanade.presentation.more.settings.screen.SettingsMainScreen +import eu.kanade.presentation.more.settings.screen.SettingsTrackingScreen import eu.kanade.presentation.more.settings.screen.about.AboutScreen import eu.kanade.presentation.util.DefaultNavigatorScreenTransition import eu.kanade.presentation.util.LocalBackPress @@ -22,9 +23,8 @@ import eu.kanade.presentation.util.Screen import eu.kanade.presentation.util.isTabletUi import tachiyomi.presentation.core.components.TwoPanelBox -class SettingsScreen private constructor( - val toDataAndStorage: Boolean, - val toAbout: Boolean, +class SettingsScreen( + private val destination: Destination = Destination.Main, ) : Screen() { @Composable @@ -32,12 +32,11 @@ class SettingsScreen private constructor( val parentNavigator = LocalNavigator.currentOrThrow if (!isTabletUi()) { Navigator( - screen = if (toDataAndStorage) { - SettingsDataScreen - } else if (toAbout) { - AboutScreen - } else { - SettingsMainScreen + screen = when (destination) { + Destination.Main -> SettingsMainScreen + Destination.About -> AboutScreen + Destination.DataAndStorage -> SettingsDataScreen + Destination.Tracking -> SettingsTrackingScreen }, content = { val pop: () -> Unit = { @@ -54,12 +53,11 @@ class SettingsScreen private constructor( ) } else { Navigator( - screen = if (toDataAndStorage) { - SettingsDataScreen - } else if (toAbout) { - AboutScreen - } else { - SettingsAppearanceScreen + screen = when (destination) { + Destination.Main -> SettingsAppearanceScreen + Destination.About -> AboutScreen + Destination.DataAndStorage -> SettingsDataScreen + Destination.Tracking -> SettingsTrackingScreen }, ) { val insets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal) @@ -78,11 +76,10 @@ class SettingsScreen private constructor( } } - companion object { - fun toMainScreen() = SettingsScreen(toDataAndStorage = false, toAbout = false) - - fun toDataAndStorageScreen() = SettingsScreen(toDataAndStorage = true, toAbout = false) - - fun toAboutScreen() = SettingsScreen(toDataAndStorage = false, toAbout = true) + sealed interface Destination { + data object Main : Destination + data object About : Destination + data object DataAndStorage : Destination + data object Tracking : Destination } }