mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Improvements + fixes to manga details actions modes
fix copy/share etc not working on description tapping on title/author will start global search when browsing from a source, in library will show the option of where to search long press on title/author/tags will copy to clipboard
This commit is contained in:
parent
03889d2c4b
commit
448db2362f
3 changed files with 30 additions and 6 deletions
|
@ -106,6 +106,7 @@ import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||||
import eu.kanade.tachiyomi.util.view.getText
|
import eu.kanade.tachiyomi.util.view.getText
|
||||||
import eu.kanade.tachiyomi.util.view.isControllerVisible
|
import eu.kanade.tachiyomi.util.view.isControllerVisible
|
||||||
|
import eu.kanade.tachiyomi.util.view.previousController
|
||||||
import eu.kanade.tachiyomi.util.view.requestFilePermissionsSafe
|
import eu.kanade.tachiyomi.util.view.requestFilePermissionsSafe
|
||||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||||
|
@ -1414,8 +1415,14 @@ class MangaDetailsController :
|
||||||
|
|
||||||
override fun showFloatingActionMode(view: TextView, content: String?, searchSource: Boolean) {
|
override fun showFloatingActionMode(view: TextView, content: String?, searchSource: Boolean) {
|
||||||
finishFloatingActionMode()
|
finishFloatingActionMode()
|
||||||
|
val previousController = previousController
|
||||||
|
if (!searchSource && previousController !is LibraryController && previousController !is RecentsController) {
|
||||||
|
globalSearch(content ?: view.text.toString())
|
||||||
|
return
|
||||||
|
}
|
||||||
val actionModeCallback = if (content != null) FloatingMangaDetailsActionModeCallback(
|
val actionModeCallback = if (content != null) FloatingMangaDetailsActionModeCallback(
|
||||||
content,
|
content,
|
||||||
|
showCopy = view is Chip,
|
||||||
searchSource = searchSource,
|
searchSource = searchSource,
|
||||||
)
|
)
|
||||||
else FloatingMangaDetailsActionModeCallback(view, searchSource = searchSource)
|
else FloatingMangaDetailsActionModeCallback(view, searchSource = searchSource)
|
||||||
|
@ -1427,7 +1434,7 @@ class MangaDetailsController :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun customActionMode(view: TextView): android.view.ActionMode.Callback {
|
override fun customActionMode(view: TextView): android.view.ActionMode.Callback {
|
||||||
return FloatingMangaDetailsActionModeCallback(view, false)
|
return FloatingMangaDetailsActionModeCallback(view, false, closeMode = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showChapterFilter() {
|
override fun showChapterFilter() {
|
||||||
|
@ -1713,12 +1720,14 @@ class MangaDetailsController :
|
||||||
private val textView: TextView?,
|
private val textView: TextView?,
|
||||||
private val showCopy: Boolean = true,
|
private val showCopy: Boolean = true,
|
||||||
private val searchSource: Boolean = false,
|
private val searchSource: Boolean = false,
|
||||||
|
private val closeMode: Boolean = true,
|
||||||
) : android.view.ActionMode.Callback {
|
) : android.view.ActionMode.Callback {
|
||||||
constructor(
|
constructor(
|
||||||
text: String,
|
text: String,
|
||||||
showCopy: Boolean = true,
|
showCopy: Boolean = true,
|
||||||
searchSource: Boolean = false,
|
searchSource: Boolean = false,
|
||||||
) : this(null, showCopy, searchSource) {
|
closeMode: Boolean = true,
|
||||||
|
) : this(null, showCopy, searchSource, closeMode) {
|
||||||
customText = text
|
customText = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,9 +1750,8 @@ class MangaDetailsController :
|
||||||
val sourceMenuItem = menu?.findItem(R.id.action_source_search)
|
val sourceMenuItem = menu?.findItem(R.id.action_source_search)
|
||||||
sourceMenuItem?.isVisible = searchSource && presenter.source is CatalogueSource
|
sourceMenuItem?.isVisible = searchSource && presenter.source is CatalogueSource
|
||||||
val context = view?.context ?: return false
|
val context = view?.context ?: return false
|
||||||
val prevController = router.backstack.getOrNull(router.backstackSize - 2)?.controller
|
|
||||||
val localItem = menu?.findItem(R.id.action_local_search) ?: return true
|
val localItem = menu?.findItem(R.id.action_local_search) ?: return true
|
||||||
localItem.isVisible = when (prevController) {
|
localItem.isVisible = when (previousController) {
|
||||||
is LibraryController, is RecentsController -> true
|
is LibraryController, is RecentsController -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
@ -1769,8 +1777,9 @@ class MangaDetailsController :
|
||||||
R.id.action_global_search -> globalSearch(text)
|
R.id.action_global_search -> globalSearch(text)
|
||||||
R.id.action_source_search -> sourceSearch(text)
|
R.id.action_source_search -> sourceSearch(text)
|
||||||
R.id.action_local_search -> localSearch(text)
|
R.id.action_local_search -> localSearch(text)
|
||||||
|
else -> return false
|
||||||
}
|
}
|
||||||
if (showCopy) {
|
if (closeMode) {
|
||||||
mode?.finish()
|
mode?.finish()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -133,11 +133,23 @@ class MangaHeaderHolder(
|
||||||
adapter.delegate.showFloatingActionMode(view as TextView, it)
|
adapter.delegate.showFloatingActionMode(view as TextView, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
title.setOnLongClickListener {
|
||||||
|
title.text?.toString()?.toNormalized()?.let {
|
||||||
|
adapter.delegate.copyToClipboard(it, R.string.title)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
mangaAuthor.setOnClickListener { view ->
|
mangaAuthor.setOnClickListener { view ->
|
||||||
mangaAuthor.text?.toString()?.let {
|
mangaAuthor.text?.toString()?.let {
|
||||||
adapter.delegate.showFloatingActionMode(view as TextView, it)
|
adapter.delegate.showFloatingActionMode(view as TextView, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mangaAuthor.setOnLongClickListener {
|
||||||
|
mangaAuthor.text?.toString()?.let {
|
||||||
|
adapter.delegate.copyToClipboard(it, R.string.author)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
mangaSummary.customSelectionActionModeCallback = adapter.delegate.customActionMode(mangaSummary)
|
mangaSummary.customSelectionActionModeCallback = adapter.delegate.customActionMode(mangaSummary)
|
||||||
applyBlur()
|
applyBlur()
|
||||||
mangaCover.setOnClickListener { adapter.delegate.zoomImageFromThumb(coverCard) }
|
mangaCover.setOnClickListener { adapter.delegate.zoomImageFromThumb(coverCard) }
|
||||||
|
@ -500,7 +512,7 @@ class MangaHeaderHolder(
|
||||||
adapter.delegate.showFloatingActionMode(chip, searchSource = true)
|
adapter.delegate.showFloatingActionMode(chip, searchSource = true)
|
||||||
}
|
}
|
||||||
chip.setOnLongClickListener {
|
chip.setOnLongClickListener {
|
||||||
adapter.delegate.showFloatingActionMode(chip, searchSource = true)
|
adapter.delegate.copyToClipboard(genreText, genreText)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
this.addView(chip)
|
this.addView(chip)
|
||||||
|
|
|
@ -746,6 +746,9 @@ val Controller.fullAppBarHeight: Int?
|
||||||
val Controller.isControllerVisible: Boolean
|
val Controller.isControllerVisible: Boolean
|
||||||
get() = router.backstack.lastOrNull()?.controller == this
|
get() = router.backstack.lastOrNull()?.controller == this
|
||||||
|
|
||||||
|
val Controller.previousController: Controller?
|
||||||
|
get() = router.backstack.getOrNull(router.backstackSize - 2)?.controller
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
fun Router.canStillGoBack(): Boolean {
|
fun Router.canStillGoBack(): Boolean {
|
||||||
if (backstack.size > 1) return true
|
if (backstack.size > 1) return true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue