Download dialog in chapters removed, now using submenu
This commit is contained in:
parent
81eaf8bb95
commit
a253c255e8
@ -47,7 +47,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 {
|
||||||
|
|
||||||
@ -193,7 +192,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
|
||||||
@ -526,10 +529,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 }
|
||||||
@ -547,23 +546,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.afollestad.materialdialogs.list.listItems
|
|
||||||
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(activity)
|
|
||||||
.title(R.string.manga_download)
|
|
||||||
.negativeButton(android.R.string.cancel)
|
|
||||||
.listItems(items = choices){dialog, position, _ ->
|
|
||||||
(targetController as? Listener)?.downloadChapters(position)
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 >
|
||||||
|
<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>
|
</menu>
|
Loading…
Reference in New Issue
Block a user