diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchHolder.kt index b0c06cbbe4..d189ada45c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchHolder.kt @@ -45,8 +45,11 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) : val source = item.source val results = item.results - // Set Title witch country code if available. - title.text = if (!source.lang.isEmpty()) "${source.name} (${source.lang})" else source.name + val titlePrefix = if (item.highlighted) "▶" else "" + val langSuffix = if (source.lang.isNotEmpty()) " (${source.lang})" else "" + + // Set Title with country code if available. + title.text = titlePrefix + source.name + langSuffix when { results == null -> { @@ -93,5 +96,4 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) : return null } - } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchItem.kt index 7722a32029..9fe950082c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchItem.kt @@ -9,9 +9,11 @@ import eu.kanade.tachiyomi.source.CatalogueSource /** * Item that contains search result information. * - * @param source contains information about search result. + * @param source the source for the search results. + * @param results the search results. + * @param highlighted whether this search item should be highlighted/marked in the catalogue search view. */ -class CatalogueSearchItem(val source: CatalogueSource, val results: List?) +class CatalogueSearchItem(val source: CatalogueSource, val results: List?, val highlighted: Boolean = false) : AbstractFlexibleItem() { /** @@ -61,4 +63,4 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List?): CatalogueSearchItem { + return CatalogueSearchItem(source, results) + } + + /** + * Initiates a search for manga per catalogue. * * @param query query on which to search. */ @@ -113,7 +120,7 @@ open class CatalogueSearchPresenter( initializeFetchImageSubscription() // Create items with the initial state - val initialItems = sources.map { CatalogueSearchItem(it, null) } + val initialItems = sources.map { createCatalogueSearchItem(it, null) } var items = initialItems fetchSourcesSubscription?.unsubscribe() @@ -125,7 +132,7 @@ open class CatalogueSearchPresenter( .map { it.mangas.take(10) } // Get at most 10 manga from search result. .map { it.map { networkToLocalManga(it, source.id) } } // Convert to local manga. .doOnNext { fetchImage(it, source) } // Load manga covers. - .map { CatalogueSearchItem(source, it.map { CatalogueSearchCardItem(it) }) } + .map { createCatalogueSearchItem(source, it.map { CatalogueSearchCardItem(it) }) } }, 5) .observeOn(AndroidSchedulers.mainThread()) // Update matching source with the obtained results @@ -212,4 +219,4 @@ open class CatalogueSearchPresenter( } return localManga } -} \ No newline at end of file +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchPresenter.kt index 09f4ea6b5a..2a7f218b8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchPresenter.kt @@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.migration import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.CatalogueSource +import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchCardItem +import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchItem import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchPresenter class SearchPresenter( @@ -10,8 +12,13 @@ class SearchPresenter( ) : CatalogueSearchPresenter(initialQuery) { override fun getEnabledSources(): List { - // Filter out the source of the selected manga + // Put the source of the selected manga at the top return super.getEnabledSources() - .filterNot { it.id == manga.source } + .sortedByDescending { it.id == manga.source } } -} \ No newline at end of file + + override fun createCatalogueSearchItem(source: CatalogueSource, results: List?): CatalogueSearchItem { + //Set the catalogue search item as highlighted if the source matches that of the selected manga + return CatalogueSearchItem(source, results, source.id == manga.source) + } +}