mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-09-10 20:23:18 +02:00
Remove display/sorting mode dialogs
This commit is contained in:
parent
9baeb38177
commit
ff5169d7b9
@ -45,8 +45,6 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
FlexibleAdapter.OnItemClickListener,
|
||||
FlexibleAdapter.OnItemLongClickListener,
|
||||
ChaptersAdapter.OnMenuItemClickListener,
|
||||
SetDisplayModeDialog.Listener,
|
||||
SetSortingDialog.Listener,
|
||||
DownloadCustomChaptersDialog.Listener,
|
||||
DeleteChaptersDialog.Listener {
|
||||
|
||||
@ -187,17 +185,46 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
if (presenter.onlyUnread())
|
||||
//Disable read filter option if unread filter is enabled.
|
||||
menuFilterRead.isEnabled = false
|
||||
|
||||
// Display mode submenu
|
||||
if (presenter.manga.displayMode == Manga.DISPLAY_NAME) {
|
||||
menu.findItem(R.id.display_title).isChecked = true
|
||||
} else {
|
||||
menu.findItem(R.id.display_chapter_number).isChecked = true
|
||||
}
|
||||
|
||||
// Sorting mode submenu
|
||||
if (presenter.manga.sorting == Manga.SORTING_SOURCE) {
|
||||
menu.findItem(R.id.sort_by_source).isChecked = true
|
||||
} else {
|
||||
menu.findItem(R.id.sort_by_number).isChecked = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_display_mode -> showDisplayModeDialog()
|
||||
R.id.display_title -> {
|
||||
item.isChecked = true
|
||||
setDisplayMode(Manga.DISPLAY_NAME)
|
||||
}
|
||||
R.id.display_chapter_number -> {
|
||||
item.isChecked = true
|
||||
setDisplayMode(Manga.DISPLAY_NUMBER)
|
||||
}
|
||||
|
||||
R.id.sort_by_source -> {
|
||||
item.isChecked = true
|
||||
presenter.setSorting(Manga.SORTING_SOURCE)
|
||||
}
|
||||
R.id.sort_by_number -> {
|
||||
item.isChecked = true
|
||||
presenter.setSorting(Manga.SORTING_NUMBER)
|
||||
}
|
||||
|
||||
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_filter_unread -> {
|
||||
item.isChecked = !item.isChecked
|
||||
presenter.setUnreadFilter(item.isChecked)
|
||||
@ -510,42 +537,16 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
|
||||
// OVERFLOW MENU DIALOGS
|
||||
|
||||
private fun showDisplayModeDialog() {
|
||||
val preselected = if (presenter.manga.displayMode == Manga.DISPLAY_NAME) 0 else 1
|
||||
SetDisplayModeDialog(this, preselected).showDialog(router)
|
||||
}
|
||||
|
||||
override fun setDisplayMode(id: Int) {
|
||||
private fun setDisplayMode(id: Int) {
|
||||
presenter.setDisplayMode(id)
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun showSortingDialog() {
|
||||
val preselected = if (presenter.manga.sorting == Manga.SORTING_SOURCE) 0 else 1
|
||||
SetSortingDialog(this, preselected).showDialog(router)
|
||||
}
|
||||
|
||||
override fun setSorting(id: Int) {
|
||||
presenter.setSorting(id)
|
||||
}
|
||||
|
||||
private fun getUnreadChaptersSorted() = presenter.chapters
|
||||
.filter { !it.read && it.status == Download.NOT_DOWNLOADED }
|
||||
.distinctBy { it.name }
|
||||
.sortedByDescending { it.source_order }
|
||||
|
||||
override fun downloadCustomChapters(amount: Int) {
|
||||
val chaptersToDownload = getUnreadChaptersSorted().take(amount)
|
||||
if (chaptersToDownload.isNotEmpty()) {
|
||||
downloadChapters(chaptersToDownload)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCustomDownloadDialog() {
|
||||
DownloadCustomChaptersDialog(this, presenter.chapters.size).showDialog(router)
|
||||
}
|
||||
|
||||
|
||||
private fun downloadChapters(choice: Int) {
|
||||
val chaptersToDownload = when (choice) {
|
||||
R.id.download_next -> getUnreadChaptersSorted().take(1)
|
||||
@ -563,4 +564,15 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
|
||||
downloadChapters(chaptersToDownload)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCustomDownloadDialog() {
|
||||
DownloadCustomChaptersDialog(this, presenter.chapters.size).showDialog(router)
|
||||
}
|
||||
|
||||
override fun downloadCustomChapters(amount: Int) {
|
||||
val chaptersToDownload = getUnreadChaptersSorted().take(amount)
|
||||
if (chaptersToDownload.isNotEmpty()) {
|
||||
downloadChapters(chaptersToDownload)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +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.listItemsSingleChoice
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
|
||||
class SetDisplayModeDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
where T : Controller, T : SetDisplayModeDialog.Listener {
|
||||
|
||||
private val selectedIndex = args.getInt("selected", -1)
|
||||
|
||||
constructor(target: T, selectedIndex: Int = -1) : this(Bundle().apply {
|
||||
putInt("selected", selectedIndex)
|
||||
}) {
|
||||
targetController = target
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
val ids = intArrayOf(Manga.DISPLAY_NAME, Manga.DISPLAY_NUMBER)
|
||||
val choices = intArrayOf(R.string.show_title, R.string.show_chapter_number)
|
||||
.map { activity.getString(it) }
|
||||
|
||||
return MaterialDialog(activity)
|
||||
.title(R.string.action_display_mode)
|
||||
.listItemsSingleChoice(items = choices, initialSelection = selectedIndex)
|
||||
{_, position, _ ->
|
||||
(targetController as? Listener)?.setDisplayMode(ids[position])
|
||||
}
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun setDisplayMode(id: Int)
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +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.listItemsSingleChoice
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
|
||||
class SetSortingDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
where T : Controller, T : SetSortingDialog.Listener {
|
||||
|
||||
private val selectedIndex = args.getInt("selected", -1)
|
||||
|
||||
constructor(target: T, selectedIndex: Int = -1) : this(Bundle().apply {
|
||||
putInt("selected", selectedIndex)
|
||||
}) {
|
||||
targetController = target
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
val ids = intArrayOf(Manga.SORTING_SOURCE, Manga.SORTING_NUMBER)
|
||||
val choices = intArrayOf(R.string.sort_by_source, R.string.sort_by_number)
|
||||
.map { activity.getString(it) }
|
||||
|
||||
return MaterialDialog(activity)
|
||||
.title(R.string.sorting_mode)
|
||||
.listItemsSingleChoice(items = choices, initialSelection = selectedIndex){
|
||||
_, position, _ ->
|
||||
(targetController as? Listener)?.setSorting(ids[position])
|
||||
}
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun setSorting(id: Int)
|
||||
}
|
||||
|
||||
}
|
@ -37,17 +37,36 @@
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_display_mode"
|
||||
android:title="@string/action_display_mode"
|
||||
app:showAsAction="never" />
|
||||
app:showAsAction="never">
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/display_title"
|
||||
android:title="@string/show_title" />
|
||||
<item
|
||||
android:id="@+id/display_chapter_number"
|
||||
android:title="@string/show_chapter_number" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_sorting_mode"
|
||||
android:title="@string/sorting_mode"
|
||||
app:showAsAction="never" />
|
||||
app:showAsAction="never">
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/sort_by_source"
|
||||
android:title="@string/sort_by_source" />
|
||||
<item
|
||||
android:id="@+id/sort_by_number"
|
||||
android:title="@string/sort_by_number" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/manga_download"
|
||||
android:title="@string/manga_download"
|
||||
app:showAsAction="never" >
|
||||
<menu >
|
||||
|
@ -81,7 +81,7 @@
|
||||
<string name="action_open_in_browser">Open in browser</string>
|
||||
<string name="action_open_in_web_view">Open in web view</string>
|
||||
<string name="action_add_to_home_screen">Add to home screen</string>
|
||||
<string name="action_display_mode">Change display mode</string>
|
||||
<string name="action_display_mode">Display mode</string>
|
||||
<string name="action_display">Display</string>
|
||||
<string name="action_display_grid">Grid</string>
|
||||
<string name="action_display_list">List</string>
|
||||
@ -459,8 +459,8 @@
|
||||
<string name="chapter_error">Error</string>
|
||||
<string name="chapter_paused">Paused</string>
|
||||
<string name="fetch_chapters_error">Could not fetch chapters</string>
|
||||
<string name="show_title">Show title</string>
|
||||
<string name="show_chapter_number">Show chapter number</string>
|
||||
<string name="show_title">Title</string>
|
||||
<string name="show_chapter_number">Chapter number</string>
|
||||
<string name="sorting_mode">Sorting mode</string>
|
||||
<string name="sort_by_source">By source</string>
|
||||
<string name="sort_by_number">By chapter number</string>
|
||||
|
Loading…
Reference in New Issue
Block a user