Allow adding multiple tags separated by commas (#1282)

This commit is contained in:
NGB-Was-Taken 2024-10-15 02:19:58 +05:45 committed by GitHub
parent dee543c7c5
commit 41e523e074
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 9 deletions

View File

@ -246,7 +246,7 @@ private fun ChipGroup.setChips(items: List<String>, scope: CoroutineScope) {
} }
val addTagChip = Chip(context).apply { 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 { chipIcon = ContextCompat.getDrawable(context, R.drawable.ic_add_24dp)?.apply {
isChipIconVisible = true isChipIconVisible = true
@ -254,14 +254,15 @@ private fun ChipGroup.setChips(items: List<String>, scope: CoroutineScope) {
} }
setOnClickListener { setOnClickListener {
var newTag: String? = null var newTags: String? = null
MaterialAlertDialogBuilder(context) MaterialAlertDialogBuilder(context)
.setTitle(SYMR.strings.add_tag.getString(context)) .setTitle(SYMR.strings.add_tags.getString(context))
.setTextInput { .setMessage(SYMR.strings.multi_tags_comma_separated.getString(context))
newTag = it.trimOrNull() .setTextInput { newTags = it.trimOrNull() }
}
.setPositiveButton(MR.strings.action_ok.getString(context)) { _, _ -> .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) .setNegativeButton(MR.strings.action_cancel.getString(context), null)
.show() .show()
@ -271,7 +272,7 @@ private fun ChipGroup.setChips(items: List<String>, scope: CoroutineScope) {
} }
private fun ChipGroup.getTextStrings(): List<String> = children.mapNotNull { private fun ChipGroup.getTextStrings(): List<String> = 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() it.text.toString()
} else { } else {
null null

View File

@ -395,13 +395,14 @@
<!-- 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_tags">Add Tags</string>
<string name="reset_info">Reset Info</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>
<string name="artist_hint">Artist: %1$s</string> <string name="artist_hint">Artist: %1$s</string>
<string name="thumbnail_url_hint">Thumbnail Url: %1$s</string> <string name="thumbnail_url_hint">Thumbnail Url: %1$s</string>
<string name="multi_tags_comma_separated">Enter tag(s), seperated by commas.</string>
<!-- Browse --> <!-- Browse -->
<!-- Sources Tab --> <!-- Sources Tab -->
@ -437,6 +438,7 @@
<string name="feed_add">Add %1$s to feed?</string> <string name="feed_add">Add %1$s to feed?</string>
<!-- Sort by tags --> <!-- Sort by tags -->
<string name="add_tag">Add Tag</string>
<string name="pref_tag_sorting">Tag sorting tags</string> <string name="pref_tag_sorting">Tag sorting tags</string>
<string name="tag_sorting">Tag sorting</string> <string name="tag_sorting">Tag sorting</string>
<string name="action_add_tags_message">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!</string> <string name="action_add_tags_message">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!</string>