mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Changed long press for fav button in library inside the popup menu for said button
also you can drag on the fav button to open the popup menu
This commit is contained in:
parent
0670e00a09
commit
198cf86377
3 changed files with 62 additions and 30 deletions
|
@ -123,5 +123,6 @@ class MangaDetailsAdapter(
|
|||
fun zoomImageFromThumb(thumbView: View)
|
||||
fun showTrackingSheet()
|
||||
fun updateScroll()
|
||||
fun setFavButtonPopup(popupView: View)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -988,35 +988,69 @@ class MangaDetailsController : BaseController,
|
|||
if (isLocked()) return
|
||||
val manga = presenter.manga
|
||||
val categories = presenter.getCategories()
|
||||
if (longPress && categories.isNotEmpty()) {
|
||||
if (!manga.favorite) {
|
||||
presenter.toggleFavorite()
|
||||
showAddedSnack()
|
||||
}
|
||||
val ids = presenter.getMangaCategoryIds()
|
||||
val preselected = ids.mapNotNull { id ->
|
||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||
}.toTypedArray()
|
||||
|
||||
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected).showDialog(
|
||||
router
|
||||
)
|
||||
} else {
|
||||
if (!manga.favorite) {
|
||||
toggleMangaFavorite()
|
||||
} else {
|
||||
val headerHolder = getHeader() ?: return
|
||||
val popup = PopupMenu(view!!.context, headerHolder.favorite_button)
|
||||
popup.menu.add(R.string.remove_from_library)
|
||||
popup.menu.add(0, 1, 0, R.string.remove_from_library)
|
||||
if (categories.isNotEmpty()) {
|
||||
popup.menu.add(0, 0, 1, R.string.edit_categories)
|
||||
}
|
||||
|
||||
// Set a listener so we are notified if a menu item is clicked
|
||||
popup.setOnMenuItemClickListener {
|
||||
popup.setOnMenuItemClickListener { menuItem ->
|
||||
if (menuItem.itemId == 0) {
|
||||
val ids = presenter.getMangaCategoryIds()
|
||||
val preselected = ids.mapNotNull { id ->
|
||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||
}.toTypedArray()
|
||||
ChangeMangaCategoriesDialog(
|
||||
this, listOf(manga), categories, preselected
|
||||
).showDialog(
|
||||
router
|
||||
)
|
||||
} else {
|
||||
toggleMangaFavorite()
|
||||
}
|
||||
true
|
||||
}
|
||||
popup.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setFavButtonPopup(popupView: View) {
|
||||
if (isLocked()) return
|
||||
val manga = presenter.manga
|
||||
if (!manga.favorite) {
|
||||
popupView.setOnTouchListener(null)
|
||||
return
|
||||
}
|
||||
val popup = PopupMenu(view!!.context, popupView)
|
||||
val categories = presenter.getCategories()
|
||||
popup.menu.add(0, 1, 0, R.string.remove_from_library)
|
||||
if (categories.isNotEmpty()) {
|
||||
popup.menu.add(0, 0, 1, R.string.edit_categories)
|
||||
}
|
||||
|
||||
// Set a listener so we are notified if a menu item is clicked
|
||||
popup.setOnMenuItemClickListener { menuItem ->
|
||||
if (menuItem.itemId == 0) {
|
||||
val ids = presenter.getMangaCategoryIds()
|
||||
val preselected = ids.mapNotNull { id ->
|
||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||
}.toTypedArray()
|
||||
ChangeMangaCategoriesDialog(
|
||||
this, listOf(manga), categories, preselected
|
||||
).showDialog(
|
||||
router
|
||||
)
|
||||
} else {
|
||||
toggleMangaFavorite()
|
||||
}
|
||||
true
|
||||
}
|
||||
popupView.setOnTouchListener(popup.dragToOpenListener)
|
||||
}
|
||||
|
||||
private fun toggleMangaFavorite() {
|
||||
|
|
|
@ -71,10 +71,6 @@ class MangaHeaderHolder(
|
|||
favorite_button.setOnClickListener {
|
||||
adapter.delegate.favoriteManga(false)
|
||||
}
|
||||
favorite_button.setOnLongClickListener {
|
||||
adapter.delegate.favoriteManga(true)
|
||||
true
|
||||
}
|
||||
title.setOnClickListener {
|
||||
title.text?.let { adapter.delegate.globalSearch(it.toString()) }
|
||||
}
|
||||
|
@ -182,6 +178,7 @@ class MangaHeaderHolder(
|
|||
}
|
||||
)
|
||||
checked(!item.isLocked && manga.favorite)
|
||||
adapter.delegate.setFavButtonPopup(this)
|
||||
}
|
||||
true_backdrop.setBackgroundColor(
|
||||
adapter.delegate.coverColor()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue