From 27fef68e54d42cf042fb3ea00c10dfa6a914851a Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 21 Apr 2021 13:27:21 -0400 Subject: [PATCH] Swipe to mark as unread in recents Closes #762 --- .../tachiyomi/ui/recents/RecentMangaHolder.kt | 5 +++++ .../tachiyomi/ui/recents/RecentMangaItem.kt | 2 +- .../tachiyomi/ui/recents/RecentsController.kt | 15 +++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt index 96eada0b34..b5516d16b8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaHolder.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaItem.kt index dae5f731f4..5879951064 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentMangaItem.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index f71afb5ff0..9dea13befc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -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() { 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) }