mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-09-10 20:43:14 +02:00
Setting to optionally sort by ignoring articles
This commit is contained in:
parent
64ca61dfcb
commit
c7dabb9d63
@ -125,6 +125,8 @@ object PreferenceKeys {
|
||||
|
||||
const val lastUnlock = "last_unlock"
|
||||
|
||||
const val removeArticles = "remove_articles"
|
||||
|
||||
@Deprecated("Use the preferences of the source")
|
||||
fun sourceUsername(sourceId: Long) = "pref_source_username_$sourceId"
|
||||
|
||||
|
@ -184,6 +184,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun lastUnlock() = rxPrefs.getLong(Keys.lastUnlock, 0)
|
||||
|
||||
fun removeArticles() = rxPrefs.getBoolean(Keys.removeArticles, false)
|
||||
|
||||
fun migrateFlags() = rxPrefs.getInteger("migrate_flags", Int.MAX_VALUE)
|
||||
|
||||
fun trustedSignatures() = rxPrefs.getStringSet("trusted_signatures", emptySet())
|
||||
|
@ -5,7 +5,6 @@ import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
@ -17,14 +16,14 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_EXCLUDE
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_INCLUDE
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
||||
import eu.kanade.tachiyomi.util.combineLatest
|
||||
import eu.kanade.tachiyomi.util.isNullOrUnsubscribed
|
||||
import eu.kanade.tachiyomi.util.syncChaptersWithSource
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_EXCLUDE
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_IGNORE
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_INCLUDE
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
@ -223,11 +222,13 @@ class LibraryPresenter(
|
||||
return map.mapValues { entry -> entry.value.sortedWith(comparator) }
|
||||
}
|
||||
|
||||
fun sortAlphabetical(i1: LibraryItem, i2: LibraryItem): Int {
|
||||
return i1.manga.title.removeArticles().compareTo(i2.manga.title.removeArticles(), true)
|
||||
private fun sortAlphabetical(i1: LibraryItem, i2: LibraryItem): Int {
|
||||
return if (preferences.removeArticles().getOrDefault())
|
||||
i1.manga.title.removeArticles().compareTo(i2.manga.title.removeArticles(), true)
|
||||
else i1.manga.title.compareTo(i2.manga.title, true)
|
||||
}
|
||||
|
||||
fun String.removeArticles(): String {
|
||||
private fun String.removeArticles(): String {
|
||||
return this.replace(Regex("^(an|a|the) ", RegexOption.IGNORE_CASE), "")
|
||||
}
|
||||
|
||||
|
@ -199,6 +199,14 @@ class SettingsGeneralController : SettingsController() {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.removeArticles
|
||||
titleRes = R.string.pref_remove_articles
|
||||
summaryRes = R.string.pref_remove_articles_summary
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
val biometricManager = BiometricManager.from(context)
|
||||
if (biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
var preference:IntListPreference? = null
|
||||
|
@ -150,6 +150,9 @@
|
||||
<string name="charging">Charging</string>
|
||||
<string name="pref_update_only_non_completed">Only update ongoing manga</string>
|
||||
<string name="pref_auto_update_manga_sync">Sync chapters after reading</string>
|
||||
<string name="pref_remove_articles">Sort by ignoring articles</string>
|
||||
<string name="pref_remove_articles_summary">When sorting alphabetically, sort ignoring
|
||||
articles (a, an, the) at the start of manga titles</string>
|
||||
<string name="pref_theme">Application theme</string>
|
||||
<string name="light_theme">Main theme</string>
|
||||
<string name="dark_theme">Dark theme</string>
|
||||
|
Loading…
Reference in New Issue
Block a user