diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 4a4a051876..80ea85568c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -58,7 +58,7 @@ import eu.kanade.tachiyomi.ui.main.RootSearchInterface import eu.kanade.tachiyomi.ui.manga.MangaDetailsController import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController +import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.launchUI @@ -944,7 +944,7 @@ class LibraryController( } override fun globalSearch(query: String) { - router.pushController(SourceSearchController(query).withFadeTransaction()) + router.pushController(GlobalSearchController(query).withFadeTransaction()) } override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt index 556074ac34..8cbfa8e1d7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt @@ -7,7 +7,7 @@ import com.bluelinelabs.conductor.Controller import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController +import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.withFadeTransaction import kotlinx.android.synthetic.main.main_activity.* @@ -67,7 +67,7 @@ class SearchActivity : MainActivity() { // Get the search query provided in extras, and if not null, perform a global search with it. val query = intent.getStringExtra(SearchManager.QUERY) if (query != null && query.isNotEmpty()) { - router.replaceTopController(SourceSearchController(query).withFadeTransaction()) + router.replaceTopController(GlobalSearchController(query).withFadeTransaction()) } } INTENT_SEARCH -> { @@ -77,7 +77,7 @@ class SearchActivity : MainActivity() { if (router.backstackSize > 1) { router.popToRoot() } - router.replaceTopController(SourceSearchController(query, filter).withFadeTransaction()) + router.replaceTopController(GlobalSearchController(query, filter).withFadeTransaction()) } } else -> return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index 88e3cc92c5..f5b8e1909a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -88,7 +88,7 @@ import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.ui.source.SourceController -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController +import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.ThemeUtil @@ -1011,7 +1011,7 @@ class MangaDetailsController : BaseController, override fun globalSearch(text: String) { if (isNotOnline()) return - router.pushController(SourceSearchController(text).withFadeTransaction()) + router.pushController(GlobalSearchController(text).withFadeTransaction()) } override fun showChapterFilter() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt index 1101ce8524..2cd28f2311 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt @@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.ui.base.controller.DialogController -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter +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.migration.manga.process.MigrationListController import eu.kanade.tachiyomi.util.view.withFadeTransaction @@ -24,7 +24,7 @@ import uy.kohesive.injekt.injectLazy class SearchController( private var manga: Manga? = null -) : SourceSearchController(manga?.title), BottomNavBarInterface { +) : GlobalSearchController(manga?.title), BottomNavBarInterface { private var newManga: Manga? = null private var progress = 1 @@ -44,7 +44,7 @@ class SearchController( return super.getTitle() } - override fun createPresenter(): SourceSearchPresenter { + override fun createPresenter(): GlobalSearchPresenter { return SearchPresenter(initialQuery, manga!!) } 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 df79579c7d..040fbb310e 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,14 +2,14 @@ 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.source.global_search.SourceSearchCardItem -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchItem -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter +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.GlobalSearchPresenter class SearchPresenter( initialQuery: String? = "", private val manga: Manga -) : SourceSearchPresenter(initialQuery) { +) : GlobalSearchPresenter(initialQuery) { override fun getEnabledSources(): List { // Put the source of the selected manga at the top @@ -17,8 +17,8 @@ class SearchPresenter( .sortedByDescending { it.id == manga.source } } - override fun createCatalogueSearchItem(source: CatalogueSource, results: List?): SourceSearchItem { + override fun createCatalogueSearchItem(source: CatalogueSource, results: List?): GlobalSearchItem { // Set the catalogue search item as highlighted if the source matches that of the selected manga - return SourceSearchItem(source, results, source.id == manga.source) + return GlobalSearchItem(source, results, source.id == manga.source) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt index 54a9a91c1d..a74287cf09 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceController.kt @@ -30,7 +30,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.RootSearchInterface import eu.kanade.tachiyomi.ui.setting.SettingsSourcesController import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController +import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController import eu.kanade.tachiyomi.util.view.collapse @@ -333,7 +333,7 @@ class SourceController : NucleusController(), } private fun performGlobalSearch(query: String) { - router.pushController(SourceSearchController(query).withFadeTransaction()) + router.pushController(GlobalSearchController(query).withFadeTransaction()) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchAdapter.kt similarity index 92% rename from app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchAdapter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchAdapter.kt index 7499a76f6b..8aac1f809b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchAdapter.kt @@ -8,10 +8,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter /** * Adapter that holds the search cards. * - * @param controller instance of [SourceSearchController]. + * @param controller instance of [GlobalSearchController]. */ -class SourceSearchAdapter(val controller: SourceSearchController) : - FlexibleAdapter(null, controller, true) { +class GlobalSearchAdapter(val controller: GlobalSearchController) : + FlexibleAdapter(null, controller, true) { /** * Bundle where the view state of the holders is saved. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchCardAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchCardAdapter.kt similarity index 68% rename from app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchCardAdapter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchCardAdapter.kt index 3bf479c49b..ce4f981404 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchCardAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchCardAdapter.kt @@ -6,10 +6,10 @@ import eu.kanade.tachiyomi.data.database.models.Manga /** * Adapter that holds the manga items from search results. * - * @param controller instance of [SourceSearchController]. + * @param controller instance of [GlobalSearchController]. */ -class SourceSearchCardAdapter(controller: SourceSearchController) : - FlexibleAdapter(null, controller, true) { +class GlobalSearchCardAdapter(controller: GlobalSearchController) : + FlexibleAdapter(null, controller, true) { /** * Listen for browse item clicks. @@ -18,7 +18,7 @@ class SourceSearchCardAdapter(controller: SourceSearchController) : /** * Listener which should be called when user clicks browse. - * Note: Should only be handled by [SourceSearchController] + * Note: Should only be handled by [GlobalSearchController] */ interface OnMangaClickListener { fun onMangaClick(manga: Manga) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchController.kt similarity index 89% rename from app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchController.kt index f10add9fbf..e008ff178d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchController.kt @@ -22,19 +22,19 @@ import kotlinx.android.synthetic.main.source_global_search_controller.* /** * This controller shows and manages the different search result in global search. - * This controller should only handle UI actions, IO actions should be done by [SourceSearchPresenter] - * [SourceSearchCardAdapter.OnMangaClickListener] called when manga is clicked in global search + * This controller should only handle UI actions, IO actions should be done by [GlobalSearchPresenter] + * [GlobalSearchCardAdapter.OnMangaClickListener] called when manga is clicked in global search */ -open class SourceSearchController( +open class GlobalSearchController( protected val initialQuery: String? = null, protected val extensionFilter: String? = null -) : NucleusController(), - SourceSearchCardAdapter.OnMangaClickListener { +) : NucleusController(), + GlobalSearchCardAdapter.OnMangaClickListener { /** * Adapter containing search results grouped by lang. */ - protected var adapter: SourceSearchAdapter? = null + protected var adapter: GlobalSearchAdapter? = null private var customTitle: String? = null @@ -66,12 +66,12 @@ open class SourceSearchController( } /** - * Create the [SourceSearchPresenter] used in controller. + * Create the [GlobalSearchPresenter] used in controller. * - * @return instance of [SourceSearchPresenter] + * @return instance of [GlobalSearchPresenter] */ - override fun createPresenter(): SourceSearchPresenter { - return SourceSearchPresenter(initialQuery, extensionFilter) + override fun createPresenter(): GlobalSearchPresenter { + return GlobalSearchPresenter(initialQuery, extensionFilter) } /** @@ -137,7 +137,7 @@ open class SourceSearchController( */ override fun onViewCreated(view: View) { super.onViewCreated(view) - adapter = SourceSearchAdapter(this) + adapter = GlobalSearchAdapter(this) recycler.updatePaddingRelative( top = (activity?.toolbar?.height ?: 0) + @@ -175,13 +175,13 @@ open class SourceSearchController( * @param source used to find holder containing source * @return the holder of the manga or null if it's not bound. */ - private fun getHolder(source: CatalogueSource): SourceSearchHolder? { + private fun getHolder(source: CatalogueSource): GlobalSearchHolder? { val adapter = adapter ?: return null adapter.allBoundViewHolders.forEach { holder -> val item = adapter.getItem(holder.adapterPosition) if (item != null && source.id == item.source.id) { - return holder as SourceSearchHolder + return holder as GlobalSearchHolder } } @@ -193,7 +193,7 @@ open class SourceSearchController( * * @param searchResult result of search. */ - fun setItems(searchResult: List) { + fun setItems(searchResult: List) { if (extensionFilter != null) { val results = searchResult.first().results if (results != null && results.size == 1) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchHolder.kt similarity index 82% rename from app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchHolder.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchHolder.kt index 018a3c88fc..af06e8b14d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchHolder.kt @@ -8,20 +8,20 @@ import eu.kanade.tachiyomi.util.view.visible import kotlinx.android.synthetic.main.source_global_search_controller_card.* /** - * Holder that binds the [SourceSearchItem] containing catalogue cards. + * Holder that binds the [GlobalSearchItem] containing catalogue cards. * - * @param view view of [SourceSearchItem] - * @param adapter instance of [SourceSearchAdapter] + * @param view view of [GlobalSearchItem] + * @param adapter instance of [GlobalSearchAdapter] */ -class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) : +class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) : BaseFlexibleViewHolder(view, adapter) { /** * Adapter containing manga from search results. */ - private val mangaAdapter = SourceSearchCardAdapter(adapter.controller) + private val mangaAdapter = GlobalSearchCardAdapter(adapter.controller) - private var lastBoundResults: List? = null + private var lastBoundResults: List? = null init { // Set layout horizontal. @@ -35,7 +35,7 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) : * * @param item item of card. */ - fun bind(item: SourceSearchItem) { + fun bind(item: GlobalSearchItem) { val source = item.source val results = item.results @@ -81,11 +81,11 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) : * @param manga the manga to find. * @return the holder of the manga or null if it's not bound. */ - private fun getHolder(manga: Manga): SourceSearchCardHolder? { + private fun getHolder(manga: Manga): GlobalSearchMangaHolder? { mangaAdapter.allBoundViewHolders.forEach { holder -> val item = mangaAdapter.getItem(holder.adapterPosition) if (item != null && item.manga.id!! == manga.id!!) { - return holder as SourceSearchCardHolder + return holder as GlobalSearchMangaHolder } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchItem.kt similarity index 78% rename from app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchItem.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchItem.kt index 60ef00d2f0..f2112c0c45 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/SourceSearchItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchItem.kt @@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource * @param results the search results. * @param highlighted whether this search item should be highlighted/marked in the catalogue search view. */ -class SourceSearchItem(val source: CatalogueSource, val results: List?, val highlighted: Boolean = false) : - AbstractFlexibleItem() { +class GlobalSearchItem(val source: CatalogueSource, val results: List?, val highlighted: Boolean = false) : + AbstractFlexibleItem() { /** * Set view. @@ -28,12 +28,12 @@ class SourceSearchItem(val source: CatalogueSource, val results: List>): SourceSearchHolder { - return SourceSearchHolder(view, adapter as SourceSearchAdapter) + override fun createViewHolder(view: View, adapter: FlexibleAdapter>): GlobalSearchHolder { + return GlobalSearchHolder(view, adapter as GlobalSearchAdapter) } /** @@ -41,7 +41,7 @@ class SourceSearchItem(val source: CatalogueSource, val results: List>, - holder: SourceSearchHolder, + holder: GlobalSearchHolder, position: Int, payloads: MutableList? ) { @@ -54,7 +54,7 @@ class SourceSearchItem(val source: CatalogueSource, val results: List() { +class GlobalSearchMangaItem(val manga: Manga) : AbstractFlexibleItem() { override fun getLayoutRes(): Int { return R.layout.source_global_search_controller_card_item } - override fun createViewHolder(view: View, adapter: FlexibleAdapter>): SourceSearchCardHolder { - return SourceSearchCardHolder(view, adapter as SourceSearchCardAdapter) + override fun createViewHolder(view: View, adapter: FlexibleAdapter>): GlobalSearchMangaHolder { + return GlobalSearchMangaHolder(view, adapter as GlobalSearchCardAdapter) } override fun bindViewHolder( adapter: FlexibleAdapter>, - holder: SourceSearchCardHolder, + holder: GlobalSearchMangaHolder, position: Int, payloads: MutableList? ) { @@ -28,7 +28,7 @@ class SourceSearchCardItem(val manga: Manga) : AbstractFlexibleItem() { +) : BasePresenter() { /** * Enabled sources. @@ -73,7 +73,7 @@ open class SourceSearchPresenter( override fun onCreate(savedState: Bundle?) { super.onCreate(savedState) - extensionFilter = savedState?.getString(SourceSearchPresenter::extensionFilter.name) + extensionFilter = savedState?.getString(GlobalSearchPresenter::extensionFilter.name) ?: initialExtensionFilter // Perform a search with previous or initial state @@ -90,7 +90,7 @@ open class SourceSearchPresenter( override fun onSave(state: Bundle) { state.putString(BrowseSourcePresenter::query.name, query) - state.putString(SourceSearchPresenter::extensionFilter.name, extensionFilter) + state.putString(GlobalSearchPresenter::extensionFilter.name, extensionFilter) super.onSave(state) } @@ -134,9 +134,9 @@ open class SourceSearchPresenter( */ protected open fun createCatalogueSearchItem( source: CatalogueSource, - results: List? - ): SourceSearchItem { - return SourceSearchItem(source, results) + results: List? + ): GlobalSearchItem { + return GlobalSearchItem(source, results) } /** @@ -180,7 +180,7 @@ open class SourceSearchPresenter( .map { createCatalogueSearchItem( source, - it.map { SourceSearchCardItem(it) }) + it.map { GlobalSearchMangaItem(it) }) } }, 5).observeOn(AndroidSchedulers.mainThread()) // Update matching source with the obtained results