Add a button that pick a random manga to read (#876)

* add random button functionality

* Add random manga setting, this should close #873

It open only manga with unread chapter, if we feel is needed we could add a setting to open even read manga

* Add random manga functionality to hopper long press

Also revert previous changes to preference and ui
This commit is contained in:
DaviDeMeo 2021-07-03 02:10:45 +02:00 committed by GitHub
parent 56bfa65a54
commit 4393e9d9b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View File

@ -438,6 +438,14 @@ class LibraryController(
filterTooltip?.show() filterTooltip?.show()
} }
private fun openRandomManga() {
val items = adapter.currentItems.filter { (it is LibraryItem && !it.manga.isBlank() && !it.manga.isHidden() && (!it.manga.initialized || it.manga.unread > 0)) }
if (items.isNotEmpty()) {
val item = items.random() as LibraryItem
openManga(item.manga)
}
}
private fun showGroupOptions() { private fun showGroupOptions() {
val groupItems = mutableListOf(BY_DEFAULT, BY_TAG, BY_SOURCE, BY_STATUS) val groupItems = mutableListOf(BY_DEFAULT, BY_TAG, BY_SOURCE, BY_STATUS)
if (presenter.isLoggedIntoTracking) { if (presenter.isLoggedIntoTracking) {
@ -673,6 +681,7 @@ class LibraryController(
binding.roundedCategoryHopper.categoryButton.setOnLongClickListener { binding.roundedCategoryHopper.categoryButton.setOnLongClickListener {
when (preferences.hopperLongPressAction().get()) { when (preferences.hopperLongPressAction().get()) {
4 -> openRandomManga()
3 -> showGroupOptions() 3 -> showGroupOptions()
2 -> showDisplayOptions() 2 -> showDisplayOptions()
1 -> if (canCollapseOrExpandCategory() != null) presenter.toggleAllCategoryVisibility() 1 -> if (canCollapseOrExpandCategory() != null) presenter.toggleAllCategoryVisibility()

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M14 8C13.45 8 13 7.55 13 7S13.45 6 14 6C14.55 6 15 6.45 15 7C15 7.55 14.55 8 14 8M12 12V19H5V12H12M12.78 10H4.22C3.55 10 3 10.55 3 11.22V19.78C3 20.45 3.55 21 4.22 21H12.78C13.45 21 14 20.45 14 19.78V11.22C14 10.55 13.45 10 12.78 10M19.78 3H11.22C10.55 3 10 3.55 10 4.22V8H12V5H19V12H16V14H19.78C20.45 14 21 13.45 21 12.78V4.22C21 3.55 20.45 3 19.78 3M17 8C16.45 8 16 7.55 16 7S16.45 6 17 6C17.55 6 18 6.45 18 7C18 7.55 17.55 8 17 8M17 11C16.45 11 16 10.55 16 10S16.45 9 17 9C17.55 9 18 9.45 18 10C18 10.55 17.55 11 17 11M7 15C6.45 15 6 14.55 6 14S6.45 13 7 13C7.55 13 8 13.45 8 14C8 14.55 7.55 15 7 15M10 18C9.45 18 9 17.55 9 17S9.45 16 10 16C10.55 16 11 16.45 11 17C11 17.55 10.55 18 10 18" />
</vector>

View File

@ -22,6 +22,7 @@
<item>@string/expand_collapse_all_categories</item> <item>@string/expand_collapse_all_categories</item>
<item>@string/display_options</item> <item>@string/display_options</item>
<item>@string/group_library_by</item> <item>@string/group_library_by</item>
<item>@string/open_random_manga</item>
</string-array> </string-array>
<string-array name="hide_hopper"> <string-array name="hide_hopper">

View File

@ -133,6 +133,7 @@
<string name="always_show_current_category">Always show current category</string> <string name="always_show_current_category">Always show current category</string>
<string name="category_hopper_long_press">Category hopper long-press action</string> <string name="category_hopper_long_press">Category hopper long-press action</string>
<string name="expand_collapse_all_categories">Expand/collapse all categories</string> <string name="expand_collapse_all_categories">Expand/collapse all categories</string>
<string name="open_random_manga">Open a random Manga</string>
<string name="expand_all_categories">Expand all categories</string> <string name="expand_all_categories">Expand all categories</string>
<string name="collapse_all_categories">Collapse all categories</string> <string name="collapse_all_categories">Collapse all categories</string>
<string name="reorder_filters">Reorder filters</string> <string name="reorder_filters">Reorder filters</string>