mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 16:11:51 +01:00
add mark previous as read option in chapter list (#632)
add download unread, mark read, mark unread on library view
This commit is contained in:
parent
68db9a88e6
commit
5989c7119f
@ -56,6 +56,10 @@ open class SourceManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isDelegatedSource(source: Source): Boolean {
|
||||||
|
return delegatedSources.values.count { it.sourceId == source.id } > 0
|
||||||
|
}
|
||||||
|
|
||||||
fun getDelegatedSource(urlName: String): DelegatedHttpSource? {
|
fun getDelegatedSource(urlName: String): DelegatedHttpSource? {
|
||||||
return delegatedSources.values.find { it.urlName == urlName }?.delegatedHttpSource
|
return delegatedSources.values.find { it.urlName == urlName }?.delegatedHttpSource
|
||||||
}
|
}
|
||||||
|
@ -1359,6 +1359,17 @@ class LibraryController(
|
|||||||
deleteMangasFromLibrary()
|
deleteMangasFromLibrary()
|
||||||
}.negativeButton(android.R.string.no).show()
|
}.negativeButton(android.R.string.no).show()
|
||||||
}
|
}
|
||||||
|
R.id.action_download_unread -> {
|
||||||
|
presenter.downloadUnread(selectedMangas.toList())
|
||||||
|
}
|
||||||
|
R.id.action_mark_as_read -> {
|
||||||
|
presenter.markReadStatus(selectedMangas.toList(), true)
|
||||||
|
destroyActionModeIfNeeded()
|
||||||
|
}
|
||||||
|
R.id.action_mark_as_unread -> {
|
||||||
|
presenter.markReadStatus(selectedMangas.toList(), false)
|
||||||
|
destroyActionModeIfNeeded()
|
||||||
|
}
|
||||||
R.id.action_migrate -> {
|
R.id.action_migrate -> {
|
||||||
val skipPre = preferences.skipPreMigration().getOrDefault()
|
val skipPre = preferences.skipPreMigration().getOrDefault()
|
||||||
PreMigrationController.navigateToMigration(
|
PreMigrationController.navigateToMigration(
|
||||||
|
@ -875,6 +875,48 @@ class LibraryPresenter(
|
|||||||
getLibrary()
|
getLibrary()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** download All unread */
|
||||||
|
fun downloadUnread(mangaList: List<Manga>) {
|
||||||
|
scope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
mangaList.forEach {
|
||||||
|
val chapters = db.getChapters(it).executeAsBlocking().filter { !it.read }
|
||||||
|
downloadManager.downloadChapters(it, chapters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (preferences.downloadBadge().getOrDefault()) {
|
||||||
|
requestDownloadBadgesUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun markReadStatus(mangaList: List<Manga>, markRead: Boolean) {
|
||||||
|
scope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
mangaList.forEach {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
val chapters = db.getChapters(it).executeAsBlocking()
|
||||||
|
chapters.forEach {
|
||||||
|
it.read = markRead
|
||||||
|
it.last_page_read = 0
|
||||||
|
}
|
||||||
|
db.updateChaptersProgress(chapters).executeAsBlocking()
|
||||||
|
if (markRead && preferences.removeAfterMarkedAsRead()) {
|
||||||
|
deleteChapters(it, chapters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getLibrary()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun deleteChapters(manga: Manga, chapters: List<Chapter>) {
|
||||||
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
|
downloadManager.deleteChapters(chapters, manga, source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var lastLibraryItems: List<LibraryItem>? = null
|
private var lastLibraryItems: List<LibraryItem>? = null
|
||||||
private var lastCategories: List<Category>? = null
|
private var lastCategories: List<Category>? = null
|
||||||
|
@ -615,7 +615,8 @@ class MangaDetailsController :
|
|||||||
|
|
||||||
popup.setOnMenuItemClickListener { menuItem ->
|
popup.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.action_mark_previous_as_read -> markPreviousAsRead(item)
|
R.id.action_mark_previous_as_read -> markPreviousAs(item, true)
|
||||||
|
R.id.action_mark_previous_as_unread -> markPreviousAs(item, false)
|
||||||
}
|
}
|
||||||
chapterPopupMenu = null
|
chapterPopupMenu = null
|
||||||
true
|
true
|
||||||
@ -644,12 +645,16 @@ class MangaDetailsController :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun markPreviousAsRead(chapter: ChapterItem) {
|
private fun markPreviousAs(chapter: ChapterItem, read: Boolean) {
|
||||||
val adapter = adapter ?: return
|
val adapter = adapter ?: return
|
||||||
val chapters = if (presenter.sortDescending()) adapter.items.reversed() else adapter.items
|
val chapters = if (presenter.sortDescending()) adapter.items.reversed() else adapter.items
|
||||||
val chapterPos = chapters.indexOf(chapter)
|
val chapterPos = chapters.indexOf(chapter)
|
||||||
if (chapterPos != -1) {
|
if (chapterPos != -1) {
|
||||||
markAsRead(chapters.take(chapterPos))
|
if (read) {
|
||||||
|
markAsRead(chapters.take(chapterPos))
|
||||||
|
} else {
|
||||||
|
markAsUnread(chapters.take(chapterPos))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,4 +3,6 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:id="@+id/action_mark_previous_as_read"
|
<item android:id="@+id/action_mark_previous_as_read"
|
||||||
android:title="@string/mark_previous_as_read"/>
|
android:title="@string/mark_previous_as_read"/>
|
||||||
|
<item android:id="@+id/action_mark_previous_as_unread"
|
||||||
|
android:title="@string/mark_previous_as_unread"/>
|
||||||
</menu>
|
</menu>
|
@ -21,9 +21,24 @@
|
|||||||
android:title="@string/source_migration"
|
android:title="@string/source_migration"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_download_unread"
|
||||||
|
android:title="@string/download_unread"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_mark_as_read"
|
||||||
|
android:title="@string/mark_as_read"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_mark_as_unread"
|
||||||
|
android:title="@string/mark_as_unread"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_share"
|
android:id="@+id/action_share"
|
||||||
android:icon="@drawable/ic_share_24dp"
|
android:icon="@drawable/ic_share_24dp"
|
||||||
android:title="@string/share"
|
android:title="@string/share"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
@ -710,6 +710,7 @@
|
|||||||
<string name="delete">Delete</string>
|
<string name="delete">Delete</string>
|
||||||
<string name="deleted_">Deleted: %1$s</string>
|
<string name="deleted_">Deleted: %1$s</string>
|
||||||
<string name="display">Display</string>
|
<string name="display">Display</string>
|
||||||
|
<string name="download_unread">Download unread</string>
|
||||||
<string name="drag_handle">Drag handle</string>
|
<string name="drag_handle">Drag handle</string>
|
||||||
<string name="edit">Edit</string>
|
<string name="edit">Edit</string>
|
||||||
<string name="enabled">Enabled</string>
|
<string name="enabled">Enabled</string>
|
||||||
@ -728,7 +729,9 @@
|
|||||||
<string name="mark_all_as_read">Mark all as read</string>
|
<string name="mark_all_as_read">Mark all as read</string>
|
||||||
<string name="mark_all_as_unread">Mark all as unread</string>
|
<string name="mark_all_as_unread">Mark all as unread</string>
|
||||||
<string name="mark_as_read">Mark as read</string>
|
<string name="mark_as_read">Mark as read</string>
|
||||||
|
<string name="mark_as_unread">Mark as unread</string>
|
||||||
<string name="mark_previous_as_read">Mark previous as read</string>
|
<string name="mark_previous_as_read">Mark previous as read</string>
|
||||||
|
<string name="mark_previous_as_unread">Mark previous as unread</string>
|
||||||
<string name="more">More</string>
|
<string name="more">More</string>
|
||||||
<string name="move_to_bottom">Move to bottom</string>
|
<string name="move_to_bottom">Move to bottom</string>
|
||||||
<string name="move_to_top">Move to top</string>
|
<string name="move_to_top">Move to top</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user