diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 158de8207..851e17029 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -71,11 +71,11 @@ object PreferenceKeys { 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 catalogueDisplayMode = "pref_display_mode_catalogue" + const val sourceDisplayMode = "pref_display_mode_catalogue" const val enabledLanguages = "source_languages" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index f45ab1eb7..8cb193959 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -135,13 +135,13 @@ class PreferencesHelper(val context: Context) { 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 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("en", Locale.getDefault().language)) @@ -215,9 +215,9 @@ class PreferencesHelper(val context: Context) { fun searchPinnedSourcesOnly() = prefs.getBoolean(Keys.searchPinnedSourcesOnly, false) - fun hiddenCatalogues() = flowPrefs.getStringSet("hidden_catalogues", emptySet()) + 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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index f0d58c1d6..8aa62b84a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt @@ -144,7 +144,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } // React to enable/disable all changes - preferences.hiddenCatalogues().asFlow() + preferences.disabledSources().asFlow() .onEach { val enabled = source.isEnabled() isChecked = enabled @@ -212,9 +212,9 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } 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) { current - source.id.toString() } else { @@ -224,7 +224,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } private fun Source.isEnabled(): Boolean { - return id.toString() !in preferences.hiddenCatalogues().get() + return id.toString() !in preferences.disabledSources().get() } private fun getPreferenceThemeContext(): Context { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt index 6aac19de4..c0593c7df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt @@ -120,7 +120,7 @@ class SourceController : private fun onItemClick(position: Int) { val item = adapter?.getItem(position) as? SourceItem ?: return val source = item.source - openCatalogue(source, BrowseSourceController(source)) + openSource(source, BrowseSourceController(source)) } override fun onItemLongClick(position: Int) { @@ -132,11 +132,11 @@ class SourceController : val items = mutableListOf( Pair( 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) { - items.add(Pair(activity.getString(R.string.action_hide), { hideCatalogue(item.source) })) + items.add(Pair(activity.getString(R.string.action_disable), { disableSource(item.source) })) } MaterialDialog(activity) @@ -151,19 +151,19 @@ class SourceController : .show() } - private fun hideCatalogue(source: Source) { - val current = preferences.hiddenCatalogues().get() - preferences.hiddenCatalogues().set(current + source.id.toString()) + private fun disableSource(source: Source) { + val current = preferences.disabledSources().get() + preferences.disabledSources().set(current + source.id.toString()) presenter.updateSources() } - private fun pinCatalogue(source: Source, isPinned: Boolean) { - val current = preferences.pinnedCatalogues().get() + private fun pinSource(source: Source, isPinned: Boolean) { + val current = preferences.pinnedSources().get() if (isPinned) { - preferences.pinnedCatalogues().set(current - source.id.toString()) + preferences.pinnedSources().set(current - source.id.toString()) } else { - preferences.pinnedCatalogues().set(current + source.id.toString()) + preferences.pinnedSources().set(current + source.id.toString()) } presenter.updateSources() @@ -181,14 +181,14 @@ class SourceController : */ override fun onLatestClick(position: Int) { 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. */ - private fun openCatalogue(source: CatalogueSource, controller: BrowseSourceController) { - preferences.lastUsedCatalogueSource().set(source.id) + private fun openSource(source: CatalogueSource, controller: BrowseSourceController) { + preferences.lastUsedSource().set(source.id) parentController!!.router.pushController(controller.withFadeTransaction()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt index 4e4e378bb..24db7e8b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceFilterController.kt @@ -78,17 +78,17 @@ class SourceFilterController : SettingsController() { * @param group the language category. */ private fun addLanguageSources(group: PreferenceGroup, sources: List) { - val hiddenCatalogues = preferences.hiddenCatalogues().get() + val disabledSourceIds = preferences.disabledSources().get() sources - .sortedBy { it.id.toString() in hiddenCatalogues } + .sortedBy { it.id.toString() in disabledSourceIds } .map { source -> CheckBoxPreference(group.context).apply { val id = source.id.toString() title = source.name key = source.getPreferenceKey() isPersistent = false - isChecked = id !in hiddenCatalogues + isChecked = id !in disabledSourceIds val sourceIcon = source.icon() if (sourceIcon != null) { @@ -97,9 +97,9 @@ class SourceFilterController : SettingsController() { onChange { newValue -> val checked = newValue as Boolean - val current = preferences.hiddenCatalogues().get() + val current = preferences.disabledSources().get() - preferences.hiddenCatalogues().set( + preferences.disabledSources().set( if (checked) { current - id } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt index acad3dbe3..66d71a5bc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt @@ -58,7 +58,7 @@ class SourcePresenter( sourceSubscription?.unsubscribe() val pinnedSources = mutableListOf() - val pinnedCatalogues = preferences.pinnedCatalogues().get() + val pinnedSourceIds = preferences.pinnedSources().get() val map = TreeMap> { d1, d2 -> // Catalogues without a lang defined will be placed at the end @@ -72,7 +72,7 @@ class SourcePresenter( var sourceItems = byLang.flatMap { val langItem = LangItem(it.key) it.value.map { source -> - if (source.id.toString() in pinnedCatalogues) { + if (source.id.toString() in pinnedSourceIds) { pinnedSources.add(SourceItem(source, LangItem(PINNED_KEY))) } @@ -90,10 +90,10 @@ class SourcePresenter( private fun loadLastUsedSource() { // Immediate initial load - preferences.lastUsedCatalogueSource().get().let { updateLastUsedSource(it) } + preferences.lastUsedSource().get().let { updateLastUsedSource(it) } // Subsequent updates - preferences.lastUsedCatalogueSource().asFlow() + preferences.lastUsedSource().asFlow() .drop(1) .onStart { delay(500) } .distinctUntilChanged() @@ -119,11 +119,11 @@ class SourcePresenter( */ private fun getEnabledSources(): List { val languages = preferences.enabledLanguages().get() - val hiddenCatalogues = preferences.hiddenCatalogues().get() + val disabledSourceIds = preferences.disabledSources().get() return sourceManager.getCatalogueSources() .filter { it.lang in languages } - .filterNot { it.id.toString() in hiddenCatalogues } + .filterNot { it.id.toString() in disabledSourceIds } .sortedBy { "(${it.lang}) ${it.name}" } + sourceManager.get(LocalSource.ID) as LocalSource } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index 640a89091..93fbe2fe6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -192,7 +192,7 @@ open class BrowseSourceController(bundle: Bundle) : binding.catalogueView.removeView(oldRecycler) } - val recycler = if (preferences.catalogueDisplayMode().get() == DisplayMode.LIST) { + val recycler = if (preferences.sourceDisplayMode().get() == DisplayMode.LIST) { RecyclerView(view.context).apply { id = R.id.recycler layoutManager = LinearLayoutManager(context) @@ -271,7 +271,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.COMFORTABLE_GRID -> R.id.action_comfortable_grid DisplayMode.LIST -> R.id.action_list @@ -445,7 +445,7 @@ open class BrowseSourceController(bundle: Bundle) : val view = view ?: return val adapter = adapter ?: return - preferences.catalogueDisplayMode().set(mode) + preferences.sourceDisplayMode().set(mode) presenter.refreshDisplayMode() activity?.invalidateOptionsMenu() setupRecycler(view) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt index 43268682b..baabd31f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt @@ -139,7 +139,7 @@ open class BrowseSourcePresenter( val sourceId = source.id - val catalogueDisplayMode = prefs.catalogueDisplayMode() + val sourceDisplayMode = prefs.sourceDisplayMode() // Prepare the pager. pagerSubscription?.let { remove(it) } @@ -147,7 +147,7 @@ open class BrowseSourcePresenter( .observeOn(Schedulers.io()) .map { pair -> pair.first to pair.second.map { networkToLocalManga(it, sourceId) } } .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()) .subscribeReplay( { view, (page, mangas) -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt index 93942f761..5ee0bb61a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceItem.kt @@ -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.gradient -class SourceItem(val manga: Manga, private val catalogueDisplayMode: Preference) : +class SourceItem(val manga: Manga, private val displayMode: Preference) : AbstractFlexibleItem() { override fun getLayoutRes(): Int { - return when (catalogueDisplayMode.get()) { + return when (displayMode.get()) { DisplayMode.COMPACT_GRID -> R.layout.source_compact_grid_item DisplayMode.COMFORTABLE_GRID -> R.layout.source_comfortable_grid_item DisplayMode.LIST -> R.layout.source_list_item @@ -32,7 +32,7 @@ class SourceItem(val manga: Manga, private val catalogueDisplayMode: Preference< view: View, adapter: FlexibleAdapter> ): SourceHolder { - return when (catalogueDisplayMode.get()) { + return when (displayMode.get()) { DisplayMode.COMPACT_GRID -> { val parent = adapter.recyclerView as AutofitRecyclerView val coverHeight = parent.itemWidth / 3 * 4 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt index 276ca3270..ba8ab206c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt @@ -197,7 +197,7 @@ open class GlobalSearchController( * Opens a catalogue with the given search. */ override fun onTitleClick(source: CatalogueSource) { - presenter.preferences.lastUsedCatalogueSource().set(source.id) + presenter.preferences.lastUsedSource().set(source.id) router.pushController(BrowseSourceController(source, presenter.query).withFadeTransaction()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt index 1d77def19..12c2ae54e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt @@ -102,13 +102,13 @@ open class GlobalSearchPresenter( */ protected open fun getEnabledSources(): List { val languages = preferences.enabledLanguages().get() - val hiddenCatalogues = preferences.hiddenCatalogues().get() - val pinnedCatalogues = preferences.pinnedCatalogues().get() + val disabledSourceIds = preferences.disabledSources().get() + val pinnedSourceIds = preferences.pinnedSources().get() return sourceManager.getCatalogueSources() .filter { it.lang in languages } - .filterNot { it.id.toString() in hiddenCatalogues } - .sortedWith(compareBy({ it.id.toString() !in pinnedCatalogues }, { "(${it.lang}) ${it.name}" })) + .filterNot { it.id.toString() in disabledSourceIds } + .sortedWith(compareBy({ it.id.toString() !in pinnedSourceIds }, { "(${it.lang}) ${it.name}" })) } private fun getSourcesToQuery(): List { @@ -129,10 +129,10 @@ open class GlobalSearchPresenter( } val onlyPinnedSources = preferences.searchPinnedSourcesOnly() - val pinnedCatalogues = preferences.pinnedCatalogues().get() + val pinnedSourceIds = preferences.pinnedSources().get() return enabledSources - .filter { if (onlyPinnedSources) it.id.toString() in pinnedCatalogues else true } + .filter { if (onlyPinnedSources) it.id.toString() in pinnedSourceIds else true } } /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ca61336c3..773058a96 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -90,7 +90,7 @@ Download badges Unread badges Show category tabs - Hide + Disable Pin Unpin Cancel