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,
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()

View file

@ -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) },

View file

@ -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()
},
)
}
}
}

View file

@ -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()

View file

@ -76,6 +76,7 @@
<string name="action_disable_all">Disable all</string>
<string name="action_edit">Edit</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_add_category">Add category</string>
<string name="action_edit_categories">Edit categories</string>