From 99270e370e1aba37c3ab5d8954363dd335ca0353 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sun, 4 Sep 2022 22:14:37 +0700 Subject: [PATCH] Fix missing downloaded only/incognito banners in Browse Source (#7936) --- .../presentation/browse/BrowseSourceScreen.kt | 35 +++++++++++++------ .../source/browse/BrowseSourceController.kt | 2 ++ .../source/browse/BrowseSourcePresenter.kt | 3 ++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt index 98fc48a6c8..c0541daa77 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/BrowseSourceScreen.kt @@ -2,6 +2,7 @@ package eu.kanade.presentation.browse import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.navigationBarsPadding @@ -39,8 +40,10 @@ import eu.kanade.presentation.browse.components.BrowseSourceComfortableGrid import eu.kanade.presentation.browse.components.BrowseSourceCompactGrid import eu.kanade.presentation.browse.components.BrowseSourceList import eu.kanade.presentation.browse.components.BrowseSourceToolbar +import eu.kanade.presentation.components.DownloadedOnlyModeBanner import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.ExtendedFloatingActionButton +import eu.kanade.presentation.components.IncognitoModeBanner import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.components.Scaffold import eu.kanade.tachiyomi.R @@ -58,6 +61,8 @@ fun BrowseSourceScreen( onMangaClick: (Manga) -> Unit, onMangaLongClick: (Manga) -> Unit, onWebViewClick: () -> Unit, + incognitoMode: Boolean, + downloadedOnlyMode: Boolean, ) { val columns by presenter.getColumnsPreferenceForCurrentOrientation() @@ -73,17 +78,25 @@ fun BrowseSourceScreen( Scaffold( topBar = { scrollBehavior -> - BrowseSourceToolbar( - state = presenter, - source = presenter.source!!, - displayMode = presenter.displayMode, - onDisplayModeChange = { presenter.displayMode = it }, - navigateUp = navigateUp, - onWebViewClick = onWebViewClick, - onHelpClick = onHelpClick, - onSearch = { presenter.search() }, - scrollBehavior = scrollBehavior, - ) + Column { + BrowseSourceToolbar( + state = presenter, + source = presenter.source!!, + displayMode = presenter.displayMode, + onDisplayModeChange = { presenter.displayMode = it }, + navigateUp = navigateUp, + onWebViewClick = onWebViewClick, + onHelpClick = onHelpClick, + onSearch = { presenter.search() }, + scrollBehavior = scrollBehavior, + ) + if (downloadedOnlyMode) { + DownloadedOnlyModeBanner() + } + if (incognitoMode) { + IncognitoModeBanner() + } + } }, floatingActionButton = { BrowseSourceFloatingActionButton( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index 41be40ee2a..6533719259 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -70,6 +70,8 @@ open class BrowseSourceController(bundle: Bundle) : val intent = WebViewActivity.newIntent(context, source.baseUrl, source.id, source.name) context.startActivity(intent) }, + incognitoMode = presenter.isIncognitoMode, + downloadedOnlyMode = presenter.isDownloadOnly, ) val onDismissRequest = { presenter.dialog = null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt index db3c2b98d4..0500ad3450 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt @@ -103,6 +103,9 @@ open class BrowseSourcePresenter( var displayMode by preferences.sourceDisplayMode().asState() + val isDownloadOnly: Boolean by preferences.downloadedOnly().asState() + val isIncognitoMode: Boolean by preferences.incognitoMode().asState() + @Composable fun getColumnsPreferenceForCurrentOrientation(): State { val isLandscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE