Add cover actions to a dialog when long-pressing manga cover (#5556)
(cherry picked from commit a1e83b9f19844b8590d637f024cb2ee6550f6765)
This commit is contained in:
parent
6e45ed3c1d
commit
6e6d69b6b1
@ -1014,7 +1014,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun shareCover() {
|
fun shareCover() {
|
||||||
try {
|
try {
|
||||||
val activity = activity!!
|
val activity = activity!!
|
||||||
val cover = presenter.shareCover(activity)
|
val cover = presenter.shareCover(activity)
|
||||||
@ -1026,7 +1026,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveCover() {
|
fun saveCover() {
|
||||||
try {
|
try {
|
||||||
presenter.saveCover(activity!!)
|
presenter.saveCover(activity!!)
|
||||||
activity?.toast(R.string.cover_saved)
|
activity?.toast(R.string.cover_saved)
|
||||||
|
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import coil.loadAny
|
import coil.loadAny
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
@ -210,16 +211,34 @@ class MangaInfoHeaderAdapter(
|
|||||||
|
|
||||||
binding.mangaCover.longClicks()
|
binding.mangaCover.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
controller.activity?.copyToClipboard(
|
showCoverOptionsDialog()
|
||||||
view.context.getString(R.string.title),
|
|
||||||
controller.presenter.manga.title
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
.launchIn(controller.viewScope)
|
.launchIn(controller.viewScope)
|
||||||
|
|
||||||
setMangaInfo(manga, source)
|
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.
|
* Update the view with manga information.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user