Rename some code from "catalogue" to "source"
(cherry picked from commit eee0bd6cf4f09b23b6d8979d52652efa850f339e) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt
This commit is contained in:
parent
6fe808be42
commit
07c69e30dc
@ -71,11 +71,11 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val autoUpdateTrack = "pref_auto_update_manga_sync_key"
|
const val autoUpdateTrack = "pref_auto_update_manga_sync_key"
|
||||||
|
|
||||||
const val lastUsedCatalogueSource = "last_catalogue_source"
|
const val lastUsedSource = "last_catalogue_source"
|
||||||
|
|
||||||
const val lastUsedCategory = "last_used_category"
|
const val lastUsedCategory = "last_used_category"
|
||||||
|
|
||||||
const val catalogueDisplayMode = "pref_display_mode_catalogue"
|
const val sourceDisplayMode = "pref_display_mode_catalogue"
|
||||||
|
|
||||||
const val enabledLanguages = "source_languages"
|
const val enabledLanguages = "source_languages"
|
||||||
|
|
||||||
|
@ -135,13 +135,13 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true)
|
fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true)
|
||||||
|
|
||||||
fun lastUsedCatalogueSource() = flowPrefs.getLong(Keys.lastUsedCatalogueSource, -1)
|
fun lastUsedSource() = flowPrefs.getLong(Keys.lastUsedSource, -1)
|
||||||
|
|
||||||
fun lastUsedCategory() = flowPrefs.getInt(Keys.lastUsedCategory, 0)
|
fun lastUsedCategory() = flowPrefs.getInt(Keys.lastUsedCategory, 0)
|
||||||
|
|
||||||
fun lastVersionCode() = flowPrefs.getInt("last_version_code", 0)
|
fun lastVersionCode() = flowPrefs.getInt("last_version_code", 0)
|
||||||
|
|
||||||
fun catalogueDisplayMode() = flowPrefs.getEnum(Keys.catalogueDisplayMode, DisplayMode.COMPACT_GRID)
|
fun sourceDisplayMode() = flowPrefs.getEnum(Keys.sourceDisplayMode, DisplayMode.COMPACT_GRID)
|
||||||
|
|
||||||
fun enabledLanguages() = flowPrefs.getStringSet(Keys.enabledLanguages, setOf("all", "en", Locale.getDefault().language))
|
fun enabledLanguages() = flowPrefs.getStringSet(Keys.enabledLanguages, setOf("all", "en", Locale.getDefault().language))
|
||||||
|
|
||||||
@ -222,9 +222,9 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun searchPinnedSourcesOnly() = prefs.getBoolean(Keys.searchPinnedSourcesOnly, false)
|
fun searchPinnedSourcesOnly() = prefs.getBoolean(Keys.searchPinnedSourcesOnly, false)
|
||||||
|
|
||||||
fun hiddenCatalogues() = flowPrefs.getStringSet("hidden_catalogues", mutableSetOf())
|
fun disabledSources() = flowPrefs.getStringSet("hidden_catalogues", emptySet())
|
||||||
|
|
||||||
fun pinnedCatalogues() = flowPrefs.getStringSet("pinned_catalogues", emptySet())
|
fun pinnedSources() = flowPrefs.getStringSet("pinned_catalogues", emptySet())
|
||||||
|
|
||||||
fun downloadNew() = flowPrefs.getBoolean(Keys.downloadNew, false)
|
fun downloadNew() = flowPrefs.getBoolean(Keys.downloadNew, false)
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
// React to enable/disable all changes
|
// React to enable/disable all changes
|
||||||
preferences.hiddenCatalogues().asFlow()
|
preferences.disabledSources().asFlow()
|
||||||
.onEach {
|
.onEach {
|
||||||
val enabled = source.isEnabled()
|
val enabled = source.isEnabled()
|
||||||
isChecked = enabled
|
isChecked = enabled
|
||||||
@ -217,9 +217,9 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleSource(source: Source, enable: Boolean) {
|
private fun toggleSource(source: Source, enable: Boolean) {
|
||||||
val current = preferences.hiddenCatalogues().get()
|
val current = preferences.disabledSources().get()
|
||||||
|
|
||||||
preferences.hiddenCatalogues().set(
|
preferences.disabledSources().set(
|
||||||
if (enable) {
|
if (enable) {
|
||||||
current - source.id.toString()
|
current - source.id.toString()
|
||||||
} else {
|
} else {
|
||||||
@ -229,7 +229,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Source.isEnabled(): Boolean {
|
private fun Source.isEnabled(): Boolean {
|
||||||
return id.toString() !in preferences.hiddenCatalogues().get()
|
return id.toString() !in preferences.disabledSources().get()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPreferenceThemeContext(): Context {
|
private fun getPreferenceThemeContext(): Context {
|
||||||
|
@ -15,7 +15,7 @@ import uy.kohesive.injekt.api.get
|
|||||||
class LatestCardItem(val manga: Manga) : AbstractFlexibleItem<LatestCardHolder>() {
|
class LatestCardItem(val manga: Manga) : AbstractFlexibleItem<LatestCardHolder>() {
|
||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
return when (Injekt.get<PreferencesHelper>().catalogueDisplayMode().get()) {
|
return when (Injekt.get<PreferencesHelper>().sourceDisplayMode().get()) {
|
||||||
PreferenceValues.DisplayMode.COMPACT_GRID -> R.layout.global_search_controller_compact_card_item
|
PreferenceValues.DisplayMode.COMPACT_GRID -> R.layout.global_search_controller_compact_card_item
|
||||||
else -> R.layout.global_search_controller_comfortable_card_item
|
else -> R.layout.global_search_controller_comfortable_card_item
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ open class LatestController :
|
|||||||
* Opens a catalogue with the given search.
|
* Opens a catalogue with the given search.
|
||||||
*/
|
*/
|
||||||
override fun onTitleClick(source: CatalogueSource) {
|
override fun onTitleClick(source: CatalogueSource) {
|
||||||
presenter.preferences.lastUsedCatalogueSource().set(source.id)
|
presenter.preferences.lastUsedSource().set(source.id)
|
||||||
parentController?.router?.pushController(LatestUpdatesController(source).withFadeTransaction())
|
parentController?.router?.pushController(LatestUpdatesController(source).withFadeTransaction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,14 +66,14 @@ open class LatestPresenter(
|
|||||||
protected open fun getEnabledSources(): List<CatalogueSource> {
|
protected open fun getEnabledSources(): List<CatalogueSource> {
|
||||||
val languages = preferences.enabledLanguages().get()
|
val languages = preferences.enabledLanguages().get()
|
||||||
val watchedSources = preferences.latestTabSources().get()
|
val watchedSources = preferences.latestTabSources().get()
|
||||||
val pinnedCatalogues = preferences.pinnedCatalogues().get()
|
val pinnedSources = preferences.pinnedSources().get()
|
||||||
|
|
||||||
val list = sourceManager.getVisibleCatalogueSources()
|
val list = sourceManager.getVisibleCatalogueSources()
|
||||||
.filter { it.lang in languages }
|
.filter { it.lang in languages }
|
||||||
.sortedBy { "(${it.lang}) ${it.name}" }
|
.sortedBy { "(${it.lang}) ${it.name}" }
|
||||||
|
|
||||||
return list.filter { it.id.toString() in watchedSources }
|
return list.filter { it.id.toString() in watchedSources }
|
||||||
.sortedBy { it.id.toString() !in pinnedCatalogues }
|
.sortedBy { it.id.toString() !in pinnedSources }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSourcesToGetLatest(): List<CatalogueSource> {
|
private fun getSourcesToGetLatest(): List<CatalogueSource> {
|
||||||
|
@ -145,8 +145,8 @@ class PreMigrationController(bundle: Bundle? = null) :
|
|||||||
|
|
||||||
fun isEnabled(id: String): Boolean {
|
fun isEnabled(id: String): Boolean {
|
||||||
val sourcesSaved = prefs.migrationSources().get()
|
val sourcesSaved = prefs.migrationSources().get()
|
||||||
val hiddenCatalogues = prefs.hiddenCatalogues().get()
|
val disabledSourceIds = prefs.disabledSources().get()
|
||||||
return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues
|
return if (sourcesSaved.isEmpty()) id !in disabledSourceIds
|
||||||
else sourcesSaved.split("/").contains(id)
|
else sourcesSaved.split("/").contains(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +164,9 @@ class PreMigrationController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
R.id.action_match_enabled, R.id.action_match_pinned -> {
|
R.id.action_match_enabled, R.id.action_match_pinned -> {
|
||||||
val enabledSources = if (item.itemId == R.id.action_match_enabled) {
|
val enabledSources = if (item.itemId == R.id.action_match_enabled) {
|
||||||
prefs.hiddenCatalogues().get().mapNotNull { it.toLongOrNull() }
|
prefs.disabledSources().get().mapNotNull { it.toLongOrNull() }
|
||||||
} else {
|
} else {
|
||||||
prefs.pinnedCatalogues().get().mapNotNull { it.toLongOrNull() }
|
prefs.pinnedSources().get().mapNotNull { it.toLongOrNull() }
|
||||||
}
|
}
|
||||||
val items = adapter?.currentItems?.toList() ?: return true
|
val items = adapter?.currentItems?.toList() ?: return true
|
||||||
items.forEach {
|
items.forEach {
|
||||||
|
@ -148,7 +148,7 @@ class SourceController(bundle: Bundle? = null) :
|
|||||||
when (mode) {
|
when (mode) {
|
||||||
Mode.CATALOGUE -> {
|
Mode.CATALOGUE -> {
|
||||||
// Open the catalogue view.
|
// Open the catalogue view.
|
||||||
openCatalogue(source, BrowseSourceController(source))
|
openSource(source, BrowseSourceController(source))
|
||||||
}
|
}
|
||||||
Mode.SMART_SEARCH -> router.pushController(
|
Mode.SMART_SEARCH -> router.pushController(
|
||||||
SmartSearchController(
|
SmartSearchController(
|
||||||
@ -171,11 +171,11 @@ class SourceController(bundle: Bundle? = null) :
|
|||||||
val items = mutableListOf(
|
val items = mutableListOf(
|
||||||
Pair(
|
Pair(
|
||||||
activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin),
|
activity.getString(if (isPinned) R.string.action_unpin else R.string.action_pin),
|
||||||
{ pinCatalogue(item.source, isPinned) }
|
{ pinSource(item.source, isPinned) }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if (item.source !is LocalSource) {
|
if (item.source !is LocalSource) {
|
||||||
items.add(Pair(activity.getString(R.string.action_hide), { hideCatalogue(item.source) }))
|
items.add(Pair(activity.getString(R.string.action_disable), { disableSource(item.source) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -210,19 +210,19 @@ class SourceController(bundle: Bundle? = null) :
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideCatalogue(source: Source) {
|
private fun disableSource(source: Source) {
|
||||||
val current = preferences.hiddenCatalogues().get()
|
val current = preferences.disabledSources().get()
|
||||||
preferences.hiddenCatalogues().set(current + source.id.toString())
|
preferences.disabledSources().set(current + source.id.toString())
|
||||||
|
|
||||||
presenter.updateSources()
|
presenter.updateSources()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pinCatalogue(source: Source, isPinned: Boolean) {
|
private fun pinSource(source: Source, isPinned: Boolean) {
|
||||||
val current = preferences.pinnedCatalogues().get()
|
val current = preferences.pinnedSources().get()
|
||||||
if (isPinned) {
|
if (isPinned) {
|
||||||
preferences.pinnedCatalogues().set(current - source.id.toString())
|
preferences.pinnedSources().set(current - source.id.toString())
|
||||||
} else {
|
} else {
|
||||||
preferences.pinnedCatalogues().set(current + source.id.toString())
|
preferences.pinnedSources().set(current + source.id.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
presenter.updateSources()
|
presenter.updateSources()
|
||||||
@ -303,14 +303,14 @@ class SourceController(bundle: Bundle? = null) :
|
|||||||
*/
|
*/
|
||||||
override fun onLatestClick(position: Int) {
|
override fun onLatestClick(position: Int) {
|
||||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||||
openCatalogue(item.source, LatestUpdatesController(item.source))
|
openSource(item.source, LatestUpdatesController(item.source))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a catalogue with the given controller.
|
* Opens a catalogue with the given controller.
|
||||||
*/
|
*/
|
||||||
private fun openCatalogue(source: CatalogueSource, controller: BrowseSourceController) {
|
private fun openSource(source: CatalogueSource, controller: BrowseSourceController) {
|
||||||
preferences.lastUsedCatalogueSource().set(source.id)
|
preferences.lastUsedSource().set(source.id)
|
||||||
parentController!!.router.pushController(controller.withFadeTransaction())
|
parentController!!.router.pushController(controller.withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,24 +106,24 @@ class SourceFilterController : SettingsController() {
|
|||||||
* @param group the language category.
|
* @param group the language category.
|
||||||
*/
|
*/
|
||||||
private fun addLanguageSources(group: PreferenceGroup, sources: List<HttpSource>) {
|
private fun addLanguageSources(group: PreferenceGroup, sources: List<HttpSource>) {
|
||||||
val hiddenCatalogues = preferences.hiddenCatalogues().get()
|
val disabledSourceIds = preferences.disabledSources().get()
|
||||||
|
|
||||||
val selectAllPreference = CheckBoxPreference(group.context).apply {
|
val selectAllPreference = CheckBoxPreference(group.context).apply {
|
||||||
title = "\t\t${context.getString(R.string.pref_category_all_sources)}"
|
title = "\t\t${context.getString(R.string.pref_category_all_sources)}"
|
||||||
key = "all_${sources.first().lang}"
|
key = "all_${sources.first().lang}"
|
||||||
isPersistent = false
|
isPersistent = false
|
||||||
isChecked = sources.all { it.id.toString() !in hiddenCatalogues }
|
isChecked = sources.all { it.id.toString() !in disabledSourceIds }
|
||||||
isVisible = query.isEmpty()
|
isVisible = query.isEmpty()
|
||||||
|
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
val checked = newValue as Boolean
|
val checked = newValue as Boolean
|
||||||
val current = preferences.hiddenCatalogues().get() as MutableSet? ?: mutableSetOf()
|
val current = preferences.disabledSources().get() as MutableSet? ?: mutableSetOf()
|
||||||
if (checked) {
|
if (checked) {
|
||||||
current.removeAll(sources.map { it.id.toString() })
|
current.removeAll(sources.map { it.id.toString() })
|
||||||
} else {
|
} else {
|
||||||
current.addAll(sources.map { it.id.toString() })
|
current.addAll(sources.map { it.id.toString() })
|
||||||
}
|
}
|
||||||
preferences.hiddenCatalogues().set(current)
|
preferences.disabledSources().set(current)
|
||||||
group.removeAll()
|
group.removeAll()
|
||||||
addLanguageSources(group, sortedSources(sources))
|
addLanguageSources(group, sortedSources(sources))
|
||||||
true
|
true
|
||||||
@ -137,7 +137,7 @@ class SourceFilterController : SettingsController() {
|
|||||||
title = source.name
|
title = source.name
|
||||||
key = getSourceKey(source.id)
|
key = getSourceKey(source.id)
|
||||||
isPersistent = false
|
isPersistent = false
|
||||||
isChecked = id !in hiddenCatalogues
|
isChecked = id !in disabledSourceIds
|
||||||
isVisible = query.isEmpty() || source.name.contains(query, ignoreCase = true)
|
isVisible = query.isEmpty() || source.name.contains(query, ignoreCase = true)
|
||||||
|
|
||||||
val sourceIcon = source.icon()
|
val sourceIcon = source.icon()
|
||||||
@ -147,9 +147,9 @@ class SourceFilterController : SettingsController() {
|
|||||||
|
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
val checked = newValue as Boolean
|
val checked = newValue as Boolean
|
||||||
val current = preferences.hiddenCatalogues().get()
|
val current = preferences.disabledSources().get()
|
||||||
|
|
||||||
preferences.hiddenCatalogues().set(
|
preferences.disabledSources().set(
|
||||||
if (checked) {
|
if (checked) {
|
||||||
current - id
|
current - id
|
||||||
} else {
|
} else {
|
||||||
@ -226,9 +226,9 @@ class SourceFilterController : SettingsController() {
|
|||||||
private fun sortedSources(sources: List<HttpSource>?): List<HttpSource> {
|
private fun sortedSources(sources: List<HttpSource>?): List<HttpSource> {
|
||||||
val sourceAlpha = sources.orEmpty().sortedBy { it.name }
|
val sourceAlpha = sources.orEmpty().sortedBy { it.name }
|
||||||
return if (sorting == SourcesSort.Enabled) {
|
return if (sorting == SourcesSort.Enabled) {
|
||||||
val hiddenCatalogues = preferences.hiddenCatalogues().get()
|
val disabledSourceIds = preferences.disabledSources().get()
|
||||||
sourceAlpha.filter { it.id.toString() !in hiddenCatalogues } +
|
sourceAlpha.filter { it.id.toString() !in disabledSourceIds } +
|
||||||
sourceAlpha.filterNot { it.id.toString() !in hiddenCatalogues }
|
sourceAlpha.filterNot { it.id.toString() !in disabledSourceIds }
|
||||||
} else {
|
} else {
|
||||||
sourceAlpha
|
sourceAlpha
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class SourcePresenter(
|
|||||||
sourceSubscription?.unsubscribe()
|
sourceSubscription?.unsubscribe()
|
||||||
|
|
||||||
val pinnedSources = mutableListOf<SourceItem>()
|
val pinnedSources = mutableListOf<SourceItem>()
|
||||||
val pinnedCatalogues = preferences.pinnedCatalogues().get()
|
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
val categories = mutableListOf<SourceCategory>()
|
val categories = mutableListOf<SourceCategory>()
|
||||||
@ -91,7 +91,7 @@ class SourcePresenter(
|
|||||||
var sourceItems = byLang.flatMap {
|
var sourceItems = byLang.flatMap {
|
||||||
val langItem = LangItem(it.key)
|
val langItem = LangItem(it.key)
|
||||||
it.value.map { source ->
|
it.value.map { source ->
|
||||||
if (source.id.toString() in pinnedCatalogues) {
|
if (source.id.toString() in pinnedSourceIds) {
|
||||||
pinnedSources.add(SourceItem(source, LangItem(PINNED_KEY), controllerMode == SourceController.Mode.CATALOGUE))
|
pinnedSources.add(SourceItem(source, LangItem(PINNED_KEY), controllerMode == SourceController.Mode.CATALOGUE))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +135,10 @@ class SourcePresenter(
|
|||||||
|
|
||||||
private fun loadLastUsedSource() {
|
private fun loadLastUsedSource() {
|
||||||
// Immediate initial load
|
// Immediate initial load
|
||||||
preferences.lastUsedCatalogueSource().get().let { updateLastUsedSource(it) }
|
preferences.lastUsedSource().get().let { updateLastUsedSource(it) }
|
||||||
|
|
||||||
// Subsequent updates
|
// Subsequent updates
|
||||||
preferences.lastUsedCatalogueSource().asFlow()
|
preferences.lastUsedSource().asFlow()
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.onStart { delay(500) }
|
.onStart { delay(500) }
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
@ -164,11 +164,11 @@ class SourcePresenter(
|
|||||||
*/
|
*/
|
||||||
private fun getEnabledSources(): List<CatalogueSource> {
|
private fun getEnabledSources(): List<CatalogueSource> {
|
||||||
val languages = preferences.enabledLanguages().get()
|
val languages = preferences.enabledLanguages().get()
|
||||||
val hiddenCatalogues = preferences.hiddenCatalogues().get()
|
val disabledSourceIds = preferences.disabledSources().get()
|
||||||
|
|
||||||
return sourceManager.getVisibleCatalogueSources()
|
return sourceManager.getVisibleCatalogueSources()
|
||||||
.filter { it.lang in languages }
|
.filter { it.lang in languages }
|
||||||
.filterNot { it.id.toString() in hiddenCatalogues }
|
.filterNot { it.id.toString() in disabledSourceIds }
|
||||||
.sortedBy { "(${it.lang}) ${it.name}" } +
|
.sortedBy { "(${it.lang}) ${it.name}" } +
|
||||||
sourceManager.get(LocalSource.ID) as LocalSource
|
sourceManager.get(LocalSource.ID) as LocalSource
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
binding.catalogueView.removeView(oldRecycler)
|
binding.catalogueView.removeView(oldRecycler)
|
||||||
}
|
}
|
||||||
|
|
||||||
val recycler = if (preferences.catalogueDisplayMode().get() == DisplayMode.LIST) {
|
val recycler = if (preferences.sourceDisplayMode().get() == DisplayMode.LIST) {
|
||||||
RecyclerView(view.context).apply {
|
RecyclerView(view.context).apply {
|
||||||
id = R.id.recycler
|
id = R.id.recycler
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
@ -418,7 +418,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val displayItem = when (preferences.catalogueDisplayMode().get()) {
|
val displayItem = when (preferences.sourceDisplayMode().get()) {
|
||||||
DisplayMode.COMPACT_GRID -> R.id.action_compact_grid
|
DisplayMode.COMPACT_GRID -> R.id.action_compact_grid
|
||||||
DisplayMode.COMFORTABLE_GRID -> R.id.action_comfortable_grid
|
DisplayMode.COMFORTABLE_GRID -> R.id.action_comfortable_grid
|
||||||
DisplayMode.LIST -> R.id.action_list
|
DisplayMode.LIST -> R.id.action_list
|
||||||
@ -620,7 +620,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
val view = view ?: return
|
val view = view ?: return
|
||||||
val adapter = adapter ?: return
|
val adapter = adapter ?: return
|
||||||
|
|
||||||
preferences.catalogueDisplayMode().set(mode)
|
preferences.sourceDisplayMode().set(mode)
|
||||||
presenter.refreshDisplayMode()
|
presenter.refreshDisplayMode()
|
||||||
activity?.invalidateOptionsMenu()
|
activity?.invalidateOptionsMenu()
|
||||||
setupRecycler(view)
|
setupRecycler(view)
|
||||||
|
@ -156,7 +156,7 @@ open class BrowseSourcePresenter(
|
|||||||
|
|
||||||
val sourceId = source.id
|
val sourceId = source.id
|
||||||
|
|
||||||
val catalogueDisplayMode = prefs.catalogueDisplayMode()
|
val sourceDisplayMode = prefs.sourceDisplayMode()
|
||||||
|
|
||||||
// Prepare the pager.
|
// Prepare the pager.
|
||||||
pagerSubscription?.let { remove(it) }
|
pagerSubscription?.let { remove(it) }
|
||||||
@ -164,7 +164,7 @@ open class BrowseSourcePresenter(
|
|||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.map { pair -> pair.first to pair.second.map { networkToLocalManga(it, sourceId) } }
|
.map { pair -> pair.first to pair.second.map { networkToLocalManga(it, sourceId) } }
|
||||||
.doOnNext { initializeMangas(it.second) }
|
.doOnNext { initializeMangas(it.second) }
|
||||||
.map { pair -> pair.first to pair.second.map { SourceItem(it, catalogueDisplayMode) } }
|
.map { pair -> pair.first to pair.second.map { SourceItem(it, sourceDisplayMode) } }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeReplay(
|
.subscribeReplay(
|
||||||
{ view, (page, mangas) ->
|
{ view, (page, mangas) ->
|
||||||
|
@ -17,11 +17,11 @@ import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
|||||||
import kotlinx.android.synthetic.main.source_compact_grid_item.view.card
|
import kotlinx.android.synthetic.main.source_compact_grid_item.view.card
|
||||||
import kotlinx.android.synthetic.main.source_compact_grid_item.view.gradient
|
import kotlinx.android.synthetic.main.source_compact_grid_item.view.gradient
|
||||||
|
|
||||||
class SourceItem(val manga: Manga, private val catalogueDisplayMode: Preference<DisplayMode>) :
|
class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMode>) :
|
||||||
AbstractFlexibleItem<SourceHolder>() {
|
AbstractFlexibleItem<SourceHolder>() {
|
||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
return when (catalogueDisplayMode.get()) {
|
return when (displayMode.get()) {
|
||||||
DisplayMode.COMPACT_GRID -> R.layout.source_compact_grid_item
|
DisplayMode.COMPACT_GRID -> R.layout.source_compact_grid_item
|
||||||
DisplayMode.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
|
DisplayMode.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item
|
||||||
DisplayMode.LIST -> R.layout.source_list_item
|
DisplayMode.LIST -> R.layout.source_list_item
|
||||||
@ -32,7 +32,7 @@ class SourceItem(val manga: Manga, private val catalogueDisplayMode: Preference<
|
|||||||
view: View,
|
view: View,
|
||||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||||
): SourceHolder {
|
): SourceHolder {
|
||||||
return when (catalogueDisplayMode.get()) {
|
return when (displayMode.get()) {
|
||||||
DisplayMode.COMPACT_GRID -> {
|
DisplayMode.COMPACT_GRID -> {
|
||||||
val parent = adapter.recyclerView as AutofitRecyclerView
|
val parent = adapter.recyclerView as AutofitRecyclerView
|
||||||
val coverHeight = parent.itemWidth / 3 * 4
|
val coverHeight = parent.itemWidth / 3 * 4
|
||||||
|
@ -16,7 +16,7 @@ class GlobalSearchCardItem(val manga: Manga) : AbstractFlexibleItem<GlobalSearch
|
|||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
// SY -->
|
// SY -->
|
||||||
return when (Injekt.get<PreferencesHelper>().catalogueDisplayMode().get()) {
|
return when (Injekt.get<PreferencesHelper>().sourceDisplayMode().get()) {
|
||||||
PreferenceValues.DisplayMode.COMPACT_GRID -> R.layout.global_search_controller_compact_card_item
|
PreferenceValues.DisplayMode.COMPACT_GRID -> R.layout.global_search_controller_compact_card_item
|
||||||
else -> R.layout.global_search_controller_comfortable_card_item
|
else -> R.layout.global_search_controller_comfortable_card_item
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ open class GlobalSearchController(
|
|||||||
* Opens a catalogue with the given search.
|
* Opens a catalogue with the given search.
|
||||||
*/
|
*/
|
||||||
override fun onTitleClick(source: CatalogueSource) {
|
override fun onTitleClick(source: CatalogueSource) {
|
||||||
presenter.preferences.lastUsedCatalogueSource().set(source.id)
|
presenter.preferences.lastUsedSource().set(source.id)
|
||||||
router.pushController(BrowseSourceController(source, presenter.query).withFadeTransaction())
|
router.pushController(BrowseSourceController(source, presenter.query).withFadeTransaction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,18 +103,18 @@ open class GlobalSearchPresenter(
|
|||||||
*/
|
*/
|
||||||
protected open fun getEnabledSources(): List<CatalogueSource> {
|
protected open fun getEnabledSources(): List<CatalogueSource> {
|
||||||
val languages = preferences.enabledLanguages().get()
|
val languages = preferences.enabledLanguages().get()
|
||||||
val hiddenCatalogues = preferences.hiddenCatalogues().get()
|
val disabledSourceIds = preferences.disabledSources().get()
|
||||||
val pinnedCatalogues = preferences.pinnedCatalogues().get()
|
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||||
|
|
||||||
val list = sourceManager.getVisibleCatalogueSources()
|
val list = sourceManager.getVisibleCatalogueSources()
|
||||||
.filter { it.lang in languages }
|
.filter { it.lang in languages }
|
||||||
.filterNot { it.id.toString() in hiddenCatalogues }
|
.filterNot { it.id.toString() in disabledSourceIds }
|
||||||
.sortedBy { "(${it.lang}) ${it.name}" }
|
.sortedBy { "(${it.lang}) ${it.name}" }
|
||||||
|
|
||||||
return if (preferences.searchPinnedSourcesOnly()) {
|
return if (preferences.searchPinnedSourcesOnly()) {
|
||||||
list.filter { it.id.toString() in pinnedCatalogues }
|
list.filter { it.id.toString() in pinnedSourceIds }
|
||||||
} else {
|
} else {
|
||||||
list.sortedBy { it.id.toString() !in pinnedCatalogues }
|
list.sortedBy { it.id.toString() !in pinnedSourceIds }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,10 +137,10 @@ open class GlobalSearchPresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val onlyPinnedSources = preferences.searchPinnedSourcesOnly()
|
val onlyPinnedSources = preferences.searchPinnedSourcesOnly()
|
||||||
val pinnedCatalogues = preferences.pinnedCatalogues().get()
|
val pinnedSourceIds = preferences.pinnedSources().get()
|
||||||
|
|
||||||
return enabledSources
|
return enabledSources
|
||||||
.filter { if (onlyPinnedSources) it.id.toString() in pinnedCatalogues else true }
|
.filter { if (onlyPinnedSources) it.id.toString() in pinnedSourceIds else true }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
<string name="action_display_download_badge">Download badges</string>
|
<string name="action_display_download_badge">Download badges</string>
|
||||||
<string name="action_display_unread_badge">Unread badges</string>
|
<string name="action_display_unread_badge">Unread badges</string>
|
||||||
<string name="action_display_show_tabs">Show category tabs</string>
|
<string name="action_display_show_tabs">Show category tabs</string>
|
||||||
<string name="action_hide">Hide</string>
|
<string name="action_disable">Disable</string>
|
||||||
<string name="action_pin">Pin</string>
|
<string name="action_pin">Pin</string>
|
||||||
<string name="action_unpin">Unpin</string>
|
<string name="action_unpin">Unpin</string>
|
||||||
<string name="action_cancel">Cancel</string>
|
<string name="action_cancel">Cancel</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user