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
This commit is contained in:
arkon 2023-02-26 16:58:36 -05:00
parent f7f2072621
commit f03a834136
5 changed files with 50 additions and 30 deletions

View File

@ -37,6 +37,7 @@ fun LibraryToolbar(
onClickInvertSelection: () -> Unit, onClickInvertSelection: () -> Unit,
onClickFilter: () -> Unit, onClickFilter: () -> Unit,
onClickRefresh: () -> Unit, onClickRefresh: () -> Unit,
onClickGlobalUpdate: () -> Unit,
onClickOpenRandomManga: () -> Unit, onClickOpenRandomManga: () -> Unit,
searchQuery: String?, searchQuery: String?,
onSearchQueryChange: (String?) -> Unit, onSearchQueryChange: (String?) -> Unit,
@ -55,6 +56,7 @@ fun LibraryToolbar(
onSearchQueryChange = onSearchQueryChange, onSearchQueryChange = onSearchQueryChange,
onClickFilter = onClickFilter, onClickFilter = onClickFilter,
onClickRefresh = onClickRefresh, onClickRefresh = onClickRefresh,
onClickGlobalUpdate = onClickGlobalUpdate,
onClickOpenRandomManga = onClickOpenRandomManga, onClickOpenRandomManga = onClickOpenRandomManga,
scrollBehavior = scrollBehavior, scrollBehavior = scrollBehavior,
) )
@ -68,6 +70,7 @@ fun LibraryRegularToolbar(
onSearchQueryChange: (String?) -> Unit, onSearchQueryChange: (String?) -> Unit,
onClickFilter: () -> Unit, onClickFilter: () -> Unit,
onClickRefresh: () -> Unit, onClickRefresh: () -> Unit,
onClickGlobalUpdate: () -> Unit,
onClickOpenRandomManga: () -> Unit, onClickOpenRandomManga: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior?, scrollBehavior: TopAppBarScrollBehavior?,
) { ) {
@ -101,6 +104,13 @@ fun LibraryRegularToolbar(
OverflowMenu { closeMenu -> OverflowMenu { closeMenu ->
DropdownMenuItem( DropdownMenuItem(
text = { Text(text = stringResource(R.string.pref_category_library_update)) }, text = { Text(text = stringResource(R.string.pref_category_library_update)) },
onClick = {
onClickGlobalUpdate()
closeMenu()
},
)
DropdownMenuItem(
text = { Text(text = stringResource(R.string.action_update_category)) },
onClick = { onClick = {
onClickRefresh() onClickRefresh()
closeMenu() closeMenu()

View File

@ -275,6 +275,7 @@ private fun MangaScreenSmallImpl(
onClickShare = onShareClicked, onClickShare = onShareClicked,
onClickDownload = onDownloadActionClicked, onClickDownload = onDownloadActionClicked,
onClickEditCategory = onEditCategoryClicked, onClickEditCategory = onEditCategoryClicked,
onClickRefresh = onRefresh,
onClickMigrate = onMigrateClicked, onClickMigrate = onMigrateClicked,
actionModeCounter = chapters.count { it.selected }, actionModeCounter = chapters.count { it.selected },
onSelectAll = { onAllChapterSelected(true) }, onSelectAll = { onAllChapterSelected(true) },
@ -495,6 +496,7 @@ fun MangaScreenLargeImpl(
onClickShare = onShareClicked, onClickShare = onShareClicked,
onClickDownload = onDownloadActionClicked, onClickDownload = onDownloadActionClicked,
onClickEditCategory = onEditCategoryClicked, onClickEditCategory = onEditCategoryClicked,
onClickRefresh = onRefresh,
onClickMigrate = onMigrateClicked, onClickMigrate = onMigrateClicked,
actionModeCounter = chapters.count { it.selected }, actionModeCounter = chapters.count { it.selected },
onSelectAll = { onAllChapterSelected(true) }, onSelectAll = { onAllChapterSelected(true) },

View File

@ -44,6 +44,7 @@ fun MangaToolbar(
onClickShare: (() -> Unit)?, onClickShare: (() -> Unit)?,
onClickDownload: ((DownloadAction) -> Unit)?, onClickDownload: ((DownloadAction) -> Unit)?,
onClickEditCategory: (() -> Unit)?, onClickEditCategory: (() -> Unit)?,
onClickRefresh: () -> Unit,
onClickMigrate: (() -> Unit)?, onClickMigrate: (() -> Unit)?,
// For action mode // For action mode
actionModeCounter: Int, actionModeCounter: Int,
@ -109,8 +110,14 @@ fun MangaToolbar(
Icon(Icons.Outlined.FilterList, contentDescription = stringResource(R.string.action_filter), tint = filterTint) Icon(Icons.Outlined.FilterList, contentDescription = stringResource(R.string.action_filter), tint = filterTint)
} }
if (onClickEditCategory != null || onClickMigrate != null || onClickShare != null) {
OverflowMenu { closeMenu -> OverflowMenu { closeMenu ->
DropdownMenuItem(
text = { Text(text = stringResource(R.string.action_webview_refresh)) },
onClick = {
onClickRefresh()
closeMenu()
},
)
if (onClickEditCategory != null) { if (onClickEditCategory != null) {
DropdownMenuItem( DropdownMenuItem(
text = { Text(text = stringResource(R.string.action_edit_categories)) }, text = { Text(text = stringResource(R.string.action_edit_categories)) },
@ -140,7 +147,6 @@ fun MangaToolbar(
} }
} }
} }
}
}, },
colors = TopAppBarDefaults.topAppBarColors( colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme containerColor = MaterialTheme.colorScheme

View File

@ -114,7 +114,8 @@ object LibraryTab : Tab {
onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) }, onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) },
onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) }, onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) },
onClickFilter = { screenModel.showSettingsDialog() }, onClickFilter = { screenModel.showSettingsDialog() },
onClickRefresh = { onClickRefresh(null) }, onClickRefresh = { onClickRefresh(state.categories[screenModel.activeCategoryIndex]) },
onClickGlobalUpdate = { onClickRefresh(null) },
onClickOpenRandomManga = { onClickOpenRandomManga = {
scope.launch { scope.launch {
val randomItem = screenModel.getRandomLibraryItemForCurrentCategory() val randomItem = screenModel.getRandomLibraryItemForCurrentCategory()

View File

@ -76,6 +76,7 @@
<string name="action_disable_all">Disable all</string> <string name="action_disable_all">Disable all</string>
<string name="action_edit">Edit</string> <string name="action_edit">Edit</string>
<string name="action_add">Add</string> <string name="action_add">Add</string>
<string name="action_update_category">Update category</string>
<string name="action_open_random_manga">Open random entry</string> <string name="action_open_random_manga">Open random entry</string>
<string name="action_add_category">Add category</string> <string name="action_add_category">Add category</string>
<string name="action_edit_categories">Edit categories</string> <string name="action_edit_categories">Edit categories</string>