Преглед на файлове

Don't show option to delete chapters for local manga (closes #5243)

arkon преди 3 години
родител
ревизия
8362bf0886
променени са 2 файла, в които са добавени 13 реда и са изтрити 7 реда
  1. 13 2
      app/src/main/java/eu/kanade/tachiyomi/ui/library/DeleteLibraryMangasDialog.kt
  2. 0 5
      app/src/main/res/values/arrays.xml

+ 13 - 2
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<T>(bundle: Bundle? = null) :
     DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener {
@@ -19,7 +20,17 @@ class DeleteLibraryMangasDialog<T>(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<T>(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)

+ 0 - 5
app/src/main/res/values/arrays.xml

@@ -84,11 +84,6 @@
         <item>@string/tapping_inverted_both</item>
     </string-array>
 
-    <string-array name="delete_selected_mangas">
-        <item>@string/manga_from_library</item>
-        <item>@string/downloaded_chapters</item>
-    </string-array>
-
     <string-array name="pager_nav">
         <item>@string/label_default</item>
         <item>@string/l_nav</item>