mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 05:45:07 +01:00
Unread filter readded
In progress/Not started seperated out
This commit is contained in:
parent
44bb8de84f
commit
ea88c254b9
@ -21,7 +21,6 @@ import eu.kanade.tachiyomi.util.system.executeOnIO
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_EXCLUDE
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_IGNORE
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_INCLUDE
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_REALLY_EXCLUDE
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@ -126,14 +125,17 @@ class LibraryPresenter(
|
||||
return@f filterDownloaded == 0 && filterUnread == 0 && filterCompleted == 0 &&
|
||||
filterTracked == 0 && filterMangaType == 0
|
||||
}
|
||||
|
||||
if (filterUnread == STATE_INCLUDE && item.manga.unread == 0) return@f false
|
||||
if (filterUnread == STATE_EXCLUDE && item.manga.unread > 0) return@f false
|
||||
|
||||
// Filter for unread chapters
|
||||
if (filterUnread == STATE_INCLUDE && (item.manga.unread == 0 || db.getChapters(item.manga)
|
||||
if (filterUnread == 3 && (item.manga.unread == 0 || db.getChapters(item.manga)
|
||||
.executeAsBlocking().size != item.manga.unread)
|
||||
) return@f false
|
||||
if (filterUnread == STATE_EXCLUDE && (item.manga.unread == 0 || db.getChapters(item.manga)
|
||||
if (filterUnread == 4 && (item.manga.unread == 0 || db.getChapters(item.manga)
|
||||
.executeAsBlocking().size == item.manga.unread)
|
||||
) return@f false
|
||||
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
|
||||
|
||||
if (filterMangaType > 0) {
|
||||
if (if (filterMangaType == Manga.TYPE_MANHWA) (filterMangaType != item.manga.mangaType() && filterMangaType != Manga.TYPE_WEBTOON)
|
||||
|
@ -44,6 +44,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
|
||||
private lateinit var unread: FilterTagGroup
|
||||
|
||||
private lateinit var unreadProgress: FilterTagGroup
|
||||
|
||||
private lateinit var completed: FilterTagGroup
|
||||
|
||||
private lateinit var tracked: FilterTagGroup
|
||||
@ -183,8 +185,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
completed.setup(this, R.string.completed, R.string.ongoing)
|
||||
|
||||
unread = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||
unread.setup(this, R.string.not_started, R.string.in_progress,
|
||||
R.string.read)
|
||||
unread.setup(this, R.string.unread, R.string.read)
|
||||
|
||||
unreadProgress = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||
unreadProgress.setup(this, R.string.not_started, R.string.in_progress)
|
||||
|
||||
tracked = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||
tracked.setup(this, R.string.tracked, R.string.not_tracked)
|
||||
@ -228,7 +232,15 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
hide_categories.visibleIf(showCategoriesCheckBox)
|
||||
downloaded.setState(preferences.filterDownloaded())
|
||||
completed.setState(preferences.filterCompleted())
|
||||
unread.setState(preferences.filterUnread())
|
||||
val unreadP = preferences.filterUnread().getOrDefault() - 1
|
||||
if (unreadP > 1) {
|
||||
unread.state = 0
|
||||
unreadProgress.state = unreadP - 2
|
||||
if (!filterItems.contains(unreadProgress))
|
||||
filterItems.add(unreadProgress)
|
||||
} else {
|
||||
unread.state = unreadP
|
||||
}
|
||||
tracked.setState(preferences.filterTracked())
|
||||
mangaType?.setState(preferences.filterMangaType())
|
||||
reSortViews()
|
||||
@ -260,10 +272,16 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
|
||||
override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference: Boolean) {
|
||||
if (updatePreference) {
|
||||
if (view == trackers) {
|
||||
FILTER_TRACKER = view.nameOf(index) ?: ""
|
||||
} else {
|
||||
when (view) {
|
||||
trackers -> {
|
||||
FILTER_TRACKER = view.nameOf(index) ?: ""
|
||||
null
|
||||
}
|
||||
unreadProgress -> {
|
||||
preferences.filterUnread().set(
|
||||
if (index > -1) index + 3 else 1)
|
||||
null
|
||||
}
|
||||
downloaded -> preferences.filterDownloaded()
|
||||
unread -> preferences.filterUnread()
|
||||
completed -> preferences.filterCompleted()
|
||||
@ -271,9 +289,17 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
mangaType -> preferences.filterMangaType()
|
||||
else -> null
|
||||
}?.set(index + 1)
|
||||
}
|
||||
onGroupClicked(ACTION_FILTER)
|
||||
}
|
||||
if (unread.state == 0 && unreadProgress.parent == null) {
|
||||
val unreadIndex = filter_layout.indexOfChild(unread) + 1
|
||||
filter_layout.addView(unreadProgress, unreadIndex)
|
||||
filterItems.add(unreadIndex, unreadProgress)
|
||||
} else if (unread.state != 0 && unreadProgress.parent != null) {
|
||||
filter_layout.removeView(unreadProgress)
|
||||
unreadProgress.reset()
|
||||
filterItems.remove(unreadProgress)
|
||||
}
|
||||
if (tracked.isActivated && trackers != null && trackers?.parent == null) {
|
||||
filter_layout.addView(trackers)
|
||||
filterItems.add(trackers!!)
|
||||
@ -304,8 +330,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
filterItems.forEach {
|
||||
it.reset()
|
||||
}
|
||||
if (trackers != null)
|
||||
filterItems.remove(trackers!!)
|
||||
trackers?.let {
|
||||
filterItems.remove(it)
|
||||
}
|
||||
filterItems.remove(unreadProgress)
|
||||
reSortViews()
|
||||
onGroupClicked(ACTION_FILTER)
|
||||
}
|
||||
|
@ -74,16 +74,16 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
||||
thirdButton.setOnClickListener { toggleButton(2) }
|
||||
}
|
||||
|
||||
var state: Int
|
||||
get() = buttons.indexOfFirst { it.isActivated }
|
||||
set(index) = toggleButton(index, false)
|
||||
|
||||
fun setState(preference: Preference<Int>) {
|
||||
val index = preference.getOrDefault() - 1
|
||||
if (index > -1)
|
||||
toggleButton(index, false)
|
||||
state = preference.getOrDefault() - 1
|
||||
}
|
||||
|
||||
fun setState(text: String) {
|
||||
val index = buttons.indexOfFirst { it.text == text && it.visibility == View.VISIBLE }
|
||||
if (index > -1)
|
||||
toggleButton(index, false)
|
||||
state = buttons.indexOfFirst { it.text == text && it.visibility == View.VISIBLE }
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
@ -98,7 +98,8 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
||||
}
|
||||
|
||||
private fun toggleButton(index: Int, callBack: Boolean = true) {
|
||||
if (itemCount == 0 || (isActivated && index != buttons.indexOfFirst { it.isActivated }))
|
||||
if (index < 0 || itemCount == 0 ||
|
||||
(isActivated && index != buttons.indexOfFirst { it.isActivated }))
|
||||
return
|
||||
if (callBack) {
|
||||
val transition = androidx.transition.AutoTransition()
|
||||
|
Loading…
Reference in New Issue
Block a user