mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
parent
31654d1bb8
commit
cfe7e366ab
7 changed files with 39 additions and 4 deletions
|
@ -7,6 +7,8 @@ class LibraryManga : MangaImpl() {
|
|||
|
||||
var category: Int = 0
|
||||
|
||||
var bookmarkCount: Int = 0
|
||||
|
||||
val totalChapters
|
||||
get() = read + unread
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ val libraryQuery =
|
|||
"""
|
||||
SELECT M.*, COALESCE(MC.${MangaCategory.COL_CATEGORY_ID}, 0) AS ${Manga.COL_CATEGORY}
|
||||
FROM (
|
||||
SELECT ${Manga.TABLE}.*, COALESCE(C.unread, 0) AS ${Manga.COL_UNREAD}, COALESCE(R.hasread, 0) AS ${Manga.COL_HAS_READ}
|
||||
SELECT ${Manga.TABLE}.*, COALESCE(C.unread, 0) AS ${Manga.COL_UNREAD}, COALESCE(R.hasread, 0) AS ${Manga.COL_HAS_READ}, COALESCE(B.bookmarkCount, 0) AS ${Manga.COL_BOOKMARK_COUNT}
|
||||
FROM ${Manga.TABLE}
|
||||
LEFT JOIN (
|
||||
SELECT ${Chapter.COL_MANGA_ID}, COUNT(*) AS unread
|
||||
|
@ -31,6 +31,13 @@ val libraryQuery =
|
|||
GROUP BY ${Chapter.COL_MANGA_ID}
|
||||
) AS R
|
||||
ON ${Manga.COL_ID} = R.${Chapter.COL_MANGA_ID}
|
||||
LEFT JOIN (
|
||||
SELECT ${Chapter.COL_MANGA_ID}, COUNT(*) AS bookmarkCount
|
||||
FROM ${Chapter.TABLE}
|
||||
WHERE ${Chapter.COL_BOOKMARK} = 1
|
||||
GROUP BY ${Chapter.COL_MANGA_ID}
|
||||
) AS B
|
||||
ON ${Manga.COL_ID} = B.${Chapter.COL_MANGA_ID}
|
||||
WHERE ${Manga.COL_FAVORITE} = 1
|
||||
GROUP BY ${Manga.COL_ID}
|
||||
ORDER BY ${Manga.COL_TITLE}
|
||||
|
|
|
@ -19,6 +19,7 @@ class LibraryMangaGetResolver : DefaultGetResolver<LibraryManga>(), BaseMangaGet
|
|||
manga.unread = cursor.getInt(cursor.getColumnIndex(MangaTable.COL_UNREAD))
|
||||
manga.category = cursor.getInt(cursor.getColumnIndex(MangaTable.COL_CATEGORY))
|
||||
manga.read = cursor.getInt(cursor.getColumnIndex(MangaTable.COL_HAS_READ))
|
||||
manga.bookmarkCount = cursor.getInt(cursor.getColumnIndex(MangaTable.COL_BOOKMARK_COUNT))
|
||||
|
||||
return manga
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ object MangaTable {
|
|||
|
||||
const val COL_HAS_READ = "has_read"
|
||||
|
||||
const val COL_BOOKMARK_COUNT = "bookmark_count"
|
||||
|
||||
const val COL_CATEGORY = "category"
|
||||
|
||||
const val COL_HIDE_TITLE = "hideTitle"
|
||||
|
|
|
@ -285,6 +285,8 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun filterCompleted() = flowPrefs.getInt(Keys.filterCompleted, 0)
|
||||
|
||||
fun filterBookmarked() = flowPrefs.getInt("pref_filter_bookmarked_key", 0)
|
||||
|
||||
fun filterTracked() = flowPrefs.getInt(Keys.filterTracked, 0)
|
||||
|
||||
fun filterMangaType() = flowPrefs.getInt(Keys.filterMangaType, 0)
|
||||
|
|
|
@ -283,6 +283,8 @@ class LibraryPresenter(
|
|||
|
||||
val filterMangaType = preferences.filterMangaType().get()
|
||||
|
||||
val filterBookmarked = preferences.filterBookmarked().get()
|
||||
|
||||
val showEmptyCategoriesWhileFiltering = preferences.showEmptyCategoriesWhileFiltering().get()
|
||||
|
||||
val filterTrackers = FilterBottomSheet.FILTER_TRACKER
|
||||
|
@ -306,6 +308,7 @@ class LibraryPresenter(
|
|||
filterCompleted,
|
||||
filterTracked,
|
||||
filterMangaType,
|
||||
filterBookmarked,
|
||||
filterTrackers,
|
||||
)
|
||||
}
|
||||
|
@ -325,6 +328,7 @@ class LibraryPresenter(
|
|||
filterCompleted,
|
||||
filterTracked,
|
||||
filterMangaType,
|
||||
filterBookmarked,
|
||||
filterTrackers,
|
||||
)
|
||||
if (matches) {
|
||||
|
@ -347,6 +351,7 @@ class LibraryPresenter(
|
|||
filterCompleted: Int,
|
||||
filterTracked: Int,
|
||||
filterMangaType: Int,
|
||||
filterBookmarked: Int,
|
||||
filterTrackers: String,
|
||||
): Boolean {
|
||||
(controller as? FilteredLibraryController)?.let {
|
||||
|
@ -360,6 +365,9 @@ class LibraryPresenter(
|
|||
if (filterUnread == 3 && !(item.manga.unread > 0 && !item.manga.hasRead)) return false
|
||||
if (filterUnread == 4 && !(item.manga.unread > 0 && item.manga.hasRead)) return false
|
||||
|
||||
if (filterBookmarked == STATE_INCLUDE && item.manga.bookmarkCount == 0) return false
|
||||
if (filterBookmarked == STATE_EXCLUDE && item.manga.bookmarkCount > 0) return false
|
||||
|
||||
if (filterMangaType > 0) {
|
||||
if (if (filterMangaType == Manga.TYPE_MANHWA) {
|
||||
item.manga.seriesType(sourceManager = sourceManager) !in arrayOf(filterMangaType, Manga.TYPE_WEBTOON)
|
||||
|
|
|
@ -71,6 +71,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
|
||||
private lateinit var completed: FilterTagGroup
|
||||
|
||||
private lateinit var bookmarked: FilterTagGroup
|
||||
|
||||
private var tracked: FilterTagGroup? = null
|
||||
|
||||
private var trackers: FilterTagGroup? = null
|
||||
|
@ -89,6 +91,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
list.add(unread)
|
||||
list.add(downloaded)
|
||||
list.add(completed)
|
||||
list.add(bookmarked)
|
||||
if (hasTracking) {
|
||||
tracked?.let { list.add(it) }
|
||||
}
|
||||
|
@ -273,6 +276,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
preferences.filterCompleted().get() > 0 ||
|
||||
preferences.filterTracked().get() > 0 ||
|
||||
preferences.filterMangaType().get() > 0 ||
|
||||
preferences.filterBookmarked().get() > 0 ||
|
||||
FILTER_TRACKER.isNotEmpty()
|
||||
}
|
||||
|
||||
|
@ -289,6 +293,9 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
unread = inflate(R.layout.filter_tag_group) as FilterTagGroup
|
||||
unread.setup(this, R.string.unread, R.string.read)
|
||||
|
||||
bookmarked = inflate(R.layout.filter_tag_group) as FilterTagGroup
|
||||
bookmarked.setup(this, R.string.bookmarked, R.string.not_bookmarked)
|
||||
|
||||
if (hasTracking) {
|
||||
tracked = inflate(R.layout.filter_tag_group) as FilterTagGroup
|
||||
tracked?.setup(this, R.string.tracked, R.string.not_tracked)
|
||||
|
@ -375,10 +382,11 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
withContext(Dispatchers.Main) {
|
||||
downloaded.setState(preferences.filterDownloaded())
|
||||
completed.setState(preferences.filterCompleted())
|
||||
bookmarked.setState(preferences.filterBookmarked())
|
||||
val unreadP = preferences.filterUnread().get()
|
||||
if (unreadP <= 2) {
|
||||
unread.state = unreadP - 1
|
||||
} else if (unreadP >= 3) {
|
||||
} else {
|
||||
unreadProgress.state = unreadP - 3
|
||||
}
|
||||
tracked?.setState(preferences.filterTracked())
|
||||
|
@ -395,7 +403,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
filterItems.add(it)
|
||||
}
|
||||
}
|
||||
listOfNotNull(unreadProgress, unread, downloaded, completed, mangaType, tracked)
|
||||
listOfNotNull(unreadProgress, unread, downloaded, completed, mangaType, bookmarked, tracked)
|
||||
.forEach {
|
||||
if (!filterItems.contains(it)) {
|
||||
filterItems.add(it)
|
||||
|
@ -414,6 +422,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
Filters.Downloaded -> downloaded
|
||||
Filters.Completed -> completed
|
||||
Filters.SeriesType -> mangaType
|
||||
Filters.Bookmarked -> bookmarked
|
||||
Filters.Tracked -> if (hasTracking) tracked else null
|
||||
else -> null
|
||||
}
|
||||
|
@ -442,6 +451,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
}
|
||||
downloaded -> preferences.filterDownloaded()
|
||||
completed -> preferences.filterCompleted()
|
||||
bookmarked -> preferences.filterBookmarked()
|
||||
tracked -> preferences.filterTracked()
|
||||
mangaType -> {
|
||||
val newIndex = when (view.nameOf(index)) {
|
||||
|
@ -479,10 +489,11 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
binding.groupBy.setIconResource(LibraryGroup.groupTypeDrawableRes(groupType))
|
||||
}
|
||||
|
||||
fun clearFilters() {
|
||||
private fun clearFilters() {
|
||||
preferences.filterDownloaded().set(0)
|
||||
preferences.filterUnread().set(0)
|
||||
preferences.filterCompleted().set(0)
|
||||
preferences.filterBookmarked().set(0)
|
||||
preferences.filterTracked().set(0)
|
||||
preferences.filterMangaType().set(0)
|
||||
FILTER_TRACKER = ""
|
||||
|
@ -536,6 +547,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
Downloaded('d', R.string.downloaded),
|
||||
Completed('c', R.string.status),
|
||||
SeriesType('m', R.string.series_type),
|
||||
Bookmarked('b', R.string.bookmarked),
|
||||
Tracked('t', R.string.tracked),
|
||||
;
|
||||
|
||||
|
@ -546,6 +558,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||
Downloaded,
|
||||
Completed,
|
||||
SeriesType,
|
||||
Bookmarked,
|
||||
Tracked,
|
||||
).joinToString("") { it.value.toString() }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue