mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-12 21:35:18 +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,37 +988,71 @@ 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) {
|
||||||
if (!manga.favorite) {
|
toggleMangaFavorite()
|
||||||
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 {
|
} else {
|
||||||
if (!manga.favorite) {
|
val headerHolder = getHeader() ?: return
|
||||||
toggleMangaFavorite()
|
val popup = PopupMenu(view!!.context, headerHolder.favorite_button)
|
||||||
} else {
|
popup.menu.add(0, 1, 0, R.string.remove_from_library)
|
||||||
val headerHolder = getHeader() ?: return
|
if (categories.isNotEmpty()) {
|
||||||
val popup = PopupMenu(view!!.context, headerHolder.favorite_button)
|
popup.menu.add(0, 0, 1, R.string.edit_categories)
|
||||||
popup.menu.add(R.string.remove_from_library)
|
|
||||||
|
|
||||||
// Set a listener so we are notified if a menu item is clicked
|
|
||||||
popup.setOnMenuItemClickListener {
|
|
||||||
toggleMangaFavorite()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
popup.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
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() {
|
||||||
if (presenter.toggleFavorite()) {
|
if (presenter.toggleFavorite()) {
|
||||||
val categories = presenter.getCategories()
|
val categories = presenter.getCategories()
|
||||||
|
@ -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