From f03a83413689923633c8ebe5634b34c566733961 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 26 Feb 2023 16:58:36 -0500 Subject: [PATCH] Add explicit overflow menu options to refresh library category and manga chapters list Jetpack Compose treats mouse input differently than just mimicking a touch input, so dragging doesn't actually invoke the pull to refresh. If that changes in the future, we could consider removing these. Doesn't seem too necessary for the extensions list, so I skipped that. Closes #8455 --- .../library/components/LibraryToolbar.kt | 10 +++ .../kanade/presentation/manga/MangaScreen.kt | 2 + .../manga/components/MangaToolbar.kt | 64 ++++++++++--------- .../kanade/tachiyomi/ui/library/LibraryTab.kt | 3 +- i18n/src/main/res/values/strings.xml | 1 + 5 files changed, 50 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt index c5a73b6ff..022839c0e 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt @@ -37,6 +37,7 @@ fun LibraryToolbar( onClickInvertSelection: () -> Unit, onClickFilter: () -> Unit, onClickRefresh: () -> Unit, + onClickGlobalUpdate: () -> Unit, onClickOpenRandomManga: () -> Unit, searchQuery: String?, onSearchQueryChange: (String?) -> Unit, @@ -55,6 +56,7 @@ fun LibraryToolbar( onSearchQueryChange = onSearchQueryChange, onClickFilter = onClickFilter, onClickRefresh = onClickRefresh, + onClickGlobalUpdate = onClickGlobalUpdate, onClickOpenRandomManga = onClickOpenRandomManga, scrollBehavior = scrollBehavior, ) @@ -68,6 +70,7 @@ fun LibraryRegularToolbar( onSearchQueryChange: (String?) -> Unit, onClickFilter: () -> Unit, onClickRefresh: () -> Unit, + onClickGlobalUpdate: () -> Unit, onClickOpenRandomManga: () -> Unit, scrollBehavior: TopAppBarScrollBehavior?, ) { @@ -101,6 +104,13 @@ fun LibraryRegularToolbar( OverflowMenu { closeMenu -> DropdownMenuItem( text = { Text(text = stringResource(R.string.pref_category_library_update)) }, + onClick = { + onClickGlobalUpdate() + closeMenu() + }, + ) + DropdownMenuItem( + text = { Text(text = stringResource(R.string.action_update_category)) }, onClick = { onClickRefresh() closeMenu() diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 09d5af357..541036b7d 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -275,6 +275,7 @@ private fun MangaScreenSmallImpl( onClickShare = onShareClicked, onClickDownload = onDownloadActionClicked, onClickEditCategory = onEditCategoryClicked, + onClickRefresh = onRefresh, onClickMigrate = onMigrateClicked, actionModeCounter = chapters.count { it.selected }, onSelectAll = { onAllChapterSelected(true) }, @@ -495,6 +496,7 @@ fun MangaScreenLargeImpl( onClickShare = onShareClicked, onClickDownload = onDownloadActionClicked, onClickEditCategory = onEditCategoryClicked, + onClickRefresh = onRefresh, onClickMigrate = onMigrateClicked, actionModeCounter = chapters.count { it.selected }, onSelectAll = { onAllChapterSelected(true) }, diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt index 788d48eb7..04a63dddd 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaToolbar.kt @@ -44,6 +44,7 @@ fun MangaToolbar( onClickShare: (() -> Unit)?, onClickDownload: ((DownloadAction) -> Unit)?, onClickEditCategory: (() -> Unit)?, + onClickRefresh: () -> Unit, onClickMigrate: (() -> Unit)?, // For action mode actionModeCounter: Int, @@ -109,35 +110,40 @@ fun MangaToolbar( Icon(Icons.Outlined.FilterList, contentDescription = stringResource(R.string.action_filter), tint = filterTint) } - if (onClickEditCategory != null || onClickMigrate != null || onClickShare != null) { - OverflowMenu { closeMenu -> - if (onClickEditCategory != null) { - DropdownMenuItem( - text = { Text(text = stringResource(R.string.action_edit_categories)) }, - onClick = { - onClickEditCategory() - closeMenu() - }, - ) - } - if (onClickMigrate != null) { - DropdownMenuItem( - text = { Text(text = stringResource(R.string.action_migrate)) }, - onClick = { - onClickMigrate() - closeMenu() - }, - ) - } - if (onClickShare != null) { - DropdownMenuItem( - text = { Text(text = stringResource(R.string.action_share)) }, - onClick = { - onClickShare() - closeMenu() - }, - ) - } + OverflowMenu { closeMenu -> + DropdownMenuItem( + text = { Text(text = stringResource(R.string.action_webview_refresh)) }, + onClick = { + onClickRefresh() + closeMenu() + }, + ) + if (onClickEditCategory != null) { + DropdownMenuItem( + text = { Text(text = stringResource(R.string.action_edit_categories)) }, + onClick = { + onClickEditCategory() + closeMenu() + }, + ) + } + if (onClickMigrate != null) { + DropdownMenuItem( + text = { Text(text = stringResource(R.string.action_migrate)) }, + onClick = { + onClickMigrate() + closeMenu() + }, + ) + } + if (onClickShare != null) { + DropdownMenuItem( + text = { Text(text = stringResource(R.string.action_share)) }, + onClick = { + onClickShare() + closeMenu() + }, + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt index 63a8bfee2..2b8e10108 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt @@ -114,7 +114,8 @@ object LibraryTab : Tab { onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) }, onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) }, onClickFilter = { screenModel.showSettingsDialog() }, - onClickRefresh = { onClickRefresh(null) }, + onClickRefresh = { onClickRefresh(state.categories[screenModel.activeCategoryIndex]) }, + onClickGlobalUpdate = { onClickRefresh(null) }, onClickOpenRandomManga = { scope.launch { val randomItem = screenModel.getRandomLibraryItemForCurrentCategory() diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index c018161d6..90ec078df 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -76,6 +76,7 @@ Disable all Edit Add + Update category Open random entry Add category Edit categories