mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Don't show option to delete chapters for local manga (closes #5243)
This commit is contained in:
parent
1a8155c45b
commit
8362bf0886
2 changed files with 13 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue