diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt index 969f19f57..4cd2f2bed 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt @@ -3,12 +3,11 @@ package eu.kanade.tachiyomi.ui.library import android.app.Dialog import android.os.Bundle import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.customview.customView +import com.afollestad.materialdialogs.list.listItemsMultiChoice import com.bluelinelabs.conductor.Controller import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.ui.base.controller.DialogController -import eu.kanade.tachiyomi.widget.DialogCheckboxView class DeleteLibraryMangasDialog(bundle: Bundle? = null) : DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener { @@ -21,25 +20,21 @@ class DeleteLibraryMangasDialog(bundle: Bundle? = null) : } override fun onCreateDialog(savedViewState: Bundle?): Dialog { - val view = DialogCheckboxView(activity!!).apply { - setDescription(R.string.confirm_delete_manga) - setOptionDescription(R.string.also_delete_chapters) - } - return MaterialDialog(activity!!) .title(R.string.action_remove) - .customView( - view = view, - horizontalPadding = true - ) - .positiveButton(android.R.string.ok) { - val deleteChapters = view.isChecked() - (targetController as? Listener)?.deleteMangasFromLibrary(mangas, deleteChapters) + .listItemsMultiChoice( + R.array.delete_selected_mangas, + initialSelection = intArrayOf(0) + ) { _, selections, _ -> + val deleteFromLibrary = 0 in selections + val deleteChapters = 1 in selections + (targetController as? Listener)?.deleteMangas(mangas, deleteFromLibrary, deleteChapters) } + .positiveButton(android.R.string.ok) .negativeButton(android.R.string.cancel) } interface Listener { - fun deleteMangasFromLibrary(mangas: List, deleteChapters: Boolean) + fun deleteMangas(mangas: List, deleteFromLibrary: Boolean, deleteChapters: Boolean) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 60cdfb936..8aa545f3d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -571,8 +571,8 @@ class LibraryController( destroyActionModeIfNeeded() } - override fun deleteMangasFromLibrary(mangas: List, deleteChapters: Boolean) { - presenter.removeMangaFromLibrary(mangas, deleteChapters) + override fun deleteMangas(mangas: List, deleteFromLibrary: Boolean, deleteChapters: Boolean) { + presenter.removeMangas(mangas, deleteFromLibrary, deleteChapters) destroyActionModeIfNeeded() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index e94530c14..7c99e69c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -371,20 +371,23 @@ class LibraryPresenter( } /** - * Remove the selected manga from the library. + * Remove the selected manga. * * @param mangas the list of manga to delete. - * @param deleteChapters whether to also delete downloaded chapters. + * @param deleteFromLibrary whether to delete manga from library. + * @param deleteChapters whether to delete downloaded chapters. */ - fun removeMangaFromLibrary(mangas: List, deleteChapters: Boolean) { + fun removeMangas(mangas: List, deleteFromLibrary: Boolean, deleteChapters: Boolean) { launchIO { val mangaToDelete = mangas.distinctBy { it.id } - mangaToDelete.forEach { - it.favorite = false - it.removeCovers(coverCache) + if (deleteFromLibrary) { + mangaToDelete.forEach { + it.favorite = false + it.removeCovers(coverCache) + } + db.insertMangas(mangaToDelete).executeAsBlocking() } - db.insertMangas(mangaToDelete).executeAsBlocking() if (deleteChapters) { mangaToDelete.forEach { manga -> diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index eacccb2d1..d5b49c175 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -86,4 +86,9 @@ @string/tapping_inverted_vertical @string/tapping_inverted_both + + + @string/manga_from_library + @string/downloaded_chapters + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6231321e5..ad558883c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -445,8 +445,8 @@ Title or author… Updating category Local - Are you sure you want to remove selected manga? - Also delete downloaded chapters + Manga from library + Downloaded chapters Badges Tabs