mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add edited manga tag when leaving the text field
or pressing done Also if someone enters multiple tags separated by commas, its now sorted out too Also also changed the return key to a done button in the touch screen keyboard Also also also this closes #1549
This commit is contained in:
parent
63f9ed84ab
commit
4334f2bdfc
2 changed files with 26 additions and 6 deletions
|
@ -194,17 +194,20 @@ class EditMangaDialog : DialogController {
|
|||
binding.addTagEditText.requestFocus()
|
||||
showKeyboard()
|
||||
}
|
||||
binding.addTagEditText.setOnFocusChangeListener { v, hasFocus ->
|
||||
if (!hasFocus && v.parent != null) {
|
||||
addTags()
|
||||
}
|
||||
}
|
||||
binding.addTagEditText.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
val tags: List<String> = binding.mangaGenresTags.tags.toList() + binding.addTagEditText.text.toString()
|
||||
setGenreTags(tags)
|
||||
binding.seriesType.setSelection(manga.seriesType(customTags = tags.joinToString(", ")) - 1)
|
||||
addTags(true)
|
||||
binding.addTagEditText.clearFocus()
|
||||
binding.addTagEditText.setText("")
|
||||
hideKeyboard()
|
||||
} else {
|
||||
binding.addTagChip.isVisible = true
|
||||
binding.addTagEditText.isVisible = false
|
||||
}
|
||||
binding.addTagChip.isVisible = true
|
||||
binding.addTagEditText.isVisible = false
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -221,6 +224,21 @@ class EditMangaDialog : DialogController {
|
|||
}
|
||||
}
|
||||
|
||||
private fun addTags(textCanBeBlank: Boolean = false) {
|
||||
if ((textCanBeBlank || !binding.addTagEditText.text.isNullOrBlank()) &&
|
||||
binding.addTagEditText.isVisible
|
||||
) {
|
||||
val newTags = binding.addTagEditText.text.toString().split(",")
|
||||
.mapNotNull { tag -> tag.trim().takeUnless { it.isBlank() } }
|
||||
val tags: List<String> = binding.mangaGenresTags.tags.toList() + newTags
|
||||
binding.addTagEditText.setText("")
|
||||
setGenreTags(tags)
|
||||
binding.seriesType.setSelection(manga.seriesType(customTags = tags.joinToString(", ")) - 1)
|
||||
binding.addTagChip.isVisible = true
|
||||
binding.addTagEditText.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun TachiyomiTextInputEditText.appendOriginalTextOnLongClick(originalText: String?) {
|
||||
setOnLongClickListener {
|
||||
if (this.text.isNullOrBlank()) {
|
||||
|
@ -339,6 +357,7 @@ class EditMangaDialog : DialogController {
|
|||
}
|
||||
|
||||
private fun onPositiveButtonClick() {
|
||||
addTags()
|
||||
infoController.presenter.updateManga(
|
||||
binding.title.text.toString(),
|
||||
binding.mangaAuthor.text.toString(),
|
||||
|
|
|
@ -151,6 +151,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:imeOptions="actionDone"
|
||||
android:importantForAutofill="no"
|
||||
android:hint="@string/add_tag"
|
||||
android:inputType="text"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue