Skip to content

Commit

Permalink
Allow adding multiple tags separated by commas
Browse files Browse the repository at this point in the history
  • Loading branch information
NGB-Was-Taken authored Oct 12, 2024
1 parent dea3891 commit 3c50f9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,23 @@ 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
setTint(context.getResourceColor(R.attr.colorAccent))
}

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()
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion i18n-sy/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 3c50f9d

Please sign in to comment.