mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 17:21:53 +01:00
Migration updates
When searching manually, the sources used for auto migration will also be used for searching Can now migrate to the same source if it is the only source being used for migration (for those who cant stop using kakalot)
This commit is contained in:
parent
c4f1183dc4
commit
a3305171d6
@ -13,17 +13,19 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
|
||||||
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
||||||
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
|
||||||
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
||||||
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class SearchController(
|
class SearchController(
|
||||||
private var manga: Manga? = null
|
private var manga: Manga? = null,
|
||||||
|
private var sources: List<CatalogueSource>? = null
|
||||||
) : GlobalSearchController(manga?.title), BottomNavBarInterface {
|
) : GlobalSearchController(manga?.title), BottomNavBarInterface {
|
||||||
|
|
||||||
private var newManga: Manga? = null
|
private var newManga: Manga? = null
|
||||||
@ -45,7 +47,7 @@ class SearchController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createPresenter(): GlobalSearchPresenter {
|
override fun createPresenter(): GlobalSearchPresenter {
|
||||||
return SearchPresenter(initialQuery, manga!!)
|
return SearchPresenter(initialQuery, manga!!, sources = sources)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
@ -2,14 +2,15 @@ package eu.kanade.tachiyomi.ui.migration
|
|||||||
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchMangaItem
|
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchItem
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchItem
|
||||||
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchMangaItem
|
||||||
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchPresenter
|
||||||
|
|
||||||
class SearchPresenter(
|
class SearchPresenter(
|
||||||
initialQuery: String? = "",
|
initialQuery: String? = "",
|
||||||
private val manga: Manga
|
private val manga: Manga,
|
||||||
) : GlobalSearchPresenter(initialQuery) {
|
sources: List<CatalogueSource>? = null
|
||||||
|
) : GlobalSearchPresenter(initialQuery, sourcesToUse = sources) {
|
||||||
|
|
||||||
override fun getEnabledSources(): List<CatalogueSource> {
|
override fun getEnabledSources(): List<CatalogueSource> {
|
||||||
// Put the source of the selected manga at the top
|
// Put the source of the selected manga at the top
|
||||||
|
@ -151,8 +151,10 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
|
|
||||||
val result = try {
|
val result = try {
|
||||||
CoroutineScope(manga.migrationJob).async {
|
CoroutineScope(manga.migrationJob).async {
|
||||||
val validSources = sources.filter {
|
val validSources = if (sources.size == 1) {
|
||||||
it.id != mangaSource.id
|
sources
|
||||||
|
} else {
|
||||||
|
sources.filter { it.id != mangaSource.id }
|
||||||
}
|
}
|
||||||
if (useSourceWithMost) {
|
if (useSourceWithMost) {
|
||||||
val sourceSemaphore = Semaphore(3)
|
val sourceSemaphore = Semaphore(3)
|
||||||
@ -162,15 +164,14 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
async {
|
async {
|
||||||
sourceSemaphore.withPermit {
|
sourceSemaphore.withPermit {
|
||||||
try {
|
try {
|
||||||
/* val searchResult = if (useSmartSearch) {
|
|
||||||
smartSearchEngine.smartSearch(source, mangaObj.title)
|
|
||||||
} else {*/
|
|
||||||
val searchResult = smartSearchEngine.normalSearch(
|
val searchResult = smartSearchEngine.normalSearch(
|
||||||
source,
|
source,
|
||||||
mangaObj.title
|
mangaObj.title
|
||||||
)
|
)
|
||||||
|
|
||||||
if (searchResult != null) {
|
if (searchResult != null &&
|
||||||
|
!(searchResult.url == mangaObj.url &&
|
||||||
|
source.id == mangaObj.source)) {
|
||||||
val localManga =
|
val localManga =
|
||||||
smartSearchEngine.networkToLocalManga(
|
smartSearchEngine.networkToLocalManga(
|
||||||
searchResult,
|
searchResult,
|
||||||
@ -321,9 +322,18 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_search_manually -> {
|
R.id.action_search_manually -> {
|
||||||
launchUI {
|
launchUI {
|
||||||
val manga = adapter?.getItem(position) ?: return@launchUI
|
val manga = adapter?.getItem(position)?.manga?.manga() ?: return@launchUI
|
||||||
selectedPosition = position
|
selectedPosition = position
|
||||||
val searchController = SearchController(manga.manga.manga())
|
val sources = preferences.migrationSources().get().split("/").mapNotNull {
|
||||||
|
val value = it.toLongOrNull() ?: return@mapNotNull null
|
||||||
|
sourceManager.get(value) as? CatalogueSource
|
||||||
|
}
|
||||||
|
val validSources = if (sources.size == 1) {
|
||||||
|
sources
|
||||||
|
} else {
|
||||||
|
sources.filter { it.id != manga.source }
|
||||||
|
}
|
||||||
|
val searchController = SearchController(manga, validSources)
|
||||||
searchController.targetController = this@MigrationListController
|
searchController.targetController = this@MigrationListController
|
||||||
router.pushController(searchController.withFadeTransaction())
|
router.pushController(searchController.withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import uy.kohesive.injekt.injectLazy
|
|||||||
open class GlobalSearchPresenter(
|
open class GlobalSearchPresenter(
|
||||||
private val initialQuery: String? = "",
|
private val initialQuery: String? = "",
|
||||||
private val initialExtensionFilter: String? = null,
|
private val initialExtensionFilter: String? = null,
|
||||||
|
private val sourcesToUse: List<CatalogueSource>? = null,
|
||||||
val sourceManager: SourceManager = Injekt.get(),
|
val sourceManager: SourceManager = Injekt.get(),
|
||||||
val db: DatabaseHelper = Injekt.get(),
|
val db: DatabaseHelper = Injekt.get(),
|
||||||
private val preferencesHelper: PreferencesHelper = Injekt.get()
|
private val preferencesHelper: PreferencesHelper = Injekt.get()
|
||||||
@ -117,6 +118,7 @@ open class GlobalSearchPresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getSourcesToQuery(): List<CatalogueSource> {
|
private fun getSourcesToQuery(): List<CatalogueSource> {
|
||||||
|
if (sourcesToUse != null) return sourcesToUse
|
||||||
val filter = extensionFilter
|
val filter = extensionFilter
|
||||||
val enabledSources = getEnabledSources()
|
val enabledSources = getEnabledSources()
|
||||||
if (filter.isNullOrEmpty()) {
|
if (filter.isNullOrEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user