mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 03:01:52 +01:00
Add cover actions to a dialog when long-pressing manga cover (#5556)
This commit is contained in:
parent
4ce4ee3c00
commit
a1e83b9f19
@ -661,7 +661,7 @@ class MangaController :
|
||||
}
|
||||
}
|
||||
|
||||
private fun shareCover() {
|
||||
fun shareCover() {
|
||||
try {
|
||||
val activity = activity!!
|
||||
val cover = presenter.shareCover(activity)
|
||||
@ -673,7 +673,7 @@ class MangaController :
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveCover() {
|
||||
fun saveCover() {
|
||||
try {
|
||||
presenter.saveCover(activity!!)
|
||||
activity?.toast(R.string.cover_saved)
|
||||
@ -683,7 +683,7 @@ class MangaController :
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeCover() {
|
||||
fun changeCover() {
|
||||
val manga = manga ?: return
|
||||
if (manga.hasCustomCover(coverCache)) {
|
||||
ChangeMangaCoverDialog(this, manga).showDialog(router)
|
||||
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.loadAny
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
@ -177,16 +178,34 @@ class MangaInfoHeaderAdapter(
|
||||
|
||||
binding.mangaCover.longClicks()
|
||||
.onEach {
|
||||
controller.activity?.copyToClipboard(
|
||||
view.context.getString(R.string.title),
|
||||
controller.presenter.manga.title
|
||||
)
|
||||
showCoverOptionsDialog()
|
||||
}
|
||||
.launchIn(controller.viewScope)
|
||||
|
||||
setMangaInfo(manga, source)
|
||||
}
|
||||
|
||||
private fun showCoverOptionsDialog() {
|
||||
val options = listOfNotNull(
|
||||
R.string.action_share,
|
||||
R.string.action_save,
|
||||
// Can only edit cover for library manga
|
||||
if (manga.favorite) R.string.action_edit else null
|
||||
).map(controller.activity!!::getString).toTypedArray()
|
||||
|
||||
MaterialAlertDialogBuilder(controller.activity!!)
|
||||
.setTitle(R.string.manga_cover)
|
||||
.setItems(options) { _, item ->
|
||||
when (item) {
|
||||
0 -> controller.shareCover()
|
||||
1 -> controller.saveCover()
|
||||
2 -> controller.changeCover()
|
||||
}
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the view with manga information.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user