Add option to reset custom manga info (#1118)
* Add option to reset custom manga info * Remove extra line * Update app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt --------- Co-authored-by: jobobby04 <jobobby04@users.noreply.github.com>
This commit is contained in:
@@ -239,6 +239,7 @@ fun LibraryBottomActionMenu(
|
||||
onClickCleanTitles: (() -> Unit)?,
|
||||
onClickMigrate: (() -> Unit)?,
|
||||
onClickAddToMangaDex: (() -> Unit)?,
|
||||
onClickResetInfo: (() -> Unit)?,
|
||||
// SY <--
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
@@ -267,7 +268,7 @@ fun LibraryBottomActionMenu(
|
||||
}
|
||||
}
|
||||
// SY -->
|
||||
val showOverflow = onClickCleanTitles != null || onClickAddToMangaDex != null
|
||||
val showOverflow = onClickCleanTitles != null || onClickAddToMangaDex != null || onClickResetInfo != null
|
||||
val configuration = LocalConfiguration.current
|
||||
val moveMarkPrev = remember { !configuration.isTabletUi() }
|
||||
var overFlowOpen by remember { mutableStateOf(false) }
|
||||
@@ -364,6 +365,12 @@ fun LibraryBottomActionMenu(
|
||||
onClick = onClickAddToMangaDex,
|
||||
)
|
||||
}
|
||||
if (onClickResetInfo != null) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = stringResource(SYMR.strings.reset_info)) },
|
||||
onClick = onClickResetInfo,
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Button(
|
||||
|
||||
@@ -750,6 +750,24 @@ class LibraryScreenModel(
|
||||
clearSelection()
|
||||
}
|
||||
}
|
||||
|
||||
fun resetInfo() {
|
||||
state.value.selection.fastForEach { (manga) ->
|
||||
val mangaInfo = CustomMangaInfo(
|
||||
id = manga.id,
|
||||
title = null,
|
||||
author = null,
|
||||
artist = null,
|
||||
thumbnailUrl = null,
|
||||
description = null,
|
||||
genre = null,
|
||||
status = null,
|
||||
)
|
||||
|
||||
setCustomMangaInfo.set(mangaInfo)
|
||||
}
|
||||
clearSelection()
|
||||
}
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
@@ -1336,6 +1354,18 @@ class LibraryScreenModel(
|
||||
val showAddToMangadex: Boolean by lazy {
|
||||
selection.any { it.manga.source in mangaDexSourceIds }
|
||||
}
|
||||
|
||||
val showResetInfo: Boolean by lazy {
|
||||
selection.fastAny { (manga) ->
|
||||
manga.title != manga.ogTitle ||
|
||||
manga.author != manga.ogAuthor ||
|
||||
manga.artist != manga.ogArtist ||
|
||||
manga.thumbnailUrl != manga.ogThumbnailUrl ||
|
||||
manga.description != manga.ogDescription ||
|
||||
manga.genre != manga.ogGenre ||
|
||||
manga.status != manga.ogStatus
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
|
||||
fun getLibraryItemsByCategoryId(categoryId: Long): List<LibraryItem>? {
|
||||
|
||||
@@ -205,6 +205,7 @@ object LibraryTab : Tab {
|
||||
}
|
||||
},
|
||||
onClickAddToMangaDex = screenModel::syncMangaToDex.takeIf { state.showAddToMangadex },
|
||||
onClickResetInfo = screenModel::resetInfo.takeIf { state.showResetInfo },
|
||||
// SY <--
|
||||
)
|
||||
},
|
||||
|
||||
@@ -201,6 +201,7 @@ private fun onViewCreated(manga: Manga, context: Context, binding: EditMangaDial
|
||||
binding.mangaGenresTags.clearFocus()
|
||||
|
||||
binding.resetTags.setOnClickListener { resetTags(manga, binding, scope) }
|
||||
binding.resetInfo.setOnClickListener { resetInfo(manga, binding, scope) }
|
||||
}
|
||||
|
||||
private fun resetTags(manga: Manga, binding: EditMangaDialogBinding, scope: CoroutineScope) {
|
||||
@@ -217,6 +218,15 @@ private fun loadCover(manga: Manga, context: Context, binding: EditMangaDialogBi
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetInfo(manga: Manga, binding: EditMangaDialogBinding, scope: CoroutineScope) {
|
||||
binding.title.setText("")
|
||||
binding.mangaAuthor.setText("")
|
||||
binding.mangaArtist.setText("")
|
||||
binding.thumbnailUrl.setText("")
|
||||
binding.mangaDescription.setText("")
|
||||
resetTags(manga, binding, scope)
|
||||
}
|
||||
|
||||
private fun ChipGroup.setChips(items: List<String>, scope: CoroutineScope) {
|
||||
removeAllViews()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user