From 352bea73d070d3d3150c68d0e214976ed09888c9 Mon Sep 17 00:00:00 2001 From: NGB-Was-Taken <76197326+NGB-Was-Taken@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:14:57 +0000 Subject: [PATCH] Allow adding multiple tags separated by commas --- .../tachiyomi/ui/manga/EditMangaDialog.kt | 17 +++++++++-------- .../commonMain/moko-resources/base/strings.xml | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt index 50902fa8d3e8..5b6e96f381eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt @@ -246,7 +246,7 @@ private fun ChipGroup.setChips(items: List, scope: CoroutineScope) { } val addTagChip = Chip(context).apply { - setText(SYMR.strings.add_tag.getString(context)) + setText(SYMR.strings.add_tags.getString(context)) chipIcon = ContextCompat.getDrawable(context, R.drawable.ic_add_24dp)?.apply { isChipIconVisible = true @@ -254,14 +254,15 @@ private fun ChipGroup.setChips(items: List, scope: CoroutineScope) { } setOnClickListener { - var newTag: String? = null + var newTags: String? = null MaterialAlertDialogBuilder(context) - .setTitle(SYMR.strings.add_tag.getString(context)) - .setTextInput { - newTag = it.trimOrNull() - } + .setTitle(SYMR.strings.add_tags.getString(context)) + .setMessage(SYMR.strings.multi_tags_comma_separated.getString(context)) + .setTextInput { newTags = it.trimOrNull() } .setPositiveButton(MR.strings.action_ok.getString(context)) { _, _ -> - if (newTag != null) setChips(items + listOfNotNull(newTag), scope) + newTags?.let { + setChips(items + it.split(",").map { it.trimOrNull() }.filterNotNull(), scope) + } } .setNegativeButton(MR.strings.action_cancel.getString(context), null) .show() @@ -271,7 +272,7 @@ private fun ChipGroup.setChips(items: List, scope: CoroutineScope) { } private fun ChipGroup.getTextStrings(): List = children.mapNotNull { - if (it is Chip && !it.text.toString().contains(context.stringResource(SYMR.strings.add_tag), ignoreCase = true)) { + if (it is Chip && !it.text.toString().contains(context.stringResource(SYMR.strings.add_tags), ignoreCase = true)) { it.text.toString() } else { null diff --git a/i18n-sy/src/commonMain/moko-resources/base/strings.xml b/i18n-sy/src/commonMain/moko-resources/base/strings.xml index 05f6d333ed3e..40eb662a71bd 100644 --- a/i18n-sy/src/commonMain/moko-resources/base/strings.xml +++ b/i18n-sy/src/commonMain/moko-resources/base/strings.xml @@ -395,13 +395,14 @@ Reset Tags - Add Tag + Add Tags Reset Info Title: %1$s Description: %1$s Author: %1$s Artist: %1$s Thumbnail Url: %1$s + Enter tag(s), seperated by commas. @@ -437,6 +438,7 @@ Add %1$s to feed? + Add Tag Tag sorting tags Tag sorting Read this! Tags must be exact, there are no partial matches, you cannot do netorare to filter out female:netorare or similar!\nThe style for namespace tags is\n\"female: sole female\"\nwithout quotes!\nAdding multiple variants of the same tag is supported, so feel free to do \"tag: netorare\" for NHentai and \"female: netorare\" for E-Hentai!