mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Split author and artist when searching in manga
This commit is contained in:
parent
3140361452
commit
1f51629330
5 changed files with 75 additions and 10 deletions
|
@ -38,6 +38,10 @@ interface SManga : Serializable {
|
|||
val originalStatus: Int
|
||||
get() = (this as? MangaImpl)?.ogStatus ?: status
|
||||
|
||||
val hasSameAuthorAndArtist: Boolean
|
||||
get() = author == artist || artist.isNullOrBlank() ||
|
||||
author?.contains(artist ?: "", true) == true
|
||||
|
||||
fun copyFrom(other: SManga) {
|
||||
if (other.author != null) {
|
||||
author = other.originalAuthor
|
||||
|
|
|
@ -1488,7 +1488,11 @@ class MangaDetailsController :
|
|||
override fun showFloatingActionMode(view: TextView, content: String?, isTag: Boolean) {
|
||||
finishFloatingActionMode()
|
||||
val previousController = previousController
|
||||
if (!isTag && previousController !is LibraryController && previousController !is RecentsController) {
|
||||
val hasDifferentAuthors = view.id == R.id.manga_author &&
|
||||
manga?.hasSameAuthorAndArtist == false && manga?.author != null
|
||||
val isInSource = !isTag && previousController !is LibraryController &&
|
||||
previousController !is RecentsController
|
||||
if (!hasDifferentAuthors && isInSource) {
|
||||
globalSearch(content ?: view.text.toString())
|
||||
return
|
||||
}
|
||||
|
@ -1501,6 +1505,13 @@ class MangaDetailsController :
|
|||
} else {
|
||||
FloatingMangaDetailsActionModeCallback(view, isTag = isTag)
|
||||
}
|
||||
if (hasDifferentAuthors) {
|
||||
actionModeCallback.authorText = manga?.author
|
||||
actionModeCallback.artistText = manga?.artist
|
||||
if (isInSource) {
|
||||
actionModeCallback.isGlobalSearch = true
|
||||
}
|
||||
}
|
||||
if (view is Chip) {
|
||||
view.isActivated = true
|
||||
}
|
||||
|
@ -1821,7 +1832,10 @@ class MangaDetailsController :
|
|||
customText = text
|
||||
}
|
||||
|
||||
var customText: String? = null
|
||||
private var customText: String? = null
|
||||
var authorText: String? = null
|
||||
var artistText: String? = null
|
||||
var isGlobalSearch: Boolean? = null
|
||||
val text: String
|
||||
get() {
|
||||
return customText ?: if (textView?.isTextSelectable == true) {
|
||||
|
@ -1845,6 +1859,14 @@ class MangaDetailsController :
|
|||
val library = context.getString(R.string.library).lowercase(Locale.getDefault())
|
||||
localItem.title = context.getString(R.string.search_, library)
|
||||
sourceMenuItem?.title = context.getString(R.string.search_, presenter.source.name)
|
||||
menu.findItem(R.id.action_search_author)?.title = context.getString(
|
||||
R.string.search_,
|
||||
context.getString(R.string.author).lowercase(Locale.getDefault()),
|
||||
)
|
||||
menu.findItem(R.id.action_search_artist)?.title = context.getString(
|
||||
R.string.search_,
|
||||
context.getString(R.string.artist).lowercase(Locale.getDefault()),
|
||||
)
|
||||
if (isTag) {
|
||||
if (previousController is BrowseSourceController) {
|
||||
menu.removeItem(R.id.action_source_search)
|
||||
|
@ -1866,9 +1888,34 @@ class MangaDetailsController :
|
|||
): Boolean {
|
||||
when (item?.itemId) {
|
||||
R.id.action_copy -> copyToClipboard(text, null)
|
||||
R.id.action_global_search -> globalSearch(text)
|
||||
R.id.action_source_search -> sourceSearch(text)
|
||||
R.id.action_local_search -> localSearch(text, isTag)
|
||||
R.id.action_global_search, R.id.action_local_search -> {
|
||||
if (authorText != null) {
|
||||
mode?.menu?.findItem(R.id.action_copy)?.isVisible = false
|
||||
mode?.menu?.findItem(R.id.action_local_search)?.isVisible = false
|
||||
mode?.menu?.findItem(R.id.action_source_search)?.isVisible = false
|
||||
mode?.menu?.findItem(R.id.action_global_search)?.isVisible = false
|
||||
mode?.menu?.findItem(R.id.action_search_author)?.isVisible = true
|
||||
mode?.menu?.findItem(R.id.action_search_artist)?.isVisible = true
|
||||
isGlobalSearch = item.itemId == R.id.action_global_search
|
||||
mode?.invalidate()
|
||||
return true
|
||||
} else if (item.itemId == R.id.action_global_search) {
|
||||
globalSearch(text)
|
||||
} else {
|
||||
localSearch(text, isTag)
|
||||
}
|
||||
}
|
||||
R.id.action_search_artist, R.id.action_search_author -> {
|
||||
val subText =
|
||||
(if (item.itemId == R.id.action_search_author) authorText else artistText)
|
||||
?: return false
|
||||
if (isGlobalSearch == true) {
|
||||
globalSearch(subText)
|
||||
} else {
|
||||
localSearch(subText, isTag)
|
||||
}
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
if (closeMode) {
|
||||
|
|
|
@ -309,9 +309,7 @@ class MangaHeaderHolder(
|
|||
|
||||
setGenreTags(binding, manga)
|
||||
|
||||
if (manga.author == manga.artist || manga.artist.isNullOrBlank() ||
|
||||
manga.author?.contains(manga.artist ?: "", true) == true
|
||||
) {
|
||||
if (manga.hasSameAuthorAndArtist) {
|
||||
binding.mangaAuthor.text = manga.author?.trim()
|
||||
} else {
|
||||
binding.mangaAuthor.text = listOfNotNull(manga.author?.trim(), manga.artist?.trim()).joinToString(", ")
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_copy"
|
||||
android:icon="@drawable/ic_done_all_24dp"
|
||||
android:icon="@drawable/ic_content_copy_24dp"
|
||||
android:orderInCategory="0"
|
||||
android:title="@string/copy_value"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
<item
|
||||
android:id="@+id/action_source_search"
|
||||
android:icon="@drawable/ic_extension_update_24dp"
|
||||
android:icon="@drawable/ic_search_24dp"
|
||||
android:orderInCategory="3"
|
||||
android:title="@string/search"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_copy"
|
||||
android:icon="@drawable/ic_done_all_24dp"
|
||||
android:icon="@drawable/ic_content_copy_24dp"
|
||||
android:title="@string/copy_value"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
|
@ -16,4 +16,20 @@
|
|||
android:icon="@drawable/ic_search_24dp"
|
||||
android:title="@string/search"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search_author"
|
||||
android:icon="@drawable/ic_author_24dp"
|
||||
android:orderInCategory="5"
|
||||
android:visible="false"
|
||||
android:title="@string/search"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search_artist"
|
||||
android:icon="@drawable/ic_author_24dp"
|
||||
android:orderInCategory="6"
|
||||
android:visible="false"
|
||||
android:title="@string/search"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
Loading…
Add table
Add a link
Reference in a new issue