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:
parent
a425cae73b
commit
911e959fcf
@ -239,6 +239,7 @@ fun LibraryBottomActionMenu(
|
|||||||
onClickCleanTitles: (() -> Unit)?,
|
onClickCleanTitles: (() -> Unit)?,
|
||||||
onClickMigrate: (() -> Unit)?,
|
onClickMigrate: (() -> Unit)?,
|
||||||
onClickAddToMangaDex: (() -> Unit)?,
|
onClickAddToMangaDex: (() -> Unit)?,
|
||||||
|
onClickResetInfo: (() -> Unit)?,
|
||||||
// SY <--
|
// SY <--
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
@ -267,7 +268,7 @@ fun LibraryBottomActionMenu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY -->
|
// SY -->
|
||||||
val showOverflow = onClickCleanTitles != null || onClickAddToMangaDex != null
|
val showOverflow = onClickCleanTitles != null || onClickAddToMangaDex != null || onClickResetInfo != null
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val moveMarkPrev = remember { !configuration.isTabletUi() }
|
val moveMarkPrev = remember { !configuration.isTabletUi() }
|
||||||
var overFlowOpen by remember { mutableStateOf(false) }
|
var overFlowOpen by remember { mutableStateOf(false) }
|
||||||
@ -364,6 +365,12 @@ fun LibraryBottomActionMenu(
|
|||||||
onClick = onClickAddToMangaDex,
|
onClick = onClickAddToMangaDex,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (onClickResetInfo != null) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(text = stringResource(SYMR.strings.reset_info)) },
|
||||||
|
onClick = onClickResetInfo,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Button(
|
Button(
|
||||||
|
@ -750,6 +750,24 @@ class LibraryScreenModel(
|
|||||||
clearSelection()
|
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 <--
|
// SY <--
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1336,6 +1354,18 @@ class LibraryScreenModel(
|
|||||||
val showAddToMangadex: Boolean by lazy {
|
val showAddToMangadex: Boolean by lazy {
|
||||||
selection.any { it.manga.source in mangaDexSourceIds }
|
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 <--
|
// SY <--
|
||||||
|
|
||||||
fun getLibraryItemsByCategoryId(categoryId: Long): List<LibraryItem>? {
|
fun getLibraryItemsByCategoryId(categoryId: Long): List<LibraryItem>? {
|
||||||
|
@ -205,6 +205,7 @@ object LibraryTab : Tab {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClickAddToMangaDex = screenModel::syncMangaToDex.takeIf { state.showAddToMangadex },
|
onClickAddToMangaDex = screenModel::syncMangaToDex.takeIf { state.showAddToMangadex },
|
||||||
|
onClickResetInfo = screenModel::resetInfo.takeIf { state.showResetInfo },
|
||||||
// SY <--
|
// SY <--
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -201,6 +201,7 @@ private fun onViewCreated(manga: Manga, context: Context, binding: EditMangaDial
|
|||||||
binding.mangaGenresTags.clearFocus()
|
binding.mangaGenresTags.clearFocus()
|
||||||
|
|
||||||
binding.resetTags.setOnClickListener { resetTags(manga, binding, scope) }
|
binding.resetTags.setOnClickListener { resetTags(manga, binding, scope) }
|
||||||
|
binding.resetInfo.setOnClickListener { resetInfo(manga, binding, scope) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetTags(manga: Manga, binding: EditMangaDialogBinding, scope: CoroutineScope) {
|
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) {
|
private fun ChipGroup.setChips(items: List<String>, scope: CoroutineScope) {
|
||||||
removeAllViews()
|
removeAllViews()
|
||||||
|
|
||||||
|
@ -139,6 +139,16 @@
|
|||||||
android:text="@string/reset_tags"
|
android:text="@string/reset_tags"
|
||||||
android:textAllCaps="false" />
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/reset_info"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:text="@string/reset_info"
|
||||||
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
@ -350,6 +350,7 @@
|
|||||||
<!-- Entry Info Edit -->
|
<!-- Entry Info Edit -->
|
||||||
<string name="reset_tags">Reset Tags</string>
|
<string name="reset_tags">Reset Tags</string>
|
||||||
<string name="add_tag">Add Tag</string>
|
<string name="add_tag">Add Tag</string>
|
||||||
|
<string name="reset_info">Reset Info</string>
|
||||||
<string name="title_hint">Title: %1$s</string>
|
<string name="title_hint">Title: %1$s</string>
|
||||||
<string name="description_hint">Description: %1$s</string>
|
<string name="description_hint">Description: %1$s</string>
|
||||||
<string name="author_hint">Author: %1$s</string>
|
<string name="author_hint">Author: %1$s</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user