Allow adding multiple tags separated by commas (#1282)
This commit is contained in:
parent
dee543c7c5
commit
41e523e074
@ -246,7 +246,7 @@ private fun ChipGroup.setChips(items: List<String>, 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<String>, 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<String>, scope: CoroutineScope) {
|
||||
}
|
||||
|
||||
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()
|
||||
} else {
|
||||
null
|
||||
|
@ -395,13 +395,14 @@
|
||||
|
||||
<!-- Entry Info Edit -->
|
||||
<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="title_hint">Title: %1$s</string>
|
||||
<string name="description_hint">Description: %1$s</string>
|
||||
<string name="author_hint">Author: %1$s</string>
|
||||
<string name="artist_hint">Artist: %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 -->
|
||||
<!-- Sources Tab -->
|
||||
@ -437,6 +438,7 @@
|
||||
<string name="feed_add">Add %1$s to feed?</string>
|
||||
|
||||
<!-- Sort by tags -->
|
||||
<string name="add_tag">Add Tag</string>
|
||||
<string name="pref_tag_sorting">Tag sorting tags</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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user