mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 03:51:49 +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_EXCLUDE
|
||||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_IGNORE
|
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_INCLUDE
|
||||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_REALLY_EXCLUDE
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@ -126,14 +125,17 @@ class LibraryPresenter(
|
|||||||
return@f filterDownloaded == 0 && filterUnread == 0 && filterCompleted == 0 &&
|
return@f filterDownloaded == 0 && filterUnread == 0 && filterCompleted == 0 &&
|
||||||
filterTracked == 0 && filterMangaType == 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
|
// 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)
|
.executeAsBlocking().size != item.manga.unread)
|
||||||
) return@f false
|
) 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)
|
.executeAsBlocking().size == item.manga.unread)
|
||||||
) return@f false
|
) return@f false
|
||||||
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
|
|
||||||
|
|
||||||
if (filterMangaType > 0) {
|
if (filterMangaType > 0) {
|
||||||
if (if (filterMangaType == Manga.TYPE_MANHWA) (filterMangaType != item.manga.mangaType() && filterMangaType != Manga.TYPE_WEBTOON)
|
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 unread: FilterTagGroup
|
||||||
|
|
||||||
|
private lateinit var unreadProgress: FilterTagGroup
|
||||||
|
|
||||||
private lateinit var completed: FilterTagGroup
|
private lateinit var completed: FilterTagGroup
|
||||||
|
|
||||||
private lateinit var tracked: 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)
|
completed.setup(this, R.string.completed, R.string.ongoing)
|
||||||
|
|
||||||
unread = inflate(R.layout.filter_buttons) as FilterTagGroup
|
unread = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||||
unread.setup(this, R.string.not_started, R.string.in_progress,
|
unread.setup(this, R.string.unread, R.string.read)
|
||||||
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 = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||||
tracked.setup(this, R.string.tracked, R.string.not_tracked)
|
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)
|
hide_categories.visibleIf(showCategoriesCheckBox)
|
||||||
downloaded.setState(preferences.filterDownloaded())
|
downloaded.setState(preferences.filterDownloaded())
|
||||||
completed.setState(preferences.filterCompleted())
|
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())
|
tracked.setState(preferences.filterTracked())
|
||||||
mangaType?.setState(preferences.filterMangaType())
|
mangaType?.setState(preferences.filterMangaType())
|
||||||
reSortViews()
|
reSortViews()
|
||||||
@ -260,20 +272,34 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
|
|
||||||
override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference: Boolean) {
|
override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference: Boolean) {
|
||||||
if (updatePreference) {
|
if (updatePreference) {
|
||||||
if (view == trackers) {
|
when (view) {
|
||||||
FILTER_TRACKER = view.nameOf(index) ?: ""
|
trackers -> {
|
||||||
} else {
|
FILTER_TRACKER = view.nameOf(index) ?: ""
|
||||||
when (view) {
|
null
|
||||||
downloaded -> preferences.filterDownloaded()
|
}
|
||||||
unread -> preferences.filterUnread()
|
unreadProgress -> {
|
||||||
completed -> preferences.filterCompleted()
|
preferences.filterUnread().set(
|
||||||
tracked -> preferences.filterTracked()
|
if (index > -1) index + 3 else 1)
|
||||||
mangaType -> preferences.filterMangaType()
|
null
|
||||||
else -> null
|
}
|
||||||
}?.set(index + 1)
|
downloaded -> preferences.filterDownloaded()
|
||||||
}
|
unread -> preferences.filterUnread()
|
||||||
|
completed -> preferences.filterCompleted()
|
||||||
|
tracked -> preferences.filterTracked()
|
||||||
|
mangaType -> preferences.filterMangaType()
|
||||||
|
else -> null
|
||||||
|
}?.set(index + 1)
|
||||||
onGroupClicked(ACTION_FILTER)
|
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) {
|
if (tracked.isActivated && trackers != null && trackers?.parent == null) {
|
||||||
filter_layout.addView(trackers)
|
filter_layout.addView(trackers)
|
||||||
filterItems.add(trackers!!)
|
filterItems.add(trackers!!)
|
||||||
@ -304,8 +330,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
filterItems.forEach {
|
filterItems.forEach {
|
||||||
it.reset()
|
it.reset()
|
||||||
}
|
}
|
||||||
if (trackers != null)
|
trackers?.let {
|
||||||
filterItems.remove(trackers!!)
|
filterItems.remove(it)
|
||||||
|
}
|
||||||
|
filterItems.remove(unreadProgress)
|
||||||
reSortViews()
|
reSortViews()
|
||||||
onGroupClicked(ACTION_FILTER)
|
onGroupClicked(ACTION_FILTER)
|
||||||
}
|
}
|
||||||
|
@ -74,16 +74,16 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
thirdButton.setOnClickListener { toggleButton(2) }
|
thirdButton.setOnClickListener { toggleButton(2) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var state: Int
|
||||||
|
get() = buttons.indexOfFirst { it.isActivated }
|
||||||
|
set(index) = toggleButton(index, false)
|
||||||
|
|
||||||
fun setState(preference: Preference<Int>) {
|
fun setState(preference: Preference<Int>) {
|
||||||
val index = preference.getOrDefault() - 1
|
state = preference.getOrDefault() - 1
|
||||||
if (index > -1)
|
|
||||||
toggleButton(index, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setState(text: String) {
|
fun setState(text: String) {
|
||||||
val index = buttons.indexOfFirst { it.text == text && it.visibility == View.VISIBLE }
|
state = buttons.indexOfFirst { it.text == text && it.visibility == View.VISIBLE }
|
||||||
if (index > -1)
|
|
||||||
toggleButton(index, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
@ -98,7 +98,8 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleButton(index: Int, callBack: Boolean = true) {
|
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
|
return
|
||||||
if (callBack) {
|
if (callBack) {
|
||||||
val transition = androidx.transition.AutoTransition()
|
val transition = androidx.transition.AutoTransition()
|
||||||
|
Loading…
Reference in New Issue
Block a user