diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt index 78a5b8e65..96bb1b1eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt @@ -13,6 +13,7 @@ class UpdatesAdapter( var readColor = context.getResourceColor(R.attr.colorOnSurface, 0.38f) var unreadColor = context.getResourceColor(R.attr.colorOnSurface) + var bookmarkedColor = context.getResourceColor(R.attr.colorAccent) val coverClickListener: OnCoverClickListener = controller diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index d51f2de03..66613d764 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -324,6 +324,11 @@ class UpdatesController : presenter.startDownloadingNow(chapter) } + private fun bookmarkChapters(chapters: List, bookmarked: Boolean) { + presenter.bookmarkChapters(chapters, bookmarked) + destroyActionModeIfNeeded() + } + /** * Called when ActionMode created. * @param mode the ActionMode object @@ -346,6 +351,8 @@ class UpdatesController : val chapters = getSelectedChapters() binding.actionToolbar.findItem(R.id.action_download)?.isVisible = chapters.any { !it.isDownloaded } binding.actionToolbar.findItem(R.id.action_delete)?.isVisible = chapters.any { it.isDownloaded } + binding.actionToolbar.findItem(R.id.action_bookmark)?.isVisible = chapters.any { !it.bookmark } + binding.actionToolbar.findItem(R.id.action_remove_bookmark)?.isVisible = chapters.all { it.bookmark } binding.actionToolbar.findItem(R.id.action_mark_as_read)?.isVisible = chapters.any { !it.chapter.read } binding.actionToolbar.findItem(R.id.action_mark_as_unread)?.isVisible = chapters.all { it.chapter.read } } @@ -370,6 +377,8 @@ class UpdatesController : R.id.action_delete -> ConfirmDeleteChaptersDialog(this, getSelectedChapters()) .showDialog(router) + R.id.action_bookmark -> bookmarkChapters(getSelectedChapters(), true) + R.id.action_remove_bookmark -> bookmarkChapters(getSelectedChapters(), false) R.id.action_mark_as_read -> markAsRead(getSelectedChapters()) R.id.action_mark_as_unread -> markAsUnread(getSelectedChapters()) else -> return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt index 5ba0c7dfb..e0ed10d5b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt @@ -39,15 +39,18 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) // Set manga title binding.mangaTitle.text = item.manga.title - // Check if chapter is read and set correct color + // Check if chapter is read and/or bookmarked and set correct color if (item.chapter.read) { binding.chapterTitle.setTextColor(adapter.readColor) binding.mangaTitle.setTextColor(adapter.readColor) } else { - binding.chapterTitle.setTextColor(adapter.unreadColor) binding.mangaTitle.setTextColor(adapter.unreadColor) + binding.chapterTitle.setTextColor(if (item.bookmark) adapter.bookmarkedColor else adapter.unreadColor) } + // Set bookmark status + binding.bookmarkIcon.isVisible = item.bookmark + // Set chapter status binding.download.isVisible = item.manga.source != LocalSource.ID binding.download.setState(item.status, item.progress) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index d15183063..e1ccdcdda 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -180,6 +180,22 @@ class UpdatesPresenter : BasePresenter() { ) } + /** + * Mark selected chapters as bookmarked + * @param items list of selected chapters + * @param bookmarked bookmark status + */ + fun bookmarkChapters(items: List, bookmarked: Boolean) { + val chapters = items.map { it.chapter } + chapters.forEach { + it.bookmark = bookmarked + } + + Observable.fromCallable { db.updateChaptersProgress(chapters).executeAsBlocking() } + .subscribeOn(Schedulers.io()) + .subscribe() + } + /** * Download selected chapters * @param items list of recent chapters seleted. diff --git a/app/src/main/res/layout/updates_item.xml b/app/src/main/res/layout/updates_item.xml index 257b9aeea..23bdf2d9a 100644 --- a/app/src/main/res/layout/updates_item.xml +++ b/app/src/main/res/layout/updates_item.xml @@ -37,17 +37,31 @@ app:layout_constraintVertical_chainStyle="packed" tools:text="Manga title" /> + + diff --git a/app/src/main/res/menu/updates_chapter_selection.xml b/app/src/main/res/menu/updates_chapter_selection.xml index 40713c00c..1de5670e5 100644 --- a/app/src/main/res/menu/updates_chapter_selection.xml +++ b/app/src/main/res/menu/updates_chapter_selection.xml @@ -16,6 +16,20 @@ app:iconTint="?attr/colorOnToolbar" app:showAsAction="always" /> + + + +