Swipe to mark as unread in recents

Closes #762
This commit is contained in:
Jays2Kings 2021-04-21 13:27:21 -04:00
parent d1d327cfe1
commit 27fef68e54
3 changed files with 17 additions and 5 deletions

View File

@ -98,6 +98,11 @@ class RecentMangaHolder(
}
setTextColor(ChapterUtil.readColor(context, item))
}
if (binding.frontView.translationX == 0f) {
binding.read.setImageResource(
if (item.read) R.drawable.ic_eye_off_24dp else R.drawable.ic_eye_24dp
)
}
val notValidNum = item.mch.chapter.chapter_number <= 0
binding.body.isVisible = !isUpdates
binding.body.text = when {

View File

@ -33,7 +33,7 @@ class RecentMangaItem(
}
override fun isSwipeable(): Boolean {
return mch.manga.id != null && !chapter.read
return mch.manga.id != null
}
override fun equals(other: Any?): Boolean {

View File

@ -524,19 +524,26 @@ class RecentsController(bundle: Bundle? = null) :
val lastRead = chapter.last_page_read
val pagesLeft = chapter.pages_left
lastChapterId = chapter.id
presenter.markChapterRead(chapter, true)
snack = view?.snack(R.string.marked_as_read, Snackbar.LENGTH_INDEFINITE) {
val wasRead = chapter.read
presenter.markChapterRead(chapter, !wasRead)
snack = view?.snack(
if (wasRead) R.string.marked_as_unread
else R.string.marked_as_read,
Snackbar.LENGTH_INDEFINITE
) {
anchorView = activityBinding?.bottomNav
var undoing = false
setAction(R.string.undo) {
presenter.markChapterRead(chapter, false, lastRead, pagesLeft)
presenter.markChapterRead(chapter, wasRead, lastRead, pagesLeft)
undoing = true
}
addCallback(
object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
super.onDismissed(transientBottomBar, event)
if (!undoing && presenter.preferences.removeAfterMarkedAsRead()) {
if (!undoing && presenter.preferences.removeAfterMarkedAsRead() &&
!wasRead
) {
lastChapterId = chapter.id
presenter.deleteChapter(chapter, manga)
}