Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding multiple tags separated by commas #1282

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading