Renaming a bunch of files as Source instead of Catalogue

This commit is contained in:
Jay 2020-04-19 04:33:57 -04:00
parent 83990793a2
commit 5871572442
76 changed files with 287 additions and 336 deletions

View File

@ -78,7 +78,7 @@ DON'T: https://github.com/inorichi/tachiyomi/issues/75
* Write a detailed issue, explaning what it should do or how. Avoid writing just "like X app does"
* Include screenshot (if needed)
Catalogue requests should be created at https://github.com/inorichi/tachiyomi-extensions, they do not belong in this repository.
Source requests should be created at https://github.com/inorichi/tachiyomi-extensions, they do not belong in this repository.
</details>
## FAQ

View File

@ -115,7 +115,7 @@ class PreferencesHelper(val context: Context) {
fun lastVersionCode() = rxPrefs.getInteger("last_version_code", 0)
fun catalogueAsList() = rxPrefs.getBoolean(Keys.catalogueAsList, false)
fun browseAsList() = rxPrefs.getBoolean(Keys.catalogueAsList, false)
fun enabledLanguages() = rxPrefs.getStringSet(Keys.enabledLanguages, setOf("en", Locale.getDefault().language))
@ -205,7 +205,7 @@ class PreferencesHelper(val context: Context) {
fun collapsedCategories() = rxPrefs.getStringSet("collapsed_categories", mutableSetOf())
fun hiddenCatalogues() = rxPrefs.getStringSet("hidden_catalogues", mutableSetOf())
fun hiddenSources() = rxPrefs.getStringSet("hidden_catalogues", mutableSetOf())
fun pinnedCatalogues() = rxPrefs.getStringSet("pinned_catalogues", emptySet())

View File

@ -1,41 +0,0 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.widget.SimpleNavigationView
class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
SimpleNavigationView(context, attrs) {
val adapter: FlexibleAdapter<IFlexible<*>> = FlexibleAdapter<IFlexible<*>>(null)
.setDisplayHeadersAtStartUp(true)
.setStickyHeaders(true)
var onSearchClicked = {}
var onResetClicked = {}
init {
recycler.adapter = adapter
recycler.setHasFixedSize(true)
val view = inflate(R.layout.catalogue_filter_sheet)
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
addView(view)
// title.text = context.getString(R.string.source_search_options)
/*search_btn.setOnClickListener { onSearchClicked() }
reset_btn.setOnClickListener { onResetClicked() }
view.search_layout.setOnApplyWindowInsetsListener { v, insets ->
view.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
insets
}*/
}
fun setFilters(items: List<IFlexible<*>>) {
adapter.updateDataSet(items)
}
}

View File

@ -1,3 +0,0 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
class NoResultsException : Exception()

View File

@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
@ -44,9 +44,9 @@ ExtensionAdapter.OnButtonClickListener,
private var extensions: List<ExtensionItem> = emptyList()
lateinit var controller: CatalogueController
lateinit var controller: SourceController
fun onCreate(controller: CatalogueController) {
fun onCreate(controller: SourceController) {
// Initialize adapter, scroll listener and recycler views
autoCheckItem = AutoCheckItem(presenter.getAutoCheckPref())
adapter = ExtensionAdapter(this)

View File

@ -9,7 +9,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.database.models.MangaImpl
import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.util.view.gone
import kotlinx.android.synthetic.main.catalogue_grid_item.*
import kotlinx.android.synthetic.main.manga_grid_item.*
import kotlinx.android.synthetic.main.unread_download_badge.*
/**

View File

@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
import kotlinx.android.synthetic.main.manga_grid_item.view.*
import uy.kohesive.injekt.injectLazy
class LibraryItem(
@ -39,9 +39,9 @@ class LibraryItem(
override fun getLayoutRes(): Int {
return if (libraryLayout.getOrDefault() == 0 || manga.isBlank())
R.layout.catalogue_list_item
R.layout.manga_list_item
else
R.layout.catalogue_grid_item
R.layout.manga_grid_item
}
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LibraryHolder {

View File

@ -12,8 +12,8 @@ import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.catalogue_list_item.*
import kotlinx.android.synthetic.main.catalogue_list_item.view.*
import kotlinx.android.synthetic.main.manga_list_item.*
import kotlinx.android.synthetic.main.manga_list_item.view.*
import kotlinx.android.synthetic.main.unread_download_badge.*
/**

View File

@ -45,8 +45,6 @@ import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
import eu.kanade.tachiyomi.ui.base.controller.BaseController
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
@ -55,6 +53,8 @@ import eu.kanade.tachiyomi.ui.recents.RecentsController
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
@ -152,7 +152,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
setRoot(when (id) {
R.id.nav_library -> LibraryController()
R.id.nav_recents -> RecentsController()
else -> CatalogueController()
else -> SourceController()
}, id)
} else if (currentRoot.tag()?.toIntOrNull() == id) {
if (router.backstackSize == 1) {
@ -368,13 +368,13 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
}
router.pushController(controller.withFadeTransaction())
}
SHORTCUT_CATALOGUES -> bottom_nav.selectedItemId = R.id.nav_browse
SHORTCUT_BROWSE -> bottom_nav.selectedItemId = R.id.nav_browse
SHORTCUT_EXTENSIONS -> {
bottom_nav.selectedItemId = R.id.nav_browse
router.popToRoot()
bottom_nav.post {
val controller =
router.backstack.firstOrNull()?.controller() as? CatalogueController
router.backstack.firstOrNull()?.controller() as? SourceController
controller?.showSheet()
}
}
@ -402,7 +402,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
if (router.backstackSize > 1) {
router.popToRoot()
}
router.pushController(CatalogueSearchController(query).withFadeTransaction())
router.pushController(SourceSearchController(query).withFadeTransaction())
}
}
INTENT_SEARCH -> {
@ -413,7 +413,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
router.popToRoot()
}
router.pushController(
CatalogueSearchController(
SourceSearchController(
query,
filter
).withFadeTransaction()
@ -588,7 +588,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
const val SHORTCUT_LIBRARY = "eu.kanade.tachiyomi.SHOW_LIBRARY"
const val SHORTCUT_RECENTLY_UPDATED = "eu.kanade.tachiyomi.SHOW_RECENTLY_UPDATED"
const val SHORTCUT_RECENTLY_READ = "eu.kanade.tachiyomi.SHOW_RECENTLY_READ"
const val SHORTCUT_CATALOGUES = "eu.kanade.tachiyomi.SHOW_CATALOGUES"
const val SHORTCUT_BROWSE = "eu.kanade.tachiyomi.SHOW_BROWSE"
const val SHORTCUT_DOWNLOADS = "eu.kanade.tachiyomi.SHOW_DOWNLOADS"
const val SHORTCUT_MANGA = "eu.kanade.tachiyomi.SHOW_MANGA"
const val SHORTCUT_EXTENSIONS = "eu.kanade.tachiyomi.EXTENSIONS"

View File

@ -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.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.util.view.gone
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(CatalogueSearchController(query).withFadeTransaction())
router.replaceTopController(SourceSearchController(query).withFadeTransaction())
}
}
INTENT_SEARCH -> {
@ -77,7 +77,7 @@ class SearchActivity : MainActivity() {
if (router.backstackSize > 1) {
router.popToRoot()
}
router.replaceTopController(CatalogueSearchController(query, filter).withFadeTransaction())
router.replaceTopController(SourceSearchController(query, filter).withFadeTransaction())
}
}
else -> return false

View File

@ -83,7 +83,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.controller.BaseController
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.main.MainActivity
@ -136,7 +136,7 @@ class MangaDetailsController : BaseController,
constructor(
manga: Manga?,
fromCatalogue: Boolean = false,
smartSearchConfig: CatalogueController.SmartSearchConfig? = null,
smartSearchConfig: SourceController.SmartSearchConfig? = null,
update: Boolean = false
) : super(Bundle().apply {
putLong(MANGA_EXTRA, manga?.id ?: 0)

View File

@ -7,7 +7,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import kotlinx.android.synthetic.main.catalogue_list_item.*
import kotlinx.android.synthetic.main.manga_list_item.*
class MangaHolder(
private val view: View,

View File

@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
class MangaItem(val manga: Manga) : AbstractFlexibleItem<MangaHolder>() {
override fun getLayoutRes(): Int {
return R.layout.catalogue_list_item
return R.layout.manga_list_item
}
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): MangaHolder {

View File

@ -16,15 +16,15 @@ 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.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchPresenter
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchPresenter
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
import uy.kohesive.injekt.injectLazy
class SearchController(
private var manga: Manga? = null
) : CatalogueSearchController(manga?.title), BottomNavBarInterface {
) : SourceSearchController(manga?.title), BottomNavBarInterface {
private var newManga: Manga? = null
private var progress = 1
@ -44,7 +44,7 @@ class SearchController(
return super.getTitle()
}
override fun createPresenter(): CatalogueSearchPresenter {
override fun createPresenter(): SourceSearchPresenter {
return SearchPresenter(initialQuery, manga!!)
}

View File

@ -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.catalogue.global_search.CatalogueSearchCardItem
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchItem
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchPresenter
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
class SearchPresenter(
initialQuery: String? = "",
private val manga: Manga
) : CatalogueSearchPresenter(initialQuery) {
) : SourceSearchPresenter(initialQuery) {
override fun getEnabledSources(): List<CatalogueSource> {
// 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<CatalogueSearchCardItem>?): CatalogueSearchItem {
override fun createCatalogueSearchItem(source: CatalogueSource, results: List<SourceSearchCardItem>?): SourceSearchItem {
// Set the catalogue search item as highlighted if the source matches that of the selected manga
return CatalogueSearchItem(source, results, source.id == manga.source)
return SourceSearchItem(source, results, source.id == manga.source)
}
}

View File

@ -7,7 +7,7 @@ import eu.davidea.flexibleadapter.items.AbstractHeaderItem
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import kotlinx.android.synthetic.main.catalogue_main_controller_card.*
import kotlinx.android.synthetic.main.source_header_item.*
/**
* Item that contains the selection header.
@ -18,7 +18,7 @@ class SelectionHeader : AbstractHeaderItem<SelectionHeader.Holder>() {
* Returns the layout resource of this item.
*/
override fun getLayoutRes(): Int {
return R.layout.catalogue_main_controller_card
return R.layout.source_header_item
}
/**

View File

@ -6,9 +6,9 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder
import eu.kanade.tachiyomi.util.view.roundTextIcon
import io.github.mthli.slice.Slice
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.card
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.edit_button
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.title
import kotlinx.android.synthetic.main.source_item.card
import kotlinx.android.synthetic.main.source_item.edit_button
import kotlinx.android.synthetic.main.source_item.title
import kotlinx.android.synthetic.main.migration_card_item.*
class SourceHolder(view: View, override val adapter: SourceAdapter) :

View File

@ -145,7 +145,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
fun isEnabled(id: String): Boolean {
val sourcesSaved = prefs.migrationSources().getOrDefault()
val hiddenCatalogues = prefs.hiddenCatalogues().getOrDefault()
val hiddenCatalogues = prefs.hiddenSources().getOrDefault()
return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues
else sourcesSaved.split("/").contains(id)
}

View File

@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.setVectorCompat
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
import kotlinx.android.synthetic.main.manga_grid_item.view.*
import kotlinx.android.synthetic.main.migration_process_item.*
import kotlinx.android.synthetic.main.unread_download_badge.view.*
import kotlinx.coroutines.Dispatchers

View File

@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.data.database.models.History
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.ui.base.controller.BaseController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.browse.ProgressItem
import eu.kanade.tachiyomi.ui.source.browse.ProgressItem
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.system.launchUI

View File

@ -85,7 +85,7 @@ class SettingsSourcesController : SettingsController() {
* @param group the language category.
*/
private fun addLanguageSources(group: PreferenceGroup, sources: List<HttpSource>) {
val hiddenCatalogues = preferences.hiddenCatalogues().getOrDefault()
val hiddenCatalogues = preferences.hiddenSources().getOrDefault()
val selectAllPreference = CheckBoxPreference(group.context).apply {
@ -97,12 +97,12 @@ class SettingsSourcesController : SettingsController() {
onChange { newValue ->
val checked = newValue as Boolean
val current = preferences.hiddenCatalogues().get() ?: mutableSetOf()
val current = preferences.hiddenSources().get() ?: mutableSetOf()
if (checked)
current.removeAll(sources.map { it.id.toString() })
else
current.addAll(sources.map { it.id.toString() })
preferences.hiddenCatalogues().set(current)
preferences.hiddenSources().set(current)
group.removeAll()
addLanguageSources(group, sortedSources(sources))
true
@ -126,9 +126,9 @@ class SettingsSourcesController : SettingsController() {
onChange { newValue ->
val checked = newValue as Boolean
val current = preferences.hiddenCatalogues().getOrDefault()
val current = preferences.hiddenSources().getOrDefault()
preferences.hiddenCatalogues().set(
preferences.hiddenSources().set(
if (checked) current - id
else current + id
)
@ -220,7 +220,7 @@ class SettingsSourcesController : SettingsController() {
private fun sortedSources(sources: List<HttpSource>?): List<HttpSource> {
val sourceAlpha = sources.orEmpty().sortedBy { it.name }
return if (sorting == SourcesSort.Enabled) {
val hiddenCatalogues = preferences.hiddenCatalogues().getOrDefault()
val hiddenCatalogues = preferences.hiddenSources().getOrDefault()
sourceAlpha.filter { it.id.toString() !in hiddenCatalogues } +
sourceAlpha.filterNot { it.id.toString() !in hiddenCatalogues }
} else {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -6,7 +6,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.system.LocaleHelper
import kotlinx.android.synthetic.main.catalogue_main_controller_card.*
import kotlinx.android.synthetic.main.source_header_item.*
class LangHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
BaseFlexibleViewHolder(view, adapter) {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -18,7 +18,7 @@ data class LangItem(val code: String) : AbstractHeaderItem<LangHolder>() {
* Returns the layout resource of this item.
*/
override fun getLayoutRes(): Int {
return R.layout.catalogue_main_controller_card
return R.layout.source_header_item
}
/**

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible
@ -8,9 +8,9 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
/**
* Adapter that holds the catalogue cards.
*
* @param controller instance of [CatalogueController].
* @param controller instance of [SourceController].
*/
class CatalogueAdapter(val controller: CatalogueController) :
class SourceAdapter(val controller: SourceController) :
FlexibleAdapter<IFlexible<*>>(null, controller, true) {
val cardBackground = controller.activity!!.getResourceColor(R.attr.background_card)
@ -31,7 +31,7 @@ class CatalogueAdapter(val controller: CatalogueController) :
/**
* Listener which should be called when user clicks browse.
* Note: Should only be handled by [CatalogueController]
* Note: Should only be handled by [SourceController]
*/
interface OnBrowseClickListener {
fun onBrowseClick(position: Int)
@ -39,7 +39,7 @@ class CatalogueAdapter(val controller: CatalogueController) :
/**
* Listener which should be called when user clicks latest.
* Note: Should only be handled by [CatalogueController]
* Note: Should only be handled by [SourceController]
*/
interface OnLatestClickListener {
fun onLatestClick(position: Int)

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
import android.app.Activity
@ -27,38 +27,38 @@ import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.catalogue.latest.LatestUpdatesController
import eu.kanade.tachiyomi.ui.extension.SettingsExtensionsController
import eu.kanade.tachiyomi.ui.main.BottomSheetController
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.latest.LatestUpdatesController
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
import eu.kanade.tachiyomi.util.view.scrollViewWith
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.catalogue_main_controller.*
import kotlinx.android.synthetic.main.extensions_bottom_sheet.*
import kotlinx.android.synthetic.main.main_activity.*
import kotlinx.android.synthetic.main.source_controller.*
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import kotlin.math.max
/**
* This controller shows and manages the different catalogues enabled by the user.
* This controller should only handle UI actions, IO actions should be done by [CataloguePresenter]
* [CatalogueAdapter.OnBrowseClickListener] call function data on browse item click.
* [CatalogueAdapter.OnLatestClickListener] call function data on latest item click
* This controller should only handle UI actions, IO actions should be done by [SourcePresenter]
* [SourceAdapter.OnBrowseClickListener] call function data on browse item click.
* [SourceAdapter.OnLatestClickListener] call function data on latest item click
*/
class CatalogueController : NucleusController<CataloguePresenter>(),
class SourceController : NucleusController<SourcePresenter>(),
FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener,
CatalogueAdapter.OnBrowseClickListener,
SourceAdapter.OnBrowseClickListener,
RootSearchInterface,
BottomSheetController,
CatalogueAdapter.OnLatestClickListener {
SourceAdapter.OnLatestClickListener {
/**
* Application preferences.
@ -68,7 +68,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
/**
* Adapter containing sources.
*/
private var adapter: CatalogueAdapter? = null
private var adapter: SourceAdapter? = null
var extQuery = ""
private set
@ -90,26 +90,26 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
else applicationContext?.getString(R.string.sources)
}
override fun createPresenter(): CataloguePresenter {
return CataloguePresenter()
override fun createPresenter(): SourcePresenter {
return SourcePresenter()
}
/**
* Initiate the view with [R.layout.catalogue_main_controller].
* Initiate the view with [R.layout.source_controller].
*
* @param inflater used to load the layout xml.
* @param container containing parent views.
* @return inflated view.
*/
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
return inflater.inflate(R.layout.catalogue_main_controller, container, false)
return inflater.inflate(R.layout.source_controller, container, false)
}
override fun onViewCreated(view: View) {
super.onViewCreated(view)
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
adapter = CatalogueAdapter(this)
adapter = SourceAdapter(this)
// Create recycler and set adapter.
recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(view.context)
@ -212,14 +212,14 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
val item = adapter?.getItem(position) as? SourceItem ?: return false
val source = item.source
// Open the catalogue view.
openCatalogue(source, BrowseCatalogueController(source))
openCatalogue(source, BrowseSourceController(source))
return false
}
override fun onItemLongClick(position: Int) {
val activity = activity ?: return
val item = adapter?.getItem(position) as? SourceItem ?: return
val isPinned = item.header?.code?.equals(CataloguePresenter.PINNED_KEY) ?: false
val isPinned = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false
MaterialDialog(activity)
.title(text = item.source.name)
@ -235,8 +235,8 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
}
private fun hideCatalogue(source: Source) {
val current = preferences.hiddenCatalogues().getOrDefault()
preferences.hiddenCatalogues().set(current + source.id.toString())
val current = preferences.hiddenSources().getOrDefault()
preferences.hiddenSources().set(current + source.id.toString())
presenter.updateSources()
}
@ -253,14 +253,14 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
}
/**
* Called when browse is clicked in [CatalogueAdapter]
* Called when browse is clicked in [SourceAdapter]
*/
override fun onBrowseClick(position: Int) {
onItemClick(view!!, position)
}
/**
* Called when latest is clicked in [CatalogueAdapter]
* Called when latest is clicked in [SourceAdapter]
*/
override fun onLatestClick(position: Int) {
val item = adapter?.getItem(position) as? SourceItem ?: return
@ -270,7 +270,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
/**
* Opens a catalogue with the given controller.
*/
private fun openCatalogue(source: CatalogueSource, controller: BrowseCatalogueController) {
private fun openCatalogue(source: CatalogueSource, controller: BrowseSourceController) {
preferences.lastUsedCatalogueSource().set(source.id)
router.pushController(controller.withFadeTransaction())
}
@ -326,7 +326,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
}
private fun performGlobalSearch(query: String) {
router.pushController(CatalogueSearchController(query).withFadeTransaction())
router.pushController(SourceSearchController(query).withFadeTransaction())
}
/**

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.content.Context
import android.graphics.Canvas

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.view.View
import eu.kanade.tachiyomi.source.icon
@ -6,9 +6,9 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.roundTextIcon
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.*
import kotlinx.android.synthetic.main.source_item.*
class SourceHolder(view: View, val adapter: CatalogueAdapter) :
class SourceHolder(view: View, val adapter: SourceAdapter) :
BaseFlexibleViewHolder(view, adapter) {
/*override val slice = Slice(card).apply {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -21,14 +21,14 @@ data class SourceItem(val source: CatalogueSource, val header: LangItem? = null)
* Returns the layout resource of this item.
*/
override fun getLayoutRes(): Int {
return R.layout.catalogue_main_controller_card_item
return R.layout.source_item
}
/**
* Creates a new view holder for this item.
*/
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceHolder {
return SourceHolder(view, adapter as CatalogueAdapter)
return SourceHolder(view, adapter as SourceAdapter)
}
/**

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue
package eu.kanade.tachiyomi.ui.source
import android.os.Bundle
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -16,16 +16,16 @@ import java.util.TreeMap
import java.util.concurrent.TimeUnit
/**
* Presenter of [CatalogueController]
* Presenter of [SourceController]
* Function calls should be done from here. UI calls should be done from the controller.
*
* @param sourceManager manages the different sources.
* @param preferences application preferences.
*/
class CataloguePresenter(
class SourcePresenter(
val sourceManager: SourceManager = Injekt.get(),
private val preferences: PreferencesHelper = Injekt.get()
) : BasePresenter<CatalogueController>() {
) : BasePresenter<SourceController>() {
var sources = getEnabledSources()
@ -76,7 +76,7 @@ class CataloguePresenter(
}
sourceSubscription = Observable.just(sourceItems)
.subscribeLatestCache(CatalogueController::setSources)
.subscribeLatestCache(SourceController::setSources)
}
private fun loadLastUsedSource() {
@ -88,7 +88,7 @@ class CataloguePresenter(
sharedObs.skip(1).delay(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()))
.distinctUntilChanged()
.map { (sourceManager.get(it) as? CatalogueSource)?.let { SourceItem(it) } }
.subscribeLatestCache(CatalogueController::setLastUsedSource)
.subscribeLatestCache(SourceController::setLastUsedSource)
}
fun updateSources() {
@ -103,7 +103,7 @@ class CataloguePresenter(
*/
private fun getEnabledSources(): List<CatalogueSource> {
val languages = preferences.enabledLanguages().getOrDefault()
val hiddenCatalogues = preferences.hiddenCatalogues().getOrDefault()
val hiddenCatalogues = preferences.hiddenSources().getOrDefault()
return sourceManager.getCatalogueSources()
.filter { it.lang in languages }

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.os.Bundle
import android.view.LayoutInflater
@ -27,10 +27,10 @@ import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.connectivityManager
import eu.kanade.tachiyomi.util.system.dpToPx
@ -42,7 +42,7 @@ import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import kotlinx.android.synthetic.main.catalogue_controller.*
import kotlinx.android.synthetic.main.browse_source_controller.*
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
@ -53,8 +53,8 @@ import java.util.concurrent.TimeUnit
/**
* Controller to manage the catalogues available in the app.
*/
open class BrowseCatalogueController(bundle: Bundle) :
NucleusController<BrowseCataloguePresenter>(bundle),
open class BrowseSourceController(bundle: Bundle) :
NucleusController<BrowseSourcePresenter>(bundle),
FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener,
FlexibleAdapter.EndlessScrollListener,
@ -63,7 +63,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
constructor(
source: CatalogueSource,
searchQuery: String? = null,
smartSearchConfig: CatalogueController.SmartSearchConfig? = null
smartSearchConfig: SourceController.SmartSearchConfig? = null
) : this(Bundle().apply {
putLong(SOURCE_ID_KEY, source.id)
@ -93,11 +93,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
*/
private var snack: Snackbar? = null
/**
* Navigation view containing filter items.
*/
private var navView: CatalogueNavigationView? = null
/**
* Recycler view with the list of results.
*/
@ -121,12 +116,12 @@ open class BrowseCatalogueController(bundle: Bundle) :
return presenter.source.name
}
override fun createPresenter(): BrowseCataloguePresenter {
return BrowseCataloguePresenter(args.getLong(SOURCE_ID_KEY))
override fun createPresenter(): BrowseSourcePresenter {
return BrowseSourcePresenter(args.getLong(SOURCE_ID_KEY))
}
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
return inflater.inflate(R.layout.catalogue_controller, container, false)
return inflater.inflate(R.layout.browse_source_controller, container, false)
}
override fun onViewCreated(view: View) {
@ -136,8 +131,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
adapter = FlexibleAdapter(null, this)
setupRecycler(view)
navView?.setFilters(presenter.filterItems)
fab.visibleIf(presenter.sourceFilters.isNotEmpty())
fab.setOnClickListener { showFilters() }
progress?.visible()
@ -170,7 +163,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
}
} else {
(catalogue_view.inflate(R.layout.catalogue_recycler_autofit) as AutofitRecyclerView).apply {
(catalogue_view.inflate(R.layout.manga_recycler_autofit) as AutofitRecyclerView).apply {
columnWidth = when (preferences.gridSize().getOrDefault()) {
0 -> 1f
2 -> 1.66f
@ -180,7 +173,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
(layoutManager as androidx.recyclerview.widget.GridLayoutManager).spanSizeLookup = object : androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return when (adapter?.getItemViewType(position)) {
R.layout.catalogue_grid_item, null -> 1
R.layout.manga_grid_item, null -> 1
else -> spanCount
}
}
@ -229,7 +222,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
val searchEventsObservable = searchView.queryTextChangeEvents()
.skip(1)
.filter { router.backstack.lastOrNull()?.controller() == this@BrowseCatalogueController }
.filter { router.backstack.lastOrNull()?.controller() == this@BrowseSourceController }
.share()
val writingObservable = searchEventsObservable
.filter { !it.isSubmitted }
@ -278,7 +271,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
}
private fun showFilters() {
val sheet = CatalogueSearchSheet(activity!!)
val sheet = SourceSearchSheet(activity!!)
sheet.setFilters(presenter.filterItems)
presenter.filtersChanged = false
val oldFilters = mutableListOf<Any?>()
@ -358,7 +351,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
* @param page the current page.
* @param mangas the list of manga of the page.
*/
fun onAddPage(page: Int, mangas: List<CatalogueItem>) {
fun onAddPage(page: Int, mangas: List<BrowseSourceItem>) {
val adapter = adapter ?: return
hideProgressBar()
if (page == 1) {
@ -381,7 +374,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
snack?.dismiss()
val message = if (error is NoResultsException) catalogue_view.context.getString(R.string.no_results_found) else (error.message ?: "")
snack = catalouge_layout?.snack(message, Snackbar.LENGTH_INDEFINITE) {
snack = source_layout?.snack(message, Snackbar.LENGTH_INDEFINITE) {
setAction(R.string.retry) {
// If not the first page, show bottom progress bar.
if (adapter.mainItemCount > 0) {
@ -442,7 +435,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
if (!isListMode || !view.context.connectivityManager.isActiveNetworkMetered) {
// Initialize mangas if going to grid view or if over wifi when going to list view
val mangas = (0 until adapter.itemCount).mapNotNull {
(adapter.getItem(it) as? CatalogueItem)?.manga
(adapter.getItem(it) as? BrowseSourceItem)?.manga
}
presenter.initializeMangas(mangas)
}
@ -454,13 +447,13 @@ open class BrowseCatalogueController(bundle: Bundle) :
* @param manga the manga to find.
* @return the holder of the manga or null if it's not bound.
*/
private fun getHolder(manga: Manga): CatalogueHolder? {
private fun getHolder(manga: Manga): BrowseSourceHolder? {
val adapter = adapter ?: return null
adapter.allBoundViewHolders.forEach { holder ->
val item = adapter.getItem(holder.adapterPosition) as? CatalogueItem
val item = adapter.getItem(holder.adapterPosition) as? BrowseSourceItem
if (item != null && item.manga.id!! == manga.id!!) {
return holder as CatalogueHolder
return holder as BrowseSourceHolder
}
}
@ -490,7 +483,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
* @return true if the item should be selected, false otherwise.
*/
override fun onItemClick(view: View?, position: Int): Boolean {
val item = adapter?.getItem(position) as? CatalogueItem ?: return false
val item = adapter?.getItem(position) as? BrowseSourceItem ?: return false
router.pushController(MangaDetailsController(item.manga, true).withFadeTransaction())
return false
@ -506,12 +499,12 @@ open class BrowseCatalogueController(bundle: Bundle) :
* @param position the position of the element clicked.
*/
override fun onItemLongClick(position: Int) {
val manga = (adapter?.getItem(position) as? CatalogueItem?)?.manga ?: return
val manga = (adapter?.getItem(position) as? BrowseSourceItem?)?.manga ?: return
snack?.dismiss()
if (manga.favorite) {
presenter.changeMangaFavorite(manga)
adapter?.notifyItemChanged(position)
snack = catalouge_layout?.snack(R.string.removed_from_library, Snackbar.LENGTH_INDEFINITE) {
snack = source_layout?.snack(R.string.removed_from_library, Snackbar.LENGTH_INDEFINITE) {
setAction(R.string.undo) {
if (!manga.favorite) addManga(manga, position)
}
@ -525,7 +518,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
(activity as? MainActivity)?.setUndoSnackBar(snack)
} else {
addManga(manga, position)
snack = catalouge_layout?.snack(R.string.added_to_library)
snack = source_layout?.snack(R.string.added_to_library)
}
}

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.ui.library.LibraryCategoryAdapter
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.catalogue_grid_item.*
import kotlinx.android.synthetic.main.manga_grid_item.*
import kotlinx.android.synthetic.main.unread_download_badge.*
/**
@ -24,11 +24,11 @@ import kotlinx.android.synthetic.main.unread_download_badge.*
* @param listener a listener to react to single tap and long tap events.
* @constructor creates a new library holder.
*/
class CatalogueGridHolder(
class BrowseSourceGridHolder(
private val view: View,
private val adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
compact: Boolean
) : CatalogueHolder(view, adapter) {
) : BrowseSourceHolder(view, adapter) {
init {
if (compact) {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
* @param view the inflated view for this holder.
* @param adapter the adapter handling this holder.
*/
abstract class CatalogueHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
abstract class BrowseSourceHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
BaseFlexibleViewHolder(view, adapter) {
/**

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.view.Gravity
import android.view.View
@ -18,23 +18,23 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
import kotlinx.android.synthetic.main.manga_grid_item.view.*
class CatalogueItem(
class BrowseSourceItem(
val manga: Manga,
private val catalogueAsList: Preference<Boolean>,
private val catalogueListType: Preference<Int>
) :
AbstractFlexibleItem<CatalogueHolder>() {
AbstractFlexibleItem<BrowseSourceHolder>() {
override fun getLayoutRes(): Int {
return if (catalogueAsList.getOrDefault())
R.layout.catalogue_list_item
R.layout.manga_list_item
else
R.layout.catalogue_grid_item
R.layout.manga_grid_item
}
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): CatalogueHolder {
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): BrowseSourceHolder {
val parent = adapter.recyclerView
return if (parent is AutofitRecyclerView) {
val listType = catalogueListType.getOrDefault()
@ -66,15 +66,15 @@ class CatalogueItem(
(parent.itemWidth / 3f * 3.7f).toInt()
)
}
CatalogueGridHolder(view, adapter, listType == 1)
BrowseSourceGridHolder(view, adapter, listType == 1)
} else {
CatalogueListHolder(view, adapter)
BrowseSourceListHolder(view, adapter)
}
}
override fun bindViewHolder(
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
holder: CatalogueHolder,
holder: BrowseSourceHolder,
position: Int,
payloads: MutableList<Any?>?
) {
@ -84,7 +84,7 @@ class CatalogueItem(
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other is CatalogueItem) {
if (other is BrowseSourceItem) {
return manga.id!! == other.manga.id!!
}
return false

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.catalogue_list_item.*
import kotlinx.android.synthetic.main.manga_list_item.*
/**
* Class used to hold the displayed data of a manga in the catalogue, like the cover or the title.
@ -21,8 +21,8 @@ import kotlinx.android.synthetic.main.catalogue_list_item.*
* @param adapter the adapter handling this holder.
* @constructor creates a new catalogue holder.
*/
class CatalogueListHolder(private val view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
CatalogueHolder(view, adapter) {
class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
BrowseSourceHolder(view, adapter) {
/**
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.FilterList
@ -7,7 +7,7 @@ import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers
open class CataloguePager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
open class BrowseSourcePager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
override fun requestNext(): Observable<MangasPage> {
val page = currentPage

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.os.Bundle
import eu.davidea.flexibleadapter.items.IFlexible
@ -16,19 +16,19 @@ import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.ui.catalogue.filter.CheckboxItem
import eu.kanade.tachiyomi.ui.catalogue.filter.CheckboxSectionItem
import eu.kanade.tachiyomi.ui.catalogue.filter.GroupItem
import eu.kanade.tachiyomi.ui.catalogue.filter.HeaderItem
import eu.kanade.tachiyomi.ui.catalogue.filter.SelectItem
import eu.kanade.tachiyomi.ui.catalogue.filter.SelectSectionItem
import eu.kanade.tachiyomi.ui.catalogue.filter.SeparatorItem
import eu.kanade.tachiyomi.ui.catalogue.filter.SortGroup
import eu.kanade.tachiyomi.ui.catalogue.filter.SortItem
import eu.kanade.tachiyomi.ui.catalogue.filter.TextItem
import eu.kanade.tachiyomi.ui.catalogue.filter.TextSectionItem
import eu.kanade.tachiyomi.ui.catalogue.filter.TriStateItem
import eu.kanade.tachiyomi.ui.catalogue.filter.TriStateSectionItem
import eu.kanade.tachiyomi.ui.source.filter.CheckboxItem
import eu.kanade.tachiyomi.ui.source.filter.CheckboxSectionItem
import eu.kanade.tachiyomi.ui.source.filter.GroupItem
import eu.kanade.tachiyomi.ui.source.filter.HeaderItem
import eu.kanade.tachiyomi.ui.source.filter.SelectItem
import eu.kanade.tachiyomi.ui.source.filter.SelectSectionItem
import eu.kanade.tachiyomi.ui.source.filter.SeparatorItem
import eu.kanade.tachiyomi.ui.source.filter.SortGroup
import eu.kanade.tachiyomi.ui.source.filter.SortItem
import eu.kanade.tachiyomi.ui.source.filter.TextItem
import eu.kanade.tachiyomi.ui.source.filter.TextSectionItem
import eu.kanade.tachiyomi.ui.source.filter.TriStateItem
import eu.kanade.tachiyomi.ui.source.filter.TriStateSectionItem
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
@ -40,15 +40,15 @@ import uy.kohesive.injekt.api.get
import java.util.Date
/**
* Presenter of [BrowseCatalogueController].
* Presenter of [BrowseSourceController].
*/
open class BrowseCataloguePresenter(
open class BrowseSourcePresenter(
sourceId: Long,
sourceManager: SourceManager = Injekt.get(),
private val db: DatabaseHelper = Injekt.get(),
private val prefs: PreferencesHelper = Injekt.get(),
private val coverCache: CoverCache = Injekt.get()
) : BasePresenter<BrowseCatalogueController>() {
) : BasePresenter<BrowseSourceController>() {
/**
* Selected source.
@ -120,7 +120,7 @@ open class BrowseCataloguePresenter(
query = savedState.getString(::query.name, "")
}
add(prefs.catalogueAsList().asObservable()
add(prefs.browseAsList().asObservable()
.subscribe { setDisplayMode(it) })
restartPager()
@ -148,8 +148,8 @@ open class BrowseCataloguePresenter(
val sourceId = source.id
val catalogueAsList = prefs.catalogueAsList()
val catalougeListType = prefs.libraryLayout()
val browseAsList = prefs.browseAsList()
val sourceListType = prefs.libraryLayout()
// Prepare the pager.
pagerSubscription?.let { remove(it) }
@ -157,7 +157,7 @@ open class BrowseCataloguePresenter(
.observeOn(Schedulers.io())
.map { it.first to it.second.map { networkToLocalManga(it, sourceId) } }
.doOnNext { initializeMangas(it.second) }
.map { it.first to it.second.map { CatalogueItem(it, catalogueAsList, catalougeListType) } }
.map { it.first to it.second.map { BrowseSourceItem(it, browseAsList, sourceListType) } }
.observeOn(AndroidSchedulers.mainThread())
.subscribeReplay({ view, (page, mangas) ->
view.onAddPage(page, mangas)
@ -179,7 +179,7 @@ open class BrowseCataloguePresenter(
pageSubscription = Observable.defer { pager.requestNext() }
.subscribeFirst({ _, _ ->
// Nothing to do when onNext is emitted.
}, BrowseCatalogueController::onAddPageError)
}, BrowseSourceController::onAddPageError)
}
/**
@ -294,7 +294,7 @@ open class BrowseCataloguePresenter(
* Changes the active display mode.
*/
fun swapDisplayMode() {
prefs.catalogueAsList().set(!isListMode)
prefs.browseAsList().set(!isListMode)
}
/**
@ -307,7 +307,7 @@ open class BrowseCataloguePresenter(
}
open fun createPager(query: String, filters: FilterList): Pager {
return CataloguePager(source, query, filters)
return BrowseSourcePager(source, query, filters)
}
private fun FilterList.toItems(): List<IFlexible<*>> {

View File

@ -0,0 +1,3 @@
package eu.kanade.tachiyomi.ui.source.browse
class NoResultsException : Exception()

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import com.jakewharton.rxrelay.PublishRelay
import eu.kanade.tachiyomi.source.model.MangasPage

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.view.View
import android.widget.ProgressBar
@ -15,7 +15,7 @@ class ProgressItem : AbstractFlexibleItem<ProgressItem.Holder>() {
private var loadMore = true
override fun getLayoutRes(): Int {
return R.layout.catalogue_progress_item
return R.layout.source_progress_item
}
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): Holder {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.browse
package eu.kanade.tachiyomi.ui.source.browse
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
@ -16,10 +16,10 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
import kotlinx.android.synthetic.main.catalogue_filter_sheet.*
import kotlinx.android.synthetic.main.source_filter_sheet.*
import uy.kohesive.injekt.injectLazy
class CatalogueSearchSheet(activity: Activity) :
class SourceSearchSheet(activity: Activity) :
BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) {
/**
@ -43,7 +43,7 @@ class CatalogueSearchSheet(activity: Activity) :
var onResetClicked = {}
init {
val view = activity.layoutInflater.inflate(R.layout.catalogue_filter_sheet, null)
val view = activity.layoutInflater.inflate(R.layout.source_filter_sheet, null)
setContentView(view)
toolbar_title.text = context.getString(R.string.search_filters)
search_btn.setOnClickListener { dismiss() }

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import android.widget.CheckBox

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import android.widget.ImageView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.annotation.SuppressLint
import android.view.View

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import eu.davidea.flexibleadapter.items.ISectionable
import eu.kanade.tachiyomi.source.model.Filter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import android.widget.ArrayAdapter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.annotation.SuppressLint
import android.view.View

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import android.widget.CheckedTextView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import android.widget.EditText

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.filter
package eu.kanade.tachiyomi.ui.source.filter
import android.view.View
import android.widget.CheckedTextView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.os.Bundle
import android.os.Parcelable
@ -8,10 +8,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
/**
* Adapter that holds the search cards.
*
* @param controller instance of [CatalogueSearchController].
* @param controller instance of [SourceSearchController].
*/
class CatalogueSearchAdapter(val controller: CatalogueSearchController) :
FlexibleAdapter<CatalogueSearchItem>(null, controller, true) {
class SourceSearchAdapter(val controller: SourceSearchController) :
FlexibleAdapter<SourceSearchItem>(null, controller, true) {
/**
* Bundle where the view state of the holders is saved.

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.data.database.models.Manga
@ -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 [CatalogueSearchController].
* @param controller instance of [SourceSearchController].
*/
class CatalogueSearchCardAdapter(controller: CatalogueSearchController) :
FlexibleAdapter<CatalogueSearchCardItem>(null, controller, true) {
class SourceSearchCardAdapter(controller: SourceSearchController) :
FlexibleAdapter<SourceSearchCardItem>(null, controller, true) {
/**
* Listen for browse item clicks.
@ -18,7 +18,7 @@ class CatalogueSearchCardAdapter(controller: CatalogueSearchController) :
/**
* Listener which should be called when user clicks browse.
* Note: Should only be handled by [CatalogueSearchController]
* Note: Should only be handled by [SourceSearchController]
*/
interface OnMangaClickListener {
fun onMangaClick(manga: Manga)

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.view.View
import com.bumptech.glide.load.engine.DiskCacheStrategy
@ -6,9 +6,9 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card_item.*
import kotlinx.android.synthetic.main.source_global_search_controller_card_item.*
class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter) :
class SourceSearchCardHolder(view: View, adapter: SourceSearchCardAdapter) :
BaseFlexibleViewHolder(view, adapter) {
init {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -8,19 +8,19 @@ import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
class CatalogueSearchCardItem(val manga: Manga) : AbstractFlexibleItem<CatalogueSearchCardHolder>() {
class SourceSearchCardItem(val manga: Manga) : AbstractFlexibleItem<SourceSearchCardHolder>() {
override fun getLayoutRes(): Int {
return R.layout.catalogue_global_search_controller_card_item
return R.layout.source_global_search_controller_card_item
}
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): CatalogueSearchCardHolder {
return CatalogueSearchCardHolder(view, adapter as CatalogueSearchCardAdapter)
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceSearchCardHolder {
return SourceSearchCardHolder(view, adapter as SourceSearchCardAdapter)
}
override fun bindViewHolder(
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
holder: CatalogueSearchCardHolder,
holder: SourceSearchCardHolder,
position: Int,
payloads: MutableList<Any?>?
) {
@ -28,7 +28,7 @@ class CatalogueSearchCardItem(val manga: Manga) : AbstractFlexibleItem<Catalogue
}
override fun equals(other: Any?): Boolean {
if (other is CatalogueSearchCardItem) {
if (other is SourceSearchCardItem) {
return manga.id == other.manga.id
}
return false

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.os.Bundle
import android.view.LayoutInflater
@ -17,23 +17,23 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForController
import kotlinx.android.synthetic.main.catalogue_global_search_controller.*
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 [CatalogueSearchPresenter]
* [CatalogueSearchCardAdapter.OnMangaClickListener] called when manga is clicked 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
*/
open class CatalogueSearchController(
open class SourceSearchController(
protected val initialQuery: String? = null,
protected val extensionFilter: String? = null
) : NucleusController<CatalogueSearchPresenter>(),
CatalogueSearchCardAdapter.OnMangaClickListener {
) : NucleusController<SourceSearchPresenter>(),
SourceSearchCardAdapter.OnMangaClickListener {
/**
* Adapter containing search results grouped by lang.
*/
protected var adapter: CatalogueSearchAdapter? = null
protected var adapter: SourceSearchAdapter? = null
private var customTitle: String? = null
@ -45,14 +45,14 @@ open class CatalogueSearchController(
}
/**
* Initiate the view with [R.layout.catalogue_global_search_controller].
* Initiate the view with [R.layout.source_global_search_controller].
*
* @param inflater used to load the layout xml.
* @param container containing parent views.
* @return inflated view
*/
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): android.view.View {
return inflater.inflate(R.layout.catalogue_global_search_controller, container, false)
return inflater.inflate(R.layout.source_global_search_controller, container, false)
}
/**
@ -65,12 +65,12 @@ open class CatalogueSearchController(
}
/**
* Create the [CatalogueSearchPresenter] used in controller.
* Create the [SourceSearchPresenter] used in controller.
*
* @return instance of [CatalogueSearchPresenter]
* @return instance of [SourceSearchPresenter]
*/
override fun createPresenter(): CatalogueSearchPresenter {
return CatalogueSearchPresenter(initialQuery, extensionFilter)
override fun createPresenter(): SourceSearchPresenter {
return SourceSearchPresenter(initialQuery, extensionFilter)
}
/**
@ -138,7 +138,7 @@ open class CatalogueSearchController(
super.onViewCreated(view)
view.applyWindowInsetsForController()
adapter = CatalogueSearchAdapter(this)
adapter = SourceSearchAdapter(this)
// Create recycler and set adapter.
recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(view.context)
@ -171,13 +171,13 @@ open class CatalogueSearchController(
* @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): CatalogueSearchHolder? {
private fun getHolder(source: CatalogueSource): SourceSearchHolder? {
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 CatalogueSearchHolder
return holder as SourceSearchHolder
}
}
@ -189,7 +189,7 @@ open class CatalogueSearchController(
*
* @param searchResult result of search.
*/
fun setItems(searchResult: List<CatalogueSearchItem>) {
fun setItems(searchResult: List<SourceSearchItem>) {
if (extensionFilter != null) {
val results = searchResult.first().results
if (results != null && results.size == 1) {

View File

@ -1,28 +1,27 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.*
import kotlinx.android.synthetic.main.source_global_search_controller_card.*
/**
* Holder that binds the [CatalogueSearchItem] containing catalogue cards.
* Holder that binds the [SourceSearchItem] containing catalogue cards.
*
* @param view view of [CatalogueSearchItem]
* @param adapter instance of [CatalogueSearchAdapter]
* @param view view of [SourceSearchItem]
* @param adapter instance of [SourceSearchAdapter]
*/
class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
BaseFlexibleViewHolder(view, adapter) {
/**
* Adapter containing manga from search results.
*/
private val mangaAdapter = CatalogueSearchCardAdapter(adapter.controller)
private val mangaAdapter = SourceSearchCardAdapter(adapter.controller)
private var lastBoundResults: List<CatalogueSearchCardItem>? = null
private var lastBoundResults: List<SourceSearchCardItem>? = null
init {
// Set layout horizontal.
@ -36,7 +35,7 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
*
* @param item item of card.
*/
fun bind(item: CatalogueSearchItem) {
fun bind(item: SourceSearchItem) {
val source = item.source
val results = item.results
@ -81,11 +80,11 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
* @param manga the manga to find.
* @return the holder of the manga or null if it's not bound.
*/
private fun getHolder(manga: Manga): CatalogueSearchCardHolder? {
private fun getHolder(manga: Manga): SourceSearchCardHolder? {
mangaAdapter.allBoundViewHolders.forEach { holder ->
val item = mangaAdapter.getItem(holder.adapterPosition)
if (item != null && item.manga.id!! == manga.id!!) {
return holder as CatalogueSearchCardHolder
return holder as SourceSearchCardHolder
}
}

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.view.View
import androidx.recyclerview.widget.RecyclerView
@ -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 CatalogueSearchItem(val source: CatalogueSource, val results: List<CatalogueSearchCardItem>?, val highlighted: Boolean = false) :
AbstractFlexibleItem<CatalogueSearchHolder>() {
class SourceSearchItem(val source: CatalogueSource, val results: List<SourceSearchCardItem>?, val highlighted: Boolean = false) :
AbstractFlexibleItem<SourceSearchHolder>() {
/**
* Set view.
@ -24,16 +24,16 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List<Catalog
* @return id of view
*/
override fun getLayoutRes(): Int {
return R.layout.catalogue_global_search_controller_card
return R.layout.source_global_search_controller_card
}
/**
* Create view holder (see [CatalogueSearchAdapter].
* Create view holder (see [SourceSearchAdapter].
*
* @return holder of view.
*/
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): CatalogueSearchHolder {
return CatalogueSearchHolder(view, adapter as CatalogueSearchAdapter)
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): SourceSearchHolder {
return SourceSearchHolder(view, adapter as SourceSearchAdapter)
}
/**
@ -41,7 +41,7 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List<Catalog
*/
override fun bindViewHolder(
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
holder: CatalogueSearchHolder,
holder: SourceSearchHolder,
position: Int,
payloads: MutableList<Any?>?
) {
@ -54,7 +54,7 @@ class CatalogueSearchItem(val source: CatalogueSource, val results: List<Catalog
* @return items are equal?
*/
override fun equals(other: Any?): Boolean {
if (other is CatalogueSearchItem) {
if (other is SourceSearchItem) {
return source.id == other.source.id
}
return false

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.catalogue.global_search
package eu.kanade.tachiyomi.ui.source.global_search
import android.os.Bundle
import eu.kanade.tachiyomi.data.database.DatabaseHelper
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCataloguePresenter
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
@ -25,20 +25,20 @@ import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
/**
* Presenter of [CatalogueSearchController]
* Presenter of [SourceSearchController]
* Function calls should be done from here. UI calls should be done from the controller.
*
* @param sourceManager manages the different sources.
* @param db manages the database calls.
* @param preferencesHelper manages the preference calls.
*/
open class CatalogueSearchPresenter(
val initialQuery: String? = "",
val initialExtensionFilter: String? = null,
open class SourceSearchPresenter(
private val initialQuery: String? = "",
private val initialExtensionFilter: String? = null,
val sourceManager: SourceManager = Injekt.get(),
val db: DatabaseHelper = Injekt.get(),
val preferencesHelper: PreferencesHelper = Injekt.get()
) : BasePresenter<CatalogueSearchController>() {
private val preferencesHelper: PreferencesHelper = Injekt.get()
) : BasePresenter<SourceSearchController>() {
/**
* Enabled sources.
@ -73,12 +73,12 @@ open class CatalogueSearchPresenter(
override fun onCreate(savedState: Bundle?) {
super.onCreate(savedState)
extensionFilter = savedState?.getString(CatalogueSearchPresenter::extensionFilter.name)
extensionFilter = savedState?.getString(SourceSearchPresenter::extensionFilter.name)
?: initialExtensionFilter
// Perform a search with previous or initial state
search(
savedState?.getString(BrowseCataloguePresenter::query.name) ?: initialQuery.orEmpty()
savedState?.getString(BrowseSourcePresenter::query.name) ?: initialQuery.orEmpty()
)
}
@ -89,8 +89,8 @@ open class CatalogueSearchPresenter(
}
override fun onSave(state: Bundle) {
state.putString(BrowseCataloguePresenter::query.name, query)
state.putString(CatalogueSearchPresenter::extensionFilter.name, extensionFilter)
state.putString(BrowseSourcePresenter::query.name, query)
state.putString(SourceSearchPresenter::extensionFilter.name, extensionFilter)
super.onSave(state)
}
@ -101,7 +101,7 @@ open class CatalogueSearchPresenter(
*/
protected open fun getEnabledSources(): List<CatalogueSource> {
val languages = preferencesHelper.enabledLanguages().getOrDefault()
val hiddenCatalogues = preferencesHelper.hiddenCatalogues().getOrDefault()
val hiddenCatalogues = preferencesHelper.hiddenSources().getOrDefault()
return sourceManager.getCatalogueSources()
.filter { it.lang in languages }
@ -132,9 +132,9 @@ open class CatalogueSearchPresenter(
*/
protected open fun createCatalogueSearchItem(
source: CatalogueSource,
results: List<CatalogueSearchCardItem>?
): CatalogueSearchItem {
return CatalogueSearchItem(source, results)
results: List<SourceSearchCardItem>?
): SourceSearchItem {
return SourceSearchItem(source, results)
}
/**
@ -178,7 +178,7 @@ open class CatalogueSearchPresenter(
.map {
createCatalogueSearchItem(
source,
it.map { CatalogueSearchCardItem(it) })
it.map { SourceSearchCardItem(it) })
}
}, 5).observeOn(AndroidSchedulers.mainThread())
// Update matching source with the obtained results

View File

@ -1,19 +1,19 @@
package eu.kanade.tachiyomi.ui.catalogue.latest
package eu.kanade.tachiyomi.ui.source.latest
import android.os.Bundle
import android.view.Menu
import android.view.View
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCataloguePresenter
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
import eu.kanade.tachiyomi.util.view.gone
import kotlinx.android.synthetic.main.catalogue_controller.*
import kotlinx.android.synthetic.main.browse_source_controller.*
/**
* Controller that shows the latest manga from the catalogue. Inherit [BrowseCatalogueController].
* Controller that shows the latest manga from the catalogue. Inherit [BrowseSourceController].
*/
class LatestUpdatesController(bundle: Bundle) : BrowseCatalogueController(bundle) {
class LatestUpdatesController(bundle: Bundle) : BrowseSourceController(bundle) {
constructor(source: CatalogueSource) : this(Bundle().apply {
putLong(SOURCE_ID_KEY, source.id)
@ -24,7 +24,7 @@ class LatestUpdatesController(bundle: Bundle) : BrowseCatalogueController(bundle
fab.gone()
}
override fun createPresenter(): BrowseCataloguePresenter {
override fun createPresenter(): BrowseSourcePresenter {
return LatestUpdatesPresenter(args.getLong(SOURCE_ID_KEY))
}

View File

@ -1,8 +1,8 @@
package eu.kanade.tachiyomi.ui.catalogue.latest
package eu.kanade.tachiyomi.ui.source.latest
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.ui.catalogue.browse.Pager
import eu.kanade.tachiyomi.ui.source.browse.Pager
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers

View File

@ -1,13 +1,13 @@
package eu.kanade.tachiyomi.ui.catalogue.latest
package eu.kanade.tachiyomi.ui.source.latest
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCataloguePresenter
import eu.kanade.tachiyomi.ui.catalogue.browse.Pager
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
import eu.kanade.tachiyomi.ui.source.browse.Pager
/**
* Presenter of [LatestUpdatesController]. Inherit BrowseCataloguePresenter.
*/
class LatestUpdatesPresenter(sourceId: Long) : BrowseCataloguePresenter(sourceId) {
class LatestUpdatesPresenter(sourceId: Long) : BrowseSourcePresenter(sourceId) {
override fun createPager(query: String, filters: FilterList): Pager {
return LatestUpdatesPager(source)

View File

@ -7,7 +7,7 @@ import android.os.Build
import android.view.ContextThemeWrapper
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.catalogue.CataloguePresenter
import eu.kanade.tachiyomi.ui.source.SourcePresenter
import java.util.Locale
import uy.kohesive.injekt.injectLazy
@ -57,7 +57,7 @@ object LocaleHelper {
return when (lang) {
null -> ""
"" -> context.getString(R.string.other)
CataloguePresenter.PINNED_KEY -> context.getString(R.string.pinned)
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned)
"all" -> context.getString(R.string.all)
else -> {
val locale = getLocale(lang)

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/catalouge_layout"
android:id="@+id/source_layout"
android:layout_height="match_parent">
<LinearLayout
@ -12,7 +12,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/catalogue_view"
tools:context="eu.kanade.tachiyomi.ui.catalogue.browse.BrowseCatalogueController">
tools:context="eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController">
<ProgressBar
android:id="@+id/progress"

View File

@ -7,4 +7,4 @@
android:layout_height="match_parent"
android:columnWidth="140dp"
android:clipToPadding="false"
tools:listitem="@layout/catalogue_grid_item" />
tools:listitem="@layout/manga_grid_item" />

View File

@ -8,5 +8,5 @@
android:layout_height="match_parent"
android:columnWidth="120dp"
android:clipToPadding="false"
tools:listitem="@layout/catalogue_grid_item"
tools:listitem="@layout/manga_grid_item"
xmlns:app="http://schemas.android.com/apk/res-auto" />

View File

@ -7,7 +7,7 @@
<include
android:id="@+id/migration_manga_card_from"
layout="@layout/catalogue_grid_item"
layout="@layout/manga_grid_item"
android:layout_width="150dp"
app:layout_constraintVertical_bias="1.0"
android:layout_height="wrap_content"
@ -34,7 +34,7 @@
<include
android:id="@+id/migration_manga_card_to"
layout="@layout/catalogue_grid_item"
layout="@layout/manga_grid_item"
app:layout_constraintVertical_bias="1.0"
android:layout_width="150dp"
android:layout_height="wrap_content"

View File

@ -18,7 +18,7 @@
android:clipToPadding="false"
android:layout_marginBottom="30dp"
android:paddingBottom="20dp"
tools:listitem="@layout/catalogue_main_controller_card" />
tools:listitem="@layout/source_header_item" />
</FrameLayout>

View File

@ -12,6 +12,6 @@
android:clipToPadding="false"
android:paddingTop="4dp"
android:paddingBottom="4dp"
tools:listitem="@layout/catalogue_global_search_controller_card" />
tools:listitem="@layout/source_global_search_controller_card" />
</FrameLayout>

View File

@ -44,7 +44,7 @@
android:paddingEnd="4dp"
android:paddingStart="4dp"
android:clipToPadding="false"
tools:listitem="@layout/catalogue_global_search_controller_card_item" />
tools:listitem="@layout/source_global_search_controller_card_item" />
</androidx.cardview.widget.CardView>