Download dialog in chapters removed, now using submenu
(cherry picked from commit a253c255e8e1ee0cc0e158c3bf61f5352b06e656)
This commit is contained in:
parent
4b84fb5ac5
commit
81c14ba610
@ -36,7 +36,6 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
ChaptersAdapter.OnMenuItemClickListener,
|
ChaptersAdapter.OnMenuItemClickListener,
|
||||||
SetDisplayModeDialog.Listener,
|
SetDisplayModeDialog.Listener,
|
||||||
SetSortingDialog.Listener,
|
SetSortingDialog.Listener,
|
||||||
DownloadChaptersDialog.Listener,
|
|
||||||
DownloadCustomChaptersDialog.Listener,
|
DownloadCustomChaptersDialog.Listener,
|
||||||
DeleteChaptersDialog.Listener {
|
DeleteChaptersDialog.Listener {
|
||||||
|
|
||||||
@ -153,7 +152,11 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_display_mode -> showDisplayModeDialog()
|
R.id.action_display_mode -> showDisplayModeDialog()
|
||||||
R.id.manga_download -> showDownloadDialog()
|
|
||||||
|
R.id.download_next, R.id.download_next_5, R.id.download_next_10,
|
||||||
|
R.id.download_custom, R.id.download_unread, R.id.download_all
|
||||||
|
-> downloadChapters(item.itemId)
|
||||||
|
|
||||||
R.id.action_sorting_mode -> showSortingDialog()
|
R.id.action_sorting_mode -> showSortingDialog()
|
||||||
R.id.action_filter_unread -> {
|
R.id.action_filter_unread -> {
|
||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
@ -472,10 +475,6 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
presenter.setSorting(id)
|
presenter.setSorting(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showDownloadDialog() {
|
|
||||||
DownloadChaptersDialog(this).showDialog(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getUnreadChaptersSorted() = presenter.chapters
|
private fun getUnreadChaptersSorted() = presenter.chapters
|
||||||
.filter { !it.read && it.status == Download.NOT_DOWNLOADED }
|
.filter { !it.read && it.status == Download.NOT_DOWNLOADED }
|
||||||
.distinctBy { it.name }
|
.distinctBy { it.name }
|
||||||
@ -493,23 +492,17 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun downloadChapters(choice: Int) {
|
private fun downloadChapters(choice: Int) {
|
||||||
// i = 0: Download 1
|
|
||||||
// i = 1: Download 5
|
|
||||||
// i = 2: Download 10
|
|
||||||
// i = 3: Download x
|
|
||||||
// i = 4: Download unread
|
|
||||||
// i = 5: Download all
|
|
||||||
val chaptersToDownload = when (choice) {
|
val chaptersToDownload = when (choice) {
|
||||||
0 -> getUnreadChaptersSorted().take(1)
|
R.id.download_next -> getUnreadChaptersSorted().take(1)
|
||||||
1 -> getUnreadChaptersSorted().take(5)
|
R.id.download_next_5 -> getUnreadChaptersSorted().take(5)
|
||||||
2 -> getUnreadChaptersSorted().take(10)
|
R.id.download_next_10 -> getUnreadChaptersSorted().take(10)
|
||||||
3 -> {
|
R.id.download_custom -> {
|
||||||
showCustomDownloadDialog()
|
showCustomDownloadDialog()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
4 -> presenter.chapters.filter { !it.read }
|
R.id.download_unread -> presenter.chapters.filter { !it.read }
|
||||||
5 -> presenter.chapters
|
R.id.download_all -> presenter.chapters
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
if (chaptersToDownload.isNotEmpty()) {
|
if (chaptersToDownload.isNotEmpty()) {
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.bluelinelabs.conductor.Controller
|
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
|
||||||
|
|
||||||
class DownloadChaptersDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
|
||||||
where T : Controller, T : DownloadChaptersDialog.Listener {
|
|
||||||
|
|
||||||
constructor(target: T) : this() {
|
|
||||||
targetController = target
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
|
||||||
val activity = activity!!
|
|
||||||
|
|
||||||
val choices = intArrayOf(
|
|
||||||
R.string.download_1,
|
|
||||||
R.string.download_5,
|
|
||||||
R.string.download_10,
|
|
||||||
R.string.download_custom,
|
|
||||||
R.string.download_unread,
|
|
||||||
R.string.download_all
|
|
||||||
).map { activity.getString(it) }
|
|
||||||
|
|
||||||
return MaterialDialog.Builder(activity)
|
|
||||||
.title(R.string.manga_download)
|
|
||||||
.negativeText(android.R.string.cancel)
|
|
||||||
.items(choices)
|
|
||||||
.itemsCallback { _, _, position, _ ->
|
|
||||||
(targetController as? Listener)?.downloadChapters(position)
|
|
||||||
}
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Listener {
|
|
||||||
fun downloadChapters(choice: Int)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -49,5 +49,26 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/manga_download"
|
android:id="@+id/manga_download"
|
||||||
android:title="@string/manga_download"
|
android:title="@string/manga_download"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never">
|
||||||
</menu>
|
<menu>
|
||||||
|
<item
|
||||||
|
android:id="@+id/download_next"
|
||||||
|
android:title="@string/download_1" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/download_next_5"
|
||||||
|
android:title="@string/download_5" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/download_next_10"
|
||||||
|
android:title="@string/download_10" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/download_custom"
|
||||||
|
android:title="@string/download_custom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/download_unread"
|
||||||
|
android:title="@string/download_unread" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/download_all"
|
||||||
|
android:title="@string/download_all" />
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user