Add quick clean E-Hentai/nHentai titles, select them in your library and you can quick clean them
This commit is contained in:
parent
594a02fa69
commit
44c9df8c9b
@ -41,6 +41,9 @@ import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight
|
|||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import exh.EH_SOURCE_ID
|
||||||
|
import exh.EXH_SOURCE_ID
|
||||||
|
import exh.NHENTAI_SOURCE_ID
|
||||||
import exh.favorites.FavoritesIntroDialog
|
import exh.favorites.FavoritesIntroDialog
|
||||||
import exh.favorites.FavoritesSyncStatus
|
import exh.favorites.FavoritesSyncStatus
|
||||||
import exh.ui.LoaderManager
|
import exh.ui.LoaderManager
|
||||||
@ -522,6 +525,10 @@ class LibraryController(
|
|||||||
mode.title = count.toString()
|
mode.title = count.toString()
|
||||||
|
|
||||||
binding.actionToolbar.findItem(R.id.action_download_unread)?.isVisible = selectedMangas.any { it.source != LocalSource.ID }
|
binding.actionToolbar.findItem(R.id.action_download_unread)?.isVisible = selectedMangas.any { it.source != LocalSource.ID }
|
||||||
|
|
||||||
|
// SY -->
|
||||||
|
binding.actionToolbar.findItem(R.id.action_clean)?.isVisible = selectedMangas.any { it.source == EH_SOURCE_ID || it.source == EXH_SOURCE_ID }
|
||||||
|
// SY <--
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -540,9 +547,11 @@ class LibraryController(
|
|||||||
// SY -->
|
// SY -->
|
||||||
R.id.action_migrate -> {
|
R.id.action_migrate -> {
|
||||||
val skipPre = preferences.skipPreMigration().get()
|
val skipPre = preferences.skipPreMigration().get()
|
||||||
PreMigrationController.navigateToMigration(skipPre, router, selectedMangas.mapNotNull { it.id })
|
presenter.onOpenManga()
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
|
PreMigrationController.navigateToMigration(skipPre, router, selectedMangas.mapNotNull { it.id })
|
||||||
}
|
}
|
||||||
|
R.id.action_clean -> cleanTitles()
|
||||||
// SY <--
|
// SY <--
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
@ -627,6 +636,14 @@ class LibraryController(
|
|||||||
DeleteLibraryMangasDialog(this, selectedMangas.toList()).showDialog(router)
|
DeleteLibraryMangasDialog(this, selectedMangas.toList()).showDialog(router)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SY -->
|
||||||
|
private fun cleanTitles() {
|
||||||
|
val mangas = selectedMangas.filter { it.source == EH_SOURCE_ID || it.source == EXH_SOURCE_ID || it.source == NHENTAI_SOURCE_ID }.toList()
|
||||||
|
presenter.cleanTitles(mangas)
|
||||||
|
destroyActionModeIfNeeded()
|
||||||
|
}
|
||||||
|
// SY <--
|
||||||
|
|
||||||
override fun updateCategoriesForMangas(mangas: List<Manga>, categories: List<Category>) {
|
override fun updateCategoriesForMangas(mangas: List<Manga>, categories: List<Category>) {
|
||||||
presenter.moveMangasToCategories(categories, mangas)
|
presenter.moveMangasToCategories(categories, mangas)
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
|
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
|
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.Filter.TriState.Companion.STATE_EXCLUDE
|
import eu.kanade.tachiyomi.source.model.Filter.TriState.Companion.STATE_EXCLUDE
|
||||||
@ -25,6 +26,7 @@ import exh.EH_SOURCE_ID
|
|||||||
import exh.EXH_SOURCE_ID
|
import exh.EXH_SOURCE_ID
|
||||||
import exh.favorites.FavoritesSyncHelper
|
import exh.favorites.FavoritesSyncHelper
|
||||||
import exh.util.isLewd
|
import exh.util.isLewd
|
||||||
|
import exh.util.nullIfBlank
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.Comparator
|
import java.util.Comparator
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
@ -52,7 +54,10 @@ class LibraryPresenter(
|
|||||||
private val preferences: PreferencesHelper = Injekt.get(),
|
private val preferences: PreferencesHelper = Injekt.get(),
|
||||||
private val coverCache: CoverCache = Injekt.get(),
|
private val coverCache: CoverCache = Injekt.get(),
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
private val downloadManager: DownloadManager = Injekt.get()
|
private val downloadManager: DownloadManager = Injekt.get(),
|
||||||
|
// SY -->
|
||||||
|
private val customMangaManager: CustomMangaManager = Injekt.get()
|
||||||
|
// SY <--
|
||||||
) : BasePresenter<LibraryController>() {
|
) : BasePresenter<LibraryController>() {
|
||||||
|
|
||||||
private val context = preferences.context
|
private val context = preferences.context
|
||||||
@ -366,6 +371,34 @@ class LibraryPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SY -->
|
||||||
|
fun cleanTitles(mangas: List<Manga>) {
|
||||||
|
mangas.forEach { manga ->
|
||||||
|
val editedTitle = manga.title.replace("\\[.*?]".toRegex(), "").trim().replace("\\(.*?\\)".toRegex(), "").trim().replace("\\{.*?\\}".toRegex(), "").trim().let {
|
||||||
|
if (it.contains("|")) {
|
||||||
|
it.replace(".*\\|".toRegex(), "").trim()
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (manga.title == editedTitle) return@forEach
|
||||||
|
val mangaJson = manga.id?.let {
|
||||||
|
CustomMangaManager.MangaJson(
|
||||||
|
it,
|
||||||
|
editedTitle.nullIfBlank(),
|
||||||
|
(if (manga.author != manga.originalAuthor) manga.author else null),
|
||||||
|
(if (manga.artist != manga.originalArtist) manga.artist else null),
|
||||||
|
(if (manga.description != manga.originalDescription) manga.description else null),
|
||||||
|
(if (manga.genre != manga.originalGenre) manga.getGenres()?.toTypedArray() else null)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
mangaJson?.let {
|
||||||
|
customMangaManager.saveMangaInfo(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// SY <--
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the selected manga from the library.
|
* Remove the selected manga from the library.
|
||||||
*
|
*
|
||||||
|
@ -23,6 +23,13 @@
|
|||||||
app:iconTint="?attr/colorOnPrimary"
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_clean"
|
||||||
|
android:icon="@drawable/baseline_swap_calls_24"
|
||||||
|
android:title="@string/clean_titles"
|
||||||
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_select_inverse"
|
android:id="@+id/action_select_inverse"
|
||||||
android:icon="@drawable/ic_flip_to_back_24dp"
|
android:icon="@drawable/ic_flip_to_back_24dp"
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<string name="action_search_manually">Search manually</string>
|
<string name="action_search_manually">Search manually</string>
|
||||||
<string name="action_migrate_now">Migrate now</string>
|
<string name="action_migrate_now">Migrate now</string>
|
||||||
<string name="action_copy_now">Copy now</string>
|
<string name="action_copy_now">Copy now</string>
|
||||||
|
<string name="clean_titles">Clean titles</string>
|
||||||
|
|
||||||
<!-- Manga Type -->
|
<!-- Manga Type -->
|
||||||
<string name="manhwa">Manhwa</string>
|
<string name="manhwa">Manhwa</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user