mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 05:05:06 +01:00
Added Sources (Browse) settings + Global Pinned Search
Also moved all migration options to the sources settings Migration sources converted to flowpref New settings: Only globally search pinned sources Match migration sources with pinned Match migration sources with enabled sources
This commit is contained in:
parent
f851c5536a
commit
45f1f99292
@ -109,6 +109,8 @@ object PreferenceKeys {
|
||||
|
||||
const val automaticExtUpdates = "automatic_ext_updates"
|
||||
|
||||
const val onlySearchPinned = "only_search_pinned"
|
||||
|
||||
const val downloadNew = "download_new"
|
||||
|
||||
const val downloadNewCategories = "download_new_categories"
|
||||
|
@ -233,7 +233,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun trustedSignatures() = rxPrefs.getStringSet("trusted_signatures", emptySet())
|
||||
|
||||
fun migrationSources() = rxPrefs.getString("migrate_sources", "")
|
||||
// using string instead of set so it is ordered
|
||||
fun migrationSources() = flowPrefs.getString("migrate_sources", "")
|
||||
|
||||
fun useSourceWithMost() = rxPrefs.getBoolean("use_source_with_most", false)
|
||||
|
||||
@ -275,6 +276,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun showCategoryInTitle() = flowPrefs.getBoolean("category_in_title", false)
|
||||
|
||||
fun onlySearchPinned() = flowPrefs.getBoolean(Keys.onlySearchPinned, true)
|
||||
|
||||
// Tutorial preferences
|
||||
fun shownFilterTutorial() = flowPrefs.getBoolean("shown_filter_tutorial", false)
|
||||
|
||||
|
@ -3,17 +3,11 @@ package eu.kanade.tachiyomi.ui.extension
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.LinearLayout
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.ui.source.SourceController
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
@ -34,7 +28,6 @@ ExtensionAdapter.OnButtonClickListener,
|
||||
ExtensionTrustDialog.Listener {
|
||||
|
||||
var sheetBehavior: BottomSheetBehavior<*>? = null
|
||||
private lateinit var autoCheckItem: AutoCheckItem
|
||||
|
||||
var shouldCallApi = false
|
||||
|
||||
@ -51,7 +44,6 @@ ExtensionAdapter.OnButtonClickListener,
|
||||
|
||||
fun onCreate(controller: SourceController) {
|
||||
// Initialize adapter, scroll listener and recycler views
|
||||
autoCheckItem = AutoCheckItem(presenter.getAutoCheckPref())
|
||||
adapter = ExtensionAdapter(this)
|
||||
sheetBehavior = BottomSheetBehavior.from(this)
|
||||
// Create recycler and set adapter.
|
||||
@ -166,15 +158,6 @@ ExtensionAdapter.OnButtonClickListener,
|
||||
adapter?.updateDataSet(extensions)
|
||||
}
|
||||
updateExtTitle()
|
||||
setLastUsedSource()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to set the last used catalogue at the top of the view.
|
||||
*/
|
||||
private fun setLastUsedSource() {
|
||||
adapter?.removeAllScrollableHeaders()
|
||||
adapter?.addScrollableHeader(autoCheckItem)
|
||||
}
|
||||
|
||||
fun downloadUpdate(item: ExtensionItem) {
|
||||
@ -189,55 +172,3 @@ ExtensionAdapter.OnButtonClickListener,
|
||||
presenter.uninstallExtension(pkgName)
|
||||
}
|
||||
}
|
||||
|
||||
class AutoCheckItem(private val autoCheck: Preference<Boolean>) : AbstractHeaderItem<AutoCheckItem.AutoCheckHolder>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return R.layout.auto_ext_checkbox
|
||||
}
|
||||
|
||||
override fun createViewHolder(
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<IFlexible<*>>
|
||||
): AutoCheckHolder {
|
||||
return AutoCheckHolder(view, adapter, autoCheck)
|
||||
}
|
||||
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<*>>,
|
||||
holder: AutoCheckHolder,
|
||||
position: Int,
|
||||
payloads: MutableList<Any?>?
|
||||
) {
|
||||
// holder.bind(autoCheck.getOrDefault())
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return (this === other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return -1
|
||||
}
|
||||
|
||||
class AutoCheckHolder(
|
||||
val view: View,
|
||||
private val adapter: FlexibleAdapter<IFlexible<*>>,
|
||||
autoCheck: Preference<Boolean>
|
||||
) :
|
||||
FlexibleViewHolder(view, adapter, true) {
|
||||
private val autoCheckbox: CheckBox = view.findViewById(R.id.auto_checkbox)
|
||||
|
||||
init {
|
||||
autoCheckbox.bindToPreference(autoCheck)
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a checkbox or switch view with a boolean preference.
|
||||
*/
|
||||
private fun CompoundButton.bindToPreference(pref: Preference<Boolean>) {
|
||||
isChecked = pref.getOrDefault()
|
||||
setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
||||
override fun startMigration(extraParam: String?) {
|
||||
val listOfSources = adapter?.items?.filter {
|
||||
it.sourceEnabled
|
||||
}?.joinToString("/") { it.source.id.toString() }
|
||||
}?.joinToString("/") { it.source.id.toString() } ?: ""
|
||||
prefs.migrationSources().set(listOfSources)
|
||||
|
||||
router.replaceTopController(
|
||||
@ -130,7 +130,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
||||
*/
|
||||
private fun getEnabledSources(): List<HttpSource> {
|
||||
val languages = prefs.enabledLanguages().getOrDefault()
|
||||
val sourcesSaved = prefs.migrationSources().getOrDefault().split("/")
|
||||
val sourcesSaved = prefs.migrationSources().get().split("/")
|
||||
var sources = sourceManager.getCatalogueSources()
|
||||
.filterIsInstance<HttpSource>()
|
||||
.filter { it.lang in languages }
|
||||
@ -145,7 +145,7 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F
|
||||
}
|
||||
|
||||
fun isEnabled(id: String): Boolean {
|
||||
val sourcesSaved = prefs.migrationSources().getOrDefault()
|
||||
val sourcesSaved = prefs.migrationSources().get()
|
||||
val hiddenCatalogues = prefs.hiddenSources().getOrDefault()
|
||||
return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues
|
||||
else sourcesSaved.split("/").contains(id)
|
||||
|
@ -126,7 +126,7 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
private suspend fun runMigrations(mangas: List<MigratingManga>) {
|
||||
val useSourceWithMost = preferences.useSourceWithMost().getOrDefault()
|
||||
|
||||
val sources = preferences.migrationSources().getOrDefault().split("/").mapNotNull {
|
||||
val sources = preferences.migrationSources().get().split("/").mapNotNull {
|
||||
val value = it.toLongOrNull() ?: return
|
||||
sourceManager.get(value) as? CatalogueSource
|
||||
}
|
||||
|
@ -0,0 +1,110 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SettingsBrowseController : SettingsController() {
|
||||
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
titleRes = R.string.sources
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.extensions
|
||||
switchPreference {
|
||||
key = PreferenceKeys.automaticExtUpdates
|
||||
titleRes = R.string.check_for_extension_updates
|
||||
defaultValue = true
|
||||
|
||||
onChange {
|
||||
it as Boolean
|
||||
ExtensionUpdateJob.setupTask(it)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_global_search
|
||||
switchPreference {
|
||||
key = PreferenceKeys.onlySearchPinned
|
||||
titleRes = R.string.only_search_pinned_when
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.migration
|
||||
// Only show this if someone has mass migrated manga once
|
||||
|
||||
preference {
|
||||
titleRes = R.string.source_migration
|
||||
onClick { router.pushController(MigrationController().withFadeTransaction()) }
|
||||
}
|
||||
if (preferences.skipPreMigration().getOrDefault() || preferences.migrationSources()
|
||||
.isSet()
|
||||
) {
|
||||
switchPreference {
|
||||
key = PreferenceKeys.skipPreMigration
|
||||
titleRes = R.string.skip_pre_migration
|
||||
summaryRes = R.string.use_last_saved_migration_preferences
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
preference {
|
||||
titleRes = R.string.match_pinned_sources
|
||||
summaryRes = R.string.only_enable_pinned_for_migration
|
||||
onClick {
|
||||
val ogSources = preferences.migrationSources().get()
|
||||
val pinnedSources =
|
||||
(preferences.pinnedCatalogues().get() ?: emptySet()).joinToString("/")
|
||||
preferences.migrationSources().set(pinnedSources)
|
||||
(activity as? MainActivity)?.setUndoSnackBar(view?.snack(
|
||||
R.string.migration_sources_set
|
||||
) {
|
||||
setAction(R.string.undo) {
|
||||
preferences.migrationSources().set(ogSources)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
preference {
|
||||
titleRes = R.string.match_enabled_sources
|
||||
summaryRes = R.string.only_enable_enabled_for_migration
|
||||
onClick {
|
||||
val ogSources = preferences.migrationSources().get()
|
||||
val languages = preferences.enabledLanguages().getOrDefault()
|
||||
val hiddenCatalogues = preferences.hiddenSources().getOrDefault()
|
||||
val enabledSources =
|
||||
sourceManager.getCatalogueSources().filter { it.lang in languages }
|
||||
.filterNot { it.id.toString() in hiddenCatalogues }
|
||||
.sortedBy { "(${it.lang}) ${it.name}" }
|
||||
.joinToString("/") { it.id.toString() }
|
||||
preferences.migrationSources().set(enabledSources)
|
||||
(activity as? MainActivity)?.setUndoSnackBar(view?.snack(R.string.migration_sources_set) {
|
||||
setAction(R.string.undo) {
|
||||
preferences.migrationSources().set(ogSources)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.ic_info_outline_24dp
|
||||
iconTint = activity?.getResourceColor(android.R.attr.textColorSecondary) ?: 0
|
||||
summaryRes = R.string.you_can_migrate_in_library
|
||||
isEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@ -161,18 +160,5 @@ class SettingsLibraryController : SettingsController() {
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
if (preferences.skipPreMigration().getOrDefault() || preferences.migrationSources().getOrDefault().isNotEmpty()) {
|
||||
preferenceCategory {
|
||||
titleRes = R.string.migration
|
||||
// Only show this if someone has mass migrated manga once
|
||||
|
||||
switchPreference {
|
||||
key = Keys.skipPreMigration
|
||||
titleRes = R.string.skip_pre_migration
|
||||
summaryRes = R.string.use_last_saved_migration_preferences
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import androidx.preference.PreferenceScreen
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
@ -48,10 +47,10 @@ class SettingsMainController : SettingsController() {
|
||||
onClick { navigateTo(SettingsDownloadController()) }
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.ic_swap_calls_white_24dp
|
||||
iconRes = R.drawable.ic_browse_24dp
|
||||
iconTint = tintColor
|
||||
titleRes = R.string.source_migration
|
||||
onClick { navigateTo(MigrationController()) }
|
||||
titleRes = R.string.sources
|
||||
onClick { navigateTo(SettingsBrowseController()) }
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.ic_sync_black_24dp
|
||||
|
@ -104,11 +104,16 @@ open class GlobalSearchPresenter(
|
||||
val hiddenCatalogues = preferencesHelper.hiddenSources().getOrDefault()
|
||||
val pinnedCatalogues = preferencesHelper.pinnedCatalogues().getOrDefault()
|
||||
|
||||
return sourceManager.getCatalogueSources()
|
||||
val list = sourceManager.getCatalogueSources()
|
||||
.filter { it.lang in languages }
|
||||
.filterNot { it.id.toString() in hiddenCatalogues }
|
||||
.sortedBy { "(${it.lang}) ${it.name}" }
|
||||
.sortedBy { it.id.toString() !in pinnedCatalogues }
|
||||
|
||||
return if (preferencesHelper.onlySearchPinned().get()) {
|
||||
list.filter { it.id.toString() in pinnedCatalogues }
|
||||
} else {
|
||||
list.sortedBy { it.id.toString() !in pinnedCatalogues }
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSourcesToQuery(): List<CatalogueSource> {
|
||||
|
9
app/src/main/res/drawable/ic_info_outline_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_info_outline_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" />
|
||||
</vector>
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/auto_checkbox"
|
||||
android:layout_marginStart="8dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/notify_extension_updates">
|
||||
|
||||
</com.google.android.material.checkbox.MaterialCheckBox>
|
@ -12,12 +12,4 @@
|
||||
android:title="@string/search"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="collapseActionView|ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_auto_check"
|
||||
android:title="@string/notify_extension_updates"
|
||||
android:icon="@drawable/ic_sync_black_24dp"
|
||||
android:visible="false"
|
||||
android:checkable="true"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
|
@ -181,8 +181,6 @@
|
||||
<string name="sort_by_ignoring_articles">Sort by ignoring articles</string>
|
||||
<string name="when_sorting_ignore_articles">When sorting alphabetically, sort ignoring
|
||||
articles (a, an, the) at the start of manga titles</string>
|
||||
<string name="use_last_saved_migration_preferences">Use last saved pre-migration preferences
|
||||
and sources to mass migrate</string>
|
||||
<string name="categories_to_include_in_global_update">Categories to include in global update</string>
|
||||
<string name="include_in_global_update">Include in global update</string>
|
||||
<string name="auto_refresh_covers">Automatically refresh covers</string>
|
||||
@ -241,7 +239,6 @@
|
||||
<!-- Extensions -->
|
||||
<string name="extensions">Extensions</string>
|
||||
<string name="extension_updates">Extension Updates</string>
|
||||
<string name="notify_extension_updates">Notify when extension updates are available</string>
|
||||
<string name="extension_info">Extension info</string>
|
||||
<string name="details">Details</string>
|
||||
<string name="obsolete">Obsolete</string>
|
||||
@ -547,6 +544,22 @@
|
||||
<string name="delete_old_covers_in_library_used_">Delete old and unused cached covers of
|
||||
manga in your library that has been updated.\nCurrently using: %1$s</string>
|
||||
|
||||
<!-- Browse Settings -->
|
||||
<string name="pref_global_search">Global search</string>
|
||||
<string name="check_for_extension_updates">Check for extension updates</string>
|
||||
<string name="only_search_pinned_when">Only search pinned sources</string>
|
||||
<string name="match_pinned_sources">Match pinned sources</string>
|
||||
<string name="match_enabled_sources">Match enabled sources</string>
|
||||
<string name="only_enable_pinned_for_migration">Only enable your pinned sources for
|
||||
migration</string>
|
||||
<string name="only_enable_enabled_for_migration">Only enable your currently enabled sources for
|
||||
migration</string>
|
||||
<string name="use_last_saved_migration_preferences">Use last saved pre-migration preferences
|
||||
and sources to mass migrate</string>
|
||||
<string name="migration_sources_set">Migration sources set</string>
|
||||
<string name="you_can_migrate_in_library">You can also migrate by selecting manga in your
|
||||
library</string>
|
||||
|
||||
<!-- About section -->
|
||||
<string name="version">Version</string>
|
||||
<string name="build_time">Build time</string>
|
||||
|
Loading…
Reference in New Issue
Block a user