diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt index 90c0dc309..fa94338f6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt @@ -27,7 +27,6 @@ import nucleus.factory.RequiresPresenter import rx.Observable import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers -import java.util.* @RequiresPresenter(ChaptersPresenter::class) class ChaptersFragment : BaseRxFragment(), ActionMode.Callback, FlexibleViewHolder.OnListItemClickListener { @@ -217,23 +216,41 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac private fun showDownloadDialog() { // Get available modes - val modes = listOf(getString(R.string.download_all), getString(R.string.download_unread)) + val modes = listOf(getString(R.string.download_1), getString(R.string.download_5), getString(R.string.download_10), + getString(R.string.download_unread), getString(R.string.download_all)) MaterialDialog.Builder(activity) .title(R.string.manga_download) .negativeText(android.R.string.cancel) .items(modes) .itemsCallback { dialog, view, i, charSequence -> - val chapters = ArrayList() + var chapters: MutableList = arrayListOf() + // i = 0: Download 1 + // i = 1: Download 5 + // i = 2: Download 10 + // i = 3: Download unread + // i = 4: Download all for (chapter in presenter.chapters) { if (!chapter.isDownloaded) { - if (i == 0 || (i == 1 && !chapter.read)) { + if (i == 4 || (i != 4 && !chapter.read)) { chapters.add(chapter) } } } if (chapters.size > 0) { + when (i) { + // Set correct chapters size if desired + 0 -> chapters = chapters.subList(0, 1) + 1 -> { + if (chapters.size >= 5) + chapters = chapters.subList(0, 5) + } + 2 -> { + if (chapters.size >= 10) + chapters = chapters.subList(0, 10) + } + } onDownload(Observable.from(chapters)) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0e1d97fca..737ee66a4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -208,6 +208,9 @@ Show title Show chapter number Download + Download next chapter + Download next 5 chapters + Download next 10 chapters Download all Download unread