Add mark as read/unread to library (closes #156)
Adapted from e51276a1ac
(cherry picked from commit 8bab1d97988714872cc6d88c2c8fde05389967b9)
This commit is contained in:
parent
04fbb70981
commit
ad62a6b10b
@ -519,6 +519,8 @@ class LibraryController(
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_move_to_category -> showChangeMangaCategoriesDialog()
|
R.id.action_move_to_category -> showChangeMangaCategoriesDialog()
|
||||||
R.id.action_download_unread -> downloadUnreadChapters()
|
R.id.action_download_unread -> downloadUnreadChapters()
|
||||||
|
R.id.action_mark_as_read -> markReadStatus(true)
|
||||||
|
R.id.action_mark_as_unread -> markReadStatus(false)
|
||||||
R.id.action_delete -> showDeleteMangaDialog()
|
R.id.action_delete -> showDeleteMangaDialog()
|
||||||
R.id.action_select_all -> selectAllCategoryManga()
|
R.id.action_select_all -> selectAllCategoryManga()
|
||||||
R.id.action_select_inverse -> selectInverseCategoryManga()
|
R.id.action_select_inverse -> selectInverseCategoryManga()
|
||||||
@ -610,6 +612,12 @@ class LibraryController(
|
|||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun markReadStatus(read: Boolean) {
|
||||||
|
val mangas = selectedMangas.toList()
|
||||||
|
presenter.markReadStatus(mangas, read)
|
||||||
|
destroyActionModeIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
private fun showDeleteMangaDialog() {
|
private fun showDeleteMangaDialog() {
|
||||||
DeleteLibraryMangasDialog(this, selectedMangas.toList()).showDialog(router)
|
DeleteLibraryMangasDialog(this, selectedMangas.toList()).showDialog(router)
|
||||||
}
|
}
|
||||||
|
@ -405,6 +405,36 @@ class LibraryPresenter(
|
|||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks mangas' chapters read status.
|
||||||
|
*
|
||||||
|
* @param mangas the list of manga.
|
||||||
|
*/
|
||||||
|
fun markReadStatus(mangas: List<Manga>, read: Boolean) {
|
||||||
|
mangas.forEach { manga ->
|
||||||
|
launchIO {
|
||||||
|
val chapters = db.getChapters(manga).executeAsBlocking()
|
||||||
|
chapters.forEach {
|
||||||
|
it.read = read
|
||||||
|
if (!read) {
|
||||||
|
it.last_page_read = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.updateChaptersProgress(chapters).executeAsBlocking()
|
||||||
|
|
||||||
|
if (preferences.removeAfterMarkedAsRead()) {
|
||||||
|
deleteChapters(manga, chapters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun deleteChapters(manga: Manga, chapters: List<Chapter>) {
|
||||||
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
|
downloadManager.deleteChapters(chapters, manga, source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the selected manga from the library.
|
* Remove the selected manga from the library.
|
||||||
*
|
*
|
||||||
|
@ -16,6 +16,20 @@
|
|||||||
app:iconTint="?attr/colorOnPrimary"
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_mark_as_read"
|
||||||
|
android:icon="@drawable/ic_done_24dp"
|
||||||
|
android:title="@string/action_mark_as_read"
|
||||||
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_mark_as_unread"
|
||||||
|
android:icon="@drawable/ic_done_outline_24dp"
|
||||||
|
android:title="@string/action_mark_as_unread"
|
||||||
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_delete"
|
android:id="@+id/action_delete"
|
||||||
android:icon="@drawable/ic_delete_24dp"
|
android:icon="@drawable/ic_delete_24dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user