mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 04:45:07 +01: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
@ -123,5 +123,6 @@ class MangaDetailsAdapter(
|
|||||||
fun zoomImageFromThumb(thumbView: View)
|
fun zoomImageFromThumb(thumbView: View)
|
||||||
fun showTrackingSheet()
|
fun showTrackingSheet()
|
||||||
fun updateScroll()
|
fun updateScroll()
|
||||||
|
fun setFavButtonPopup(popupView: View)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,35 +988,69 @@ class MangaDetailsController : BaseController,
|
|||||||
if (isLocked()) return
|
if (isLocked()) return
|
||||||
val manga = presenter.manga
|
val manga = presenter.manga
|
||||||
val categories = presenter.getCategories()
|
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) {
|
if (!manga.favorite) {
|
||||||
toggleMangaFavorite()
|
toggleMangaFavorite()
|
||||||
} else {
|
} else {
|
||||||
val headerHolder = getHeader() ?: return
|
val headerHolder = getHeader() ?: return
|
||||||
val popup = PopupMenu(view!!.context, headerHolder.favorite_button)
|
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
|
// 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()
|
toggleMangaFavorite()
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
popup.show()
|
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() {
|
private fun toggleMangaFavorite() {
|
||||||
|
@ -71,10 +71,6 @@ class MangaHeaderHolder(
|
|||||||
favorite_button.setOnClickListener {
|
favorite_button.setOnClickListener {
|
||||||
adapter.delegate.favoriteManga(false)
|
adapter.delegate.favoriteManga(false)
|
||||||
}
|
}
|
||||||
favorite_button.setOnLongClickListener {
|
|
||||||
adapter.delegate.favoriteManga(true)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
title.setOnClickListener {
|
title.setOnClickListener {
|
||||||
title.text?.let { adapter.delegate.globalSearch(it.toString()) }
|
title.text?.let { adapter.delegate.globalSearch(it.toString()) }
|
||||||
}
|
}
|
||||||
@ -182,6 +178,7 @@ class MangaHeaderHolder(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
checked(!item.isLocked && manga.favorite)
|
checked(!item.isLocked && manga.favorite)
|
||||||
|
adapter.delegate.setFavButtonPopup(this)
|
||||||
}
|
}
|
||||||
true_backdrop.setBackgroundColor(
|
true_backdrop.setBackgroundColor(
|
||||||
adapter.delegate.coverColor()
|
adapter.delegate.coverColor()
|
||||||
|
Loading…
Reference in New Issue
Block a user