mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 23:39:07 +01:00
Option to delete chapters automatically if the source has removed them
For global updates this is on by default, manga details asks first
This commit is contained in:
parent
e1f26d5497
commit
79745e19d2
@ -105,6 +105,11 @@ class LibraryUpdateService(
|
|||||||
// List containing new updates
|
// List containing new updates
|
||||||
private val newUpdates = mutableMapOf<LibraryManga, Array<Chapter>>()
|
private val newUpdates = mutableMapOf<LibraryManga, Array<Chapter>>()
|
||||||
|
|
||||||
|
// For updates delete removed chapters if not preference is set as well
|
||||||
|
private val deleteRemoved by lazy {
|
||||||
|
preferences.deleteRemovedChapters().get() != 1
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached progress notification to avoid creating a lot.
|
* Cached progress notification to avoid creating a lot.
|
||||||
*/
|
*/
|
||||||
@ -415,6 +420,14 @@ class LibraryUpdateService(
|
|||||||
newUpdates[manga] =
|
newUpdates[manga] =
|
||||||
newChapters.first.sortedBy { it.chapter_number }.toTypedArray()
|
newChapters.first.sortedBy { it.chapter_number }.toTypedArray()
|
||||||
}
|
}
|
||||||
|
if (deleteRemoved && newChapters.second.isNotEmpty()) {
|
||||||
|
val removedChapters = newChapters.second.filter {
|
||||||
|
downloadManager.isChapterDownloaded(it, manga)
|
||||||
|
}
|
||||||
|
if (removedChapters.isNotEmpty()) {
|
||||||
|
downloadManager.deleteChapters(removedChapters, manga, source)
|
||||||
|
}
|
||||||
|
}
|
||||||
if (newChapters.first.size + newChapters.second.size > 0) listener?.onUpdateManga(
|
if (newChapters.first.size + newChapters.second.size > 0) listener?.onUpdateManga(
|
||||||
manga
|
manga
|
||||||
)
|
)
|
||||||
|
@ -79,6 +79,8 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val removeAfterReadSlots = "remove_after_read_slots"
|
const val removeAfterReadSlots = "remove_after_read_slots"
|
||||||
|
|
||||||
|
const val deleteRemovedChapters = "delete_removed_chapters"
|
||||||
|
|
||||||
const val removeAfterMarkedAsRead = "pref_remove_after_marked_as_read_key"
|
const val removeAfterMarkedAsRead = "pref_remove_after_marked_as_read_key"
|
||||||
|
|
||||||
const val libraryUpdateInterval = "pref_library_update_interval_key"
|
const val libraryUpdateInterval = "pref_library_update_interval_key"
|
||||||
|
@ -261,7 +261,9 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun alwaysShowChapterTransition() = rxPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
|
fun alwaysShowChapterTransition() = rxPrefs.getBoolean(Keys.alwaysShowChapterTransition, true)
|
||||||
|
|
||||||
// Tutorial preference
|
fun deleteRemovedChapters() = flowPrefs.getInt(Keys.deleteRemovedChapters, 0)
|
||||||
|
|
||||||
|
// Tutorial preferences
|
||||||
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
|
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
|
||||||
|
|
||||||
fun shownChapterSwipeTutorial() = flowPrefs.getBoolean("shown_swipe_tutorial", false)
|
fun shownChapterSwipeTutorial() = flowPrefs.getBoolean("shown_swipe_tutorial", false)
|
||||||
|
@ -45,6 +45,8 @@ import androidx.transition.ChangeImageTransform
|
|||||||
import androidx.transition.TransitionManager
|
import androidx.transition.TransitionManager
|
||||||
import androidx.transition.TransitionSet
|
import androidx.transition.TransitionSet
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
import com.afollestad.materialdialogs.checkbox.checkBoxPrompt
|
||||||
|
import com.afollestad.materialdialogs.checkbox.isCheckPromptChecked
|
||||||
import com.afollestad.materialdialogs.list.listItems
|
import com.afollestad.materialdialogs.list.listItems
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
@ -575,6 +577,31 @@ class MangaDetailsController : BaseController,
|
|||||||
view?.snack(message)
|
view?.snack(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showChaptersRemovedPopup(deletedChapters: List<ChapterItem>) {
|
||||||
|
val context = activity ?: return
|
||||||
|
val deleteRemovedPref = presenter.preferences.deleteRemovedChapters()
|
||||||
|
when (deleteRemovedPref.get()) {
|
||||||
|
2 -> {
|
||||||
|
presenter.deleteChapters(deletedChapters, false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
1 -> return
|
||||||
|
else -> {
|
||||||
|
MaterialDialog(context).title(R.string.chapters_removed).message(
|
||||||
|
text = context.resources.getQuantityString(R.plurals.deleted_chapters,
|
||||||
|
deletedChapters.size,
|
||||||
|
deletedChapters.size,
|
||||||
|
deletedChapters.joinToString("\n") { "${it.name}" })
|
||||||
|
).positiveButton(R.string.delete) {
|
||||||
|
presenter.deleteChapters(deletedChapters, false)
|
||||||
|
if (it.isCheckPromptChecked()) deleteRemovedPref.set(2)
|
||||||
|
}.negativeButton(R.string.keep) {
|
||||||
|
if (it.isCheckPromptChecked()) deleteRemovedPref.set(1)
|
||||||
|
}.cancelOnTouchOutside(false).checkBoxPrompt(R.string.remember_this_choice) {}.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setRefresh(enabled: Boolean) {
|
fun setRefresh(enabled: Boolean) {
|
||||||
swipe_refresh.isRefreshing = enabled
|
swipe_refresh.isRefreshing = enabled
|
||||||
}
|
}
|
||||||
|
@ -423,6 +423,19 @@ class MangaDetailsPresenter(
|
|||||||
.map { it.toModel() })
|
.map { it.toModel() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (newChapters.second.isNotEmpty()) {
|
||||||
|
val removedChaptersId = newChapters.second.map { it.id }
|
||||||
|
val removedChapters = this@MangaDetailsPresenter.chapters.filter {
|
||||||
|
it.id in removedChaptersId && it.isDownloaded
|
||||||
|
}
|
||||||
|
if (removedChapters.isNotEmpty()) {
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
controller.showChaptersRemovedPopup(
|
||||||
|
removedChapters
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
withContext(Dispatchers.IO) { updateChapters() }
|
withContext(Dispatchers.IO) { updateChapters() }
|
||||||
}
|
}
|
||||||
isLoading = false
|
isLoading = false
|
||||||
|
@ -102,6 +102,20 @@ class SettingsDownloadController : SettingsController() {
|
|||||||
selectedCategories.joinToString { it.name }
|
selectedCategories.joinToString { it.name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
preferenceCategory {
|
||||||
|
intListPreference(activity) {
|
||||||
|
key = Keys.deleteRemovedChapters
|
||||||
|
titleRes = R.string.delete_removed_chapters
|
||||||
|
customSummary = activity?.getString(R.string.delete_downloaded_if_removed_online)
|
||||||
|
entriesRes = arrayOf(
|
||||||
|
R.string.ask_on_chapters_page,
|
||||||
|
R.string.always_keep,
|
||||||
|
R.string.always_delete
|
||||||
|
)
|
||||||
|
entryRange = 0..2
|
||||||
|
defaultValue = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ fun syncChaptersWithSource(
|
|||||||
db.updateLastUpdated(manga).executeAsBlocking()
|
db.updateLastUpdated(manga).executeAsBlocking()
|
||||||
}
|
}
|
||||||
|
|
||||||
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
return Pair(toAdd.subtract(readded).toList(), toDelete - readded)
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if the chapter in db needs updated
|
// checks if the chapter in db needs updated
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<string name="marked_as_read">Marked as read</string>
|
<string name="marked_as_read">Marked as read</string>
|
||||||
<string name="marked_as_unread">Marked as unread</string>
|
<string name="marked_as_unread">Marked as unread</string>
|
||||||
<string name="removed_bookmark">Removed bookmark</string>
|
<string name="removed_bookmark">Removed bookmark</string>
|
||||||
|
<string name="chapters_removed">Chapters removed.</string>
|
||||||
<plurals name="remove_n_chapters">
|
<plurals name="remove_n_chapters">
|
||||||
<item quantity="one">Remove %1$d downloaded chapter?</item>
|
<item quantity="one">Remove %1$d downloaded chapter?</item>
|
||||||
<item quantity="other">Remove %1$d downloaded chapters?</item>
|
<item quantity="other">Remove %1$d downloaded chapters?</item>
|
||||||
@ -368,6 +369,13 @@
|
|||||||
<string name="reset_cover">Reset cover</string>
|
<string name="reset_cover">Reset cover</string>
|
||||||
<string name="failed_to_update_cover">Failed to update cover</string>
|
<string name="failed_to_update_cover">Failed to update cover</string>
|
||||||
<string name="must_be_in_library_to_edit">Manga must be in your library to edit</string>
|
<string name="must_be_in_library_to_edit">Manga must be in your library to edit</string>
|
||||||
|
<string name="remember_this_choice">Remember this choice</string>
|
||||||
|
<plurals name="deleted_chapters">
|
||||||
|
<item quantity="one">A chapter has been removed from the source:\n%2$s\nDelete
|
||||||
|
its download?</item>
|
||||||
|
<item quantity="other">%1$s chapters have been removed from the source:\n%2$s\n\nDelete
|
||||||
|
their downloads?</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
<!-- Tracking -->
|
<!-- Tracking -->
|
||||||
<string name="tracking">Tracking</string>
|
<string name="tracking">Tracking</string>
|
||||||
@ -575,6 +583,12 @@
|
|||||||
<string name="fifth_to_last">Fifth to last chapter</string>
|
<string name="fifth_to_last">Fifth to last chapter</string>
|
||||||
<string name="download_new_chapters">Download new chapters</string>
|
<string name="download_new_chapters">Download new chapters</string>
|
||||||
<string name="categories_to_include_in_download">Categories to include in download</string>
|
<string name="categories_to_include_in_download">Categories to include in download</string>
|
||||||
|
<string name="delete_removed_chapters">Delete removed chapters</string>
|
||||||
|
<string name="delete_downloaded_if_removed_online">Delete downloaded chapters if the source
|
||||||
|
has removed the chapter online</string>
|
||||||
|
<string name="ask_on_chapters_page">Delete during global updates, ask on chapters page</string>
|
||||||
|
<string name="always_keep">Always keep</string>
|
||||||
|
<string name="always_delete">Always delete</string>
|
||||||
|
|
||||||
<!-- Time -->
|
<!-- Time -->
|
||||||
<string name="manual">Manual</string>
|
<string name="manual">Manual</string>
|
||||||
@ -633,6 +647,7 @@
|
|||||||
<string name="hide">Hide</string>
|
<string name="hide">Hide</string>
|
||||||
<string name="ignore">Ignore</string>
|
<string name="ignore">Ignore</string>
|
||||||
<string name="install">Install</string>
|
<string name="install">Install</string>
|
||||||
|
<string name="keep">Keep</string>
|
||||||
<string name="left">Left</string>
|
<string name="left">Left</string>
|
||||||
<string name="less">Less</string>
|
<string name="less">Less</string>
|
||||||
<string name="loading">Loading…</string>
|
<string name="loading">Loading…</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user