mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 14:31:50 +01:00
option to add manga count to the category headers
closes
This commit is contained in:
parent
1e138ab476
commit
226bb18d46
@ -198,6 +198,8 @@ object PreferenceKeys {
|
||||
|
||||
const val showLibraryUpdateErrors = "show_library_update_errors"
|
||||
|
||||
const val categoryNumberOfItems = "display_number_of_items"
|
||||
|
||||
const val alwaysShowChapterTransition = "always_show_chapter_transition"
|
||||
|
||||
const val hideBottomNavOnScroll = "hide_bottom_nav_on_scroll"
|
||||
|
@ -355,6 +355,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun unreadBadgeType() = flowPrefs.getInt("unread_badge_type", 2)
|
||||
|
||||
fun categoryNumberOfItems() = flowPrefs.getBoolean(Keys.categoryNumberOfItems, false)
|
||||
|
||||
fun hideStartReadingButton() = flowPrefs.getBoolean("hide_reading_button", false)
|
||||
|
||||
fun alwaysShowChapterTransition() = flowPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
|
||||
|
@ -27,10 +27,19 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
|
||||
|
||||
val sourceManager by injectLazy<SourceManager>()
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
var showNumber = preferences.categoryNumberOfItems().get()
|
||||
|
||||
init {
|
||||
setDisplayHeadersAtStartUp(true)
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of manga in each category.
|
||||
*/
|
||||
var itemsPerCategory: Map<Int, Int> = emptyMap()
|
||||
|
||||
/**
|
||||
* The list of manga in this category.
|
||||
*/
|
||||
@ -51,6 +60,10 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
|
||||
mangas = list.toList()
|
||||
|
||||
performFilter()
|
||||
|
||||
itemsPerCategory = headerItems.map { header ->
|
||||
(header as LibraryHeaderItem).catId to getSectionItemPositions(header).size
|
||||
}.toMap()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -905,6 +905,13 @@ class LibraryController(
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
.launchIn(viewScope)
|
||||
preferences.categoryNumberOfItems().asFlow()
|
||||
.drop(1)
|
||||
.onEach {
|
||||
adapter.showNumber = it
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
|
||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.ui.library
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.util.TypedValue
|
||||
@ -58,6 +59,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun bind(item: LibraryHeaderItem) {
|
||||
val index = adapter.headerItems.indexOf(item)
|
||||
val previousIsCollapsed =
|
||||
@ -79,8 +81,11 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
}
|
||||
val category = item.category
|
||||
|
||||
if (category.isAlone && !category.isDynamic) binding.categoryTitle.text = ""
|
||||
else binding.categoryTitle.text = category.name
|
||||
binding.categoryTitle.text =
|
||||
if (category.isAlone && !category.isDynamic) { "" } else { category.name } +
|
||||
if (adapter.showNumber && !category.isHidden) {
|
||||
" (${adapter.itemsPerCategory[item.catId]})"
|
||||
} else { "" }
|
||||
if (category.sourceId != null) {
|
||||
val icon = adapter.sourceManager.get(category.sourceId!!)?.icon()
|
||||
icon?.setBounds(0, 0, 32.dpToPx, 32.dpToPx)
|
||||
|
@ -29,6 +29,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
dynamicToBottom.bindToPreference(preferences.collapsedDynamicAtBottom()) {
|
||||
controller?.presenter?.getLibrary()
|
||||
}
|
||||
showNumberOfItems.bindToPreference(preferences.categoryNumberOfItems())
|
||||
val hideHopper = min(
|
||||
2,
|
||||
preferences.hideHopper().get().toInt() * 2 + preferences.autohideHopper().get()
|
||||
|
@ -35,6 +35,14 @@
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/move_dynamic_to_bottom" />
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/show_number_of_items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/show_number_of_items" />
|
||||
|
||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
||||
android:id="@+id/hide_hopper_spinner"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -129,6 +129,7 @@
|
||||
<string name="no_matches_for_filters">No matches found for your current filters</string>
|
||||
<string name="show_all_categories">Show all categories</string>
|
||||
<string name="move_dynamic_to_bottom">Move collapsed dynamic categories to bottom</string>
|
||||
<string name="show_number_of_items">Show number of items</string>
|
||||
<string name="when_grouping_by_sources_tags">When grouping library by sources, status, etc.</string>
|
||||
<string name="always_show_current_category">Always show current category</string>
|
||||
<string name="category_hopper_long_press">Category hopper long-press action</string>
|
||||
|
Loading…
Reference in New Issue
Block a user