From 8362bf0886d5c12e2a588895d470098fedf68529 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 12 Sep 2021 13:01:53 -0400 Subject: [PATCH] Don't show option to delete chapters for local manga (closes #5243) --- .../ui/library/DeleteLibraryMangasDialog.kt | 15 +++++++++++++-- app/src/main/res/values/arrays.xml | 5 ----- 2 files changed, 13 insertions(+), 7 deletions(-) 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 aa0d437703..b60dc8b7bd 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 @@ -7,6 +7,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder 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.util.isLocal class DeleteLibraryMangasDialog(bundle: Bundle? = null) : DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener { @@ -19,7 +20,17 @@ class DeleteLibraryMangasDialog(bundle: Bundle? = null) : } override fun onCreateDialog(savedViewState: Bundle?): Dialog { - val items = resources!!.getStringArray(R.array.delete_selected_mangas) + val canDeleteChapters = mangas.any { !it.isLocal() } + val items = when (canDeleteChapters) { + true -> listOf( + R.string.manga_from_library, + R.string.downloaded_chapters, + ) + false -> listOf(R.string.manga_from_library) + } + .map { resources!!.getString(it) } + .toTypedArray() + val selected = items .mapIndexed { i, _ -> i == 0 } .toBooleanArray() @@ -30,7 +41,7 @@ class DeleteLibraryMangasDialog(bundle: Bundle? = null) : } .setPositiveButton(android.R.string.ok) { _, _ -> val deleteFromLibrary = selected[0] - val deleteChapters = selected[1] + val deleteChapters = canDeleteChapters && selected[1] (targetController as? Listener)?.deleteMangas(mangas, deleteFromLibrary, deleteChapters) } .setNegativeButton(android.R.string.cancel, null) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index b7ba2e3dbb..33da89d445 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -84,11 +84,6 @@ @string/tapping_inverted_both - - @string/manga_from_library - @string/downloaded_chapters - - @string/label_default @string/l_nav