Skip to content

Commit

Permalink
Added long click shortcut to mark chapter as read in Reader view chap…
Browse files Browse the repository at this point in the history
…ter list sheet
  • Loading branch information
Saud-97 committed Jan 30, 2024
1 parent 448b77b commit 4fdb245
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,18 @@ class ReaderViewModel(
db.updateChapterProgress(chapter).executeAsBlocking()
}

fun toggleRead(chapter: Chapter) {
chapter.read = !chapter.read
db.updateChapterProgress(chapter).executeAsBlocking()
if (chapter.read) {
if (preferences.removeAfterMarkedAsRead()) {
enqueueDeleteReadChapters(ReaderChapter(chapter))
} else {
deleteChapterIfNeeded(ReaderChapter(chapter))
}
}
}

/**
* Called when the viewers decide it's a good time to preload a [chapter] and improve the UX so
* that the user doesn't have to wait too long to continue reading.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr

adapter = FastAdapter.with(itemAdapter)
binding.chapterRecycler.adapter = adapter
adapter?.onLongClickListener = { _, _, item, _ ->

if (!sheetBehavior.isExpanded() || activity.isLoading) {
false
} else {
if (item.chapter.id != viewModel.getCurrentChapter()?.chapter?.id) {
viewModel.toggleRead(item.chapter)
refreshList()
}
true
}
}

adapter?.onClickListener = { _, _, item, position ->
if (!sheetBehavior.isExpanded() || activity.isLoading) {
false
Expand Down

0 comments on commit 4fdb245

Please sign in to comment.