mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 02:19:08 +01:00
Add option to hide start reading button
This commit is contained in:
parent
b38b74d95d
commit
b53d571a1c
@ -253,6 +253,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun unreadBadgeType() = rxPrefs.getInteger("unread_badge_type", 2)
|
||||
|
||||
fun hideStartReadingButton() = rxPrefs.getBoolean("hide_reading_button", false)
|
||||
|
||||
fun hideFiltersAtStart() = rxPrefs.getBoolean("hide_filters_at_start", false)
|
||||
|
||||
fun alwaysShowChapterTransition() = rxPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
|
||||
|
@ -98,6 +98,9 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee
|
||||
unread_badge_group.bindToPreference(preferences.unreadBadgeType()) {
|
||||
controller.presenter.requestUnreadBadgesUpdate()
|
||||
}
|
||||
hide_reading.bindToPreference(preferences.hideStartReadingButton()) {
|
||||
controller.reattachAdapter()
|
||||
}
|
||||
hide_filters.bindToPreference(preferences.hideFiltersAtStart())
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,7 @@ class LibraryGridHolder(
|
||||
compact_title.text = title.text
|
||||
|
||||
setUnreadBadge(badge_view, item)
|
||||
play_layout.visibility = if (item.manga.unread > 0 && item.unreadType > 0)
|
||||
View.VISIBLE else View.GONE
|
||||
setReadingButton(item)
|
||||
|
||||
// Update the cover.
|
||||
if (item.manga.thumbnail_url == null) GlideApp.with(view.context).clear(cover_thumbnail)
|
||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library
|
||||
import android.view.View
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import kotlinx.android.synthetic.main.manga_grid_item.*
|
||||
|
||||
/**
|
||||
* Generic class used to hold the displayed data of a manga in the library.
|
||||
@ -40,6 +41,11 @@ abstract class LibraryHolder(
|
||||
item.chapterCount > -1)
|
||||
}
|
||||
|
||||
fun setReadingButton(item: LibraryItem) {
|
||||
play_layout.visibility = if (item.manga.unread > 0 && item.unreadType > 0 && !item.hideReadingButton)
|
||||
View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is released.
|
||||
*
|
||||
|
@ -9,27 +9,27 @@ import android.widget.ImageView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.AbstractSectionableItem
|
||||
import eu.davidea.flexibleadapter.items.IFilterable
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.android.synthetic.main.manga_grid_item.view.*
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class LibraryItem(
|
||||
val manga: LibraryManga,
|
||||
private val libraryLayout: Preference<Int>,
|
||||
private val fixedSize: Preference<Boolean>,
|
||||
private val showFastScroll: Preference<Boolean>,
|
||||
header: LibraryHeaderItem
|
||||
header: LibraryHeaderItem,
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
) :
|
||||
AbstractSectionableItem<LibraryHolder, LibraryHeaderItem>(header), IFilterable<String> {
|
||||
|
||||
@ -37,8 +37,20 @@ class LibraryItem(
|
||||
var unreadType = 2
|
||||
var chapterCount = -1
|
||||
|
||||
private val showFastScroll: Boolean
|
||||
get() = preferences.alwaysShowSeeker().getOrDefault()
|
||||
|
||||
private val uniformSize: Boolean
|
||||
get() = preferences.uniformGrid().getOrDefault()
|
||||
|
||||
private val libraryLayout: Int
|
||||
get() = preferences.libraryLayout().getOrDefault()
|
||||
|
||||
val hideReadingButton: Boolean
|
||||
get() = preferences.hideStartReadingButton().getOrDefault()
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return if (libraryLayout.getOrDefault() == 0 || manga.isBlank())
|
||||
return if (libraryLayout == 0 || manga.isBlank())
|
||||
R.layout.manga_list_item
|
||||
else
|
||||
R.layout.manga_grid_item
|
||||
@ -47,10 +59,10 @@ class LibraryItem(
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LibraryHolder {
|
||||
val parent = adapter.recyclerView
|
||||
return if (parent is AutofitRecyclerView) {
|
||||
val libraryLayout = libraryLayout.getOrDefault()
|
||||
val isFixedSize = fixedSize.getOrDefault()
|
||||
val libraryLayout = libraryLayout
|
||||
val isFixedSize = uniformSize
|
||||
if (libraryLayout == 0 || manga.isBlank()) {
|
||||
LibraryListHolder(view, adapter as LibraryCategoryAdapter, showFastScroll.getOrDefault())
|
||||
LibraryListHolder(view, adapter as LibraryCategoryAdapter, showFastScroll)
|
||||
} else {
|
||||
view.apply {
|
||||
val coverHeight = (parent.itemWidth / 3f * 4f).toInt()
|
||||
@ -95,7 +107,7 @@ class LibraryItem(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
LibraryListHolder(view, adapter as LibraryCategoryAdapter, showFastScroll.getOrDefault())
|
||||
LibraryListHolder(view, adapter as LibraryCategoryAdapter, showFastScroll)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ class LibraryListHolder(
|
||||
) : LibraryHolder(view, adapter) {
|
||||
|
||||
init {
|
||||
play_layout.setOnClickListener { playButtonClicked() }
|
||||
badge_view?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
marginEnd = (if (padEnd) 22 else 12).dpToPx
|
||||
}
|
||||
@ -74,9 +75,7 @@ class LibraryListHolder(
|
||||
subtitle.visibility = if (!item.manga.author.isNullOrBlank()) View.VISIBLE
|
||||
else View.GONE
|
||||
|
||||
play_layout.visibility = if (item.manga.unread > 0 && item.unreadType > 0)
|
||||
View.VISIBLE else View.GONE
|
||||
play_layout.setOnClickListener { playButtonClicked() }
|
||||
setReadingButton(item)
|
||||
|
||||
// Update the cover.
|
||||
if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail)
|
||||
|
@ -400,7 +400,6 @@ class LibraryPresenter(
|
||||
*/
|
||||
private fun getLibraryFromDB(): List<LibraryItem> {
|
||||
val categories = db.getCategories().executeAsBlocking().toMutableList()
|
||||
val libraryLayout = preferences.libraryLayout()
|
||||
val showCategories = !preferences.hideCategories().getOrDefault()
|
||||
var libraryManga = db.getLibraryMangas().executeAsBlocking()
|
||||
val seekPref = preferences.alwaysShowSeeker()
|
||||
@ -421,7 +420,7 @@ class LibraryPresenter(
|
||||
val headerItem = (if (!showCategories) catItemAll
|
||||
else headerItems[it.category]) ?: return@mapNotNull null
|
||||
categorySet.add(it.category)
|
||||
LibraryItem(it, libraryLayout, preferences.uniformGrid(), seekPref, headerItem)
|
||||
LibraryItem(it, headerItem)
|
||||
}.toMutableList()
|
||||
|
||||
val categoriesHidden = preferences.collapsedCategories().getOrDefault().mapNotNull {
|
||||
@ -434,13 +433,7 @@ class LibraryPresenter(
|
||||
if (catId > 0 && !categorySet.contains(catId)) {
|
||||
val headerItem = headerItems[catId]
|
||||
if (headerItem != null) items.add(
|
||||
LibraryItem(
|
||||
LibraryManga.createBlank(catId),
|
||||
libraryLayout,
|
||||
preferences.uniformGrid(),
|
||||
preferences.alwaysShowSeeker(),
|
||||
headerItem
|
||||
)
|
||||
LibraryItem(LibraryManga.createBlank(catId), headerItem)
|
||||
)
|
||||
} else if (catId in categoriesHidden) {
|
||||
val mangaToRemove = items.filter { it.manga.category == catId }
|
||||
@ -450,13 +443,7 @@ class LibraryPresenter(
|
||||
items.removeAll(mangaToRemove)
|
||||
val headerItem = headerItems[catId]
|
||||
if (headerItem != null) items.add(
|
||||
LibraryItem(
|
||||
LibraryManga.createHide(catId, mergedTitle),
|
||||
libraryLayout,
|
||||
preferences.uniformGrid(),
|
||||
preferences.alwaysShowSeeker(),
|
||||
headerItem
|
||||
)
|
||||
LibraryItem(LibraryManga.createHide(catId, mergedTitle), headerItem)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,14 @@
|
||||
android:text="@string/show_count" />
|
||||
</RadioGroup>
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/hide_reading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/hide_start_reading_button" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -129,6 +129,7 @@
|
||||
<string name="compact_grid">Compact Grid</string>
|
||||
<string name="start_with_filters_hidden">Start with filters hidden</string>
|
||||
<string name="download_badge">Download badges</string>
|
||||
<string name="hide_start_reading_button">Hide start reading button</string>
|
||||
<string name="always_show_library_fast_scroll">Always show library fast scroll</string>
|
||||
<string name="unread_badges">Unread badges</string>
|
||||
<string name="uniform_covers">Uniform covers</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user