Categorize library settings
This commit is contained in:
parent
e9e9e10805
commit
b92c6cfdab
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.library
|
package eu.kanade.tachiyomi.data.library
|
||||||
|
|
||||||
import android.app.ActivityManager
|
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
|
@ -26,7 +26,8 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||||
titleRes = R.string.pref_category_library
|
titleRes = R.string.pref_category_library
|
||||||
|
preferenceCategory {
|
||||||
|
titleRes = R.string.pref_category_library_display
|
||||||
preference {
|
preference {
|
||||||
titleRes = R.string.pref_library_columns
|
titleRes = R.string.pref_library_columns
|
||||||
onClick {
|
onClick {
|
||||||
@ -34,29 +35,48 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getColumnValue(value: Int): String {
|
fun getColumnValue(value: Int): String {
|
||||||
return if (value == 0)
|
return if (value == 0) context.getString(R.string.default_columns)
|
||||||
context.getString(R.string.default_columns)
|
else value.toString()
|
||||||
else
|
|
||||||
value.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Observable.combineLatest(
|
Observable.combineLatest(preferences.portraitColumns().asObservable(),
|
||||||
preferences.portraitColumns().asObservable(),
|
|
||||||
preferences.landscapeColumns().asObservable(),
|
preferences.landscapeColumns().asObservable(),
|
||||||
{ portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) })
|
{ portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) })
|
||||||
.subscribeUntilDestroy { (portraitCols, landscapeCols) ->
|
.subscribeUntilDestroy { (portraitCols, landscapeCols) ->
|
||||||
val portrait = getColumnValue(portraitCols)
|
val portrait = getColumnValue(portraitCols)
|
||||||
val landscape = getColumnValue(landscapeCols)
|
val landscape = getColumnValue(landscapeCols)
|
||||||
summary = "${context.getString(R.string.portrait)}: $portrait, " +
|
summary =
|
||||||
"${context.getString(R.string.landscape)}: $landscape"
|
"${context.getString(R.string.portrait)}: $portrait, " + "${context.getString(
|
||||||
|
R.string.landscape
|
||||||
|
)}: $landscape"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.removeArticles
|
||||||
|
titleRes = R.string.pref_remove_articles
|
||||||
|
summaryRes = R.string.pref_remove_articles_summary
|
||||||
|
defaultValue = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val dbCategories = db.getCategories().executeAsBlocking()
|
||||||
|
|
||||||
|
preferenceCategory {
|
||||||
|
titleRes = R.string.pref_category_library_update
|
||||||
intListPreference(activity) {
|
intListPreference(activity) {
|
||||||
key = Keys.libraryUpdateInterval
|
key = Keys.libraryUpdateInterval
|
||||||
titleRes = R.string.pref_library_update_interval
|
titleRes = R.string.pref_library_update_interval
|
||||||
entriesRes = arrayOf(R.string.update_never, R.string.update_1hour,
|
entriesRes = arrayOf(
|
||||||
R.string.update_2hour, R.string.update_3hour, R.string.update_6hour,
|
R.string.update_never,
|
||||||
R.string.update_12hour, R.string.update_24hour, R.string.update_48hour)
|
R.string.update_1hour,
|
||||||
|
R.string.update_2hour,
|
||||||
|
R.string.update_3hour,
|
||||||
|
R.string.update_6hour,
|
||||||
|
R.string.update_12hour,
|
||||||
|
R.string.update_24hour,
|
||||||
|
R.string.update_48hour
|
||||||
|
)
|
||||||
entryValues = listOf(0, 1, 2, 3, 6, 12, 24, 48)
|
entryValues = listOf(0, 1, 2, 3, 6, 12, 24, 48)
|
||||||
defaultValue = 0
|
defaultValue = 0
|
||||||
|
|
||||||
@ -93,7 +113,26 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
|
|
||||||
val dbCategories = db.getCategories().executeAsBlocking()
|
intListPreference(activity) {
|
||||||
|
key = Keys.libraryUpdatePrioritization
|
||||||
|
titleRes = R.string.pref_library_update_prioritization
|
||||||
|
|
||||||
|
// The following array lines up with the list rankingScheme in:
|
||||||
|
// ../../data/library/LibraryUpdateRanker.kt
|
||||||
|
entriesRes = arrayOf(
|
||||||
|
R.string.action_sort_alpha, R.string.action_sort_last_updated
|
||||||
|
)
|
||||||
|
entryRange = 0..1
|
||||||
|
defaultValue = 0
|
||||||
|
summaryRes = R.string.pref_library_update_prioritization_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.refreshCoversToo
|
||||||
|
titleRes = R.string.pref_refresh_covers_too
|
||||||
|
summaryRes = R.string.pref_refresh_covers_too_summary
|
||||||
|
defaultValue = true
|
||||||
|
}
|
||||||
|
|
||||||
multiSelectListPreferenceMat(activity) {
|
multiSelectListPreferenceMat(activity) {
|
||||||
key = Keys.libraryUpdateCategories
|
key = Keys.libraryUpdateCategories
|
||||||
@ -102,44 +141,32 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
entryValues = dbCategories.map { it.id.toString() }
|
entryValues = dbCategories.map { it.id.toString() }
|
||||||
allSelectionRes = R.string.all
|
allSelectionRes = R.string.all
|
||||||
|
|
||||||
preferences.libraryUpdateCategories().asObservable()
|
preferences.libraryUpdateCategories().asObservable().subscribeUntilDestroy {
|
||||||
.subscribeUntilDestroy {
|
val selectedCategories =
|
||||||
val selectedCategories = it
|
it.mapNotNull { id -> dbCategories.find { it.id == id.toInt() } }
|
||||||
.mapNotNull { id -> dbCategories.find { it.id == id.toInt() } }
|
|
||||||
.sortedBy { it.order }
|
.sortedBy { it.order }
|
||||||
|
|
||||||
customSummary = if (selectedCategories.isEmpty())
|
customSummary =
|
||||||
context.getString(R.string.all)
|
if (selectedCategories.isEmpty()) context.getString(R.string.all)
|
||||||
else
|
else selectedCategories.joinToString { it.name }
|
||||||
selectedCategories.joinToString { it.name }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intListPreference(activity) {
|
|
||||||
key = Keys.libraryUpdatePrioritization
|
|
||||||
titleRes = R.string.pref_library_update_prioritization
|
|
||||||
|
|
||||||
// The following array lines up with the list rankingScheme in:
|
|
||||||
// ../../data/library/LibraryUpdateRanker.kt
|
|
||||||
entriesRes = arrayOf(
|
|
||||||
R.string.action_sort_alpha,
|
|
||||||
R.string.action_sort_last_updated
|
|
||||||
)
|
|
||||||
entryRange = 0..1
|
|
||||||
defaultValue = 0
|
|
||||||
summaryRes = R.string.pref_library_update_prioritization_summary
|
|
||||||
}
|
}
|
||||||
|
preferenceCategory {
|
||||||
|
titleRes = R.string.pref_category_library_categories
|
||||||
intListPreference(activity) {
|
intListPreference(activity) {
|
||||||
key = Keys.defaultCategory
|
key = Keys.defaultCategory
|
||||||
titleRes = R.string.default_category
|
titleRes = R.string.default_category
|
||||||
|
|
||||||
val categories = listOf(Category.createDefault(context)) + dbCategories
|
val categories = listOf(Category.createDefault(context)) + dbCategories
|
||||||
entries = listOf(context.getString(R.string.default_category_summary)) +
|
entries =
|
||||||
categories.map { it.name }.toTypedArray()
|
listOf(context.getString(R.string.default_category_summary)) + categories.map { it.name }.toTypedArray()
|
||||||
entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList()
|
entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList()
|
||||||
defaultValue = "-1"
|
defaultValue = "-1"
|
||||||
|
|
||||||
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
|
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
|
||||||
summary = selectedCategory?.name ?: context.getString(R.string.default_category_summary)
|
summary =
|
||||||
|
selectedCategory?.name ?: context.getString(R.string.default_category_summary)
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
summary = categories.find {
|
summary = categories.find {
|
||||||
it.id == newValue as Int
|
it.id == newValue as Int
|
||||||
@ -147,10 +174,12 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (preferences.skipPreMigration().getOrDefault() || preferences.migrationSources().getOrDefault().isNotEmpty()) {
|
||||||
|
preferenceCategory {
|
||||||
|
titleRes = R.string.pref_category_library_migration
|
||||||
// Only show this if someone has mass migrated manga once
|
// Only show this if someone has mass migrated manga once
|
||||||
if (preferences.skipPreMigration().getOrDefault() || preferences.migrationSources()
|
|
||||||
.getOrDefault().isNotEmpty()) {
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.skipPreMigration
|
key = Keys.skipPreMigration
|
||||||
titleRes = R.string.pref_skip_pre_migration
|
titleRes = R.string.pref_skip_pre_migration
|
||||||
@ -158,18 +187,6 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
|
||||||
key = Keys.removeArticles
|
|
||||||
titleRes = R.string.pref_remove_articles
|
|
||||||
summaryRes = R.string.pref_remove_articles_summary
|
|
||||||
defaultValue = false
|
|
||||||
}
|
|
||||||
switchPreference {
|
|
||||||
key = Keys.refreshCoversToo
|
|
||||||
titleRes = R.string.pref_refresh_covers_too
|
|
||||||
summaryRes = R.string.pref_refresh_covers_too_summary
|
|
||||||
defaultValue = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,12 +134,16 @@
|
|||||||
<string name="pref_start_screen">Start screen</string>
|
<string name="pref_start_screen">Start screen</string>
|
||||||
<string name="pref_language">Language</string>
|
<string name="pref_language">Language</string>
|
||||||
<string name="system_default">System default</string>
|
<string name="system_default">System default</string>
|
||||||
|
<string name="pref_date_format">Date format</string>
|
||||||
|
|
||||||
<!-- Library section -->
|
<!-- Library section -->
|
||||||
|
<string name="pref_category_library_display">Display</string>
|
||||||
<string name="pref_library_columns">Library manga per row</string>
|
<string name="pref_library_columns">Library manga per row</string>
|
||||||
<string name="portrait">Portrait</string>
|
<string name="portrait">Portrait</string>
|
||||||
<string name="landscape">Landscape</string>
|
<string name="landscape">Landscape</string>
|
||||||
<string name="default_columns">Default</string>
|
<string name="default_columns">Default</string>
|
||||||
|
|
||||||
|
<string name="pref_category_library_update">Updates</string>
|
||||||
<string name="pref_library_update_interval">Library update frequency</string>
|
<string name="pref_library_update_interval">Library update frequency</string>
|
||||||
<string name="update_never">Manual</string>
|
<string name="update_never">Manual</string>
|
||||||
<string name="update_1hour">Hourly</string>
|
<string name="update_1hour">Hourly</string>
|
||||||
@ -150,8 +154,7 @@
|
|||||||
<string name="update_24hour">Daily</string>
|
<string name="update_24hour">Daily</string>
|
||||||
<string name="update_48hour">Every 2 days</string>
|
<string name="update_48hour">Every 2 days</string>
|
||||||
<string name="update_weekly">Weekly</string>
|
<string name="update_weekly">Weekly</string>
|
||||||
<string name="pref_library_update_categories">Categories to include in global update</string>
|
<string name="update_monthly">Monthly</string>
|
||||||
<string name="all">All</string>
|
|
||||||
<string name="pref_library_update_prioritization">Library update order</string>
|
<string name="pref_library_update_prioritization">Library update order</string>
|
||||||
<string name="pref_library_update_prioritization_summary">Select the order in which Tachiyomi checks for update</string>
|
<string name="pref_library_update_prioritization_summary">Select the order in which Tachiyomi checks for update</string>
|
||||||
<string name="pref_library_update_restriction">Library update restrictions</string>
|
<string name="pref_library_update_restriction">Library update restrictions</string>
|
||||||
@ -166,8 +169,11 @@
|
|||||||
<string name="pref_skip_pre_migration">Skip pre-migration</string>
|
<string name="pref_skip_pre_migration">Skip pre-migration</string>
|
||||||
<string name="pref_skip_pre_migration_summary">Use last saved pre-migration preferences
|
<string name="pref_skip_pre_migration_summary">Use last saved pre-migration preferences
|
||||||
and sources to mass migrate</string>
|
and sources to mass migrate</string>
|
||||||
|
<string name="pref_category_library_categories">Categories</string>
|
||||||
<string name="default_category">Default category</string>
|
<string name="default_category">Default category</string>
|
||||||
<string name="default_category_summary">Always ask</string>
|
<string name="default_category_summary">Always ask</string>
|
||||||
|
<string name="pref_library_update_categories">Categories to include in global update</string>
|
||||||
|
<string name="all">All</string>
|
||||||
<string name="lock_with_biometrics">Lock with biometrics</string>
|
<string name="lock_with_biometrics">Lock with biometrics</string>
|
||||||
<string name="lock_when_idle">Lock when idle</string>
|
<string name="lock_when_idle">Lock when idle</string>
|
||||||
<string name="lock_always">Always</string>
|
<string name="lock_always">Always</string>
|
||||||
@ -181,6 +187,9 @@
|
|||||||
<string name="pref_refresh_covers_too_summary">Refresh covers in library as well
|
<string name="pref_refresh_covers_too_summary">Refresh covers in library as well
|
||||||
when updating library (overwrites local covers)</string>
|
when updating library (overwrites local covers)</string>
|
||||||
|
|
||||||
|
<string name="pref_category_library_migration">Migration</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Extension section -->
|
<!-- Extension section -->
|
||||||
<string name="all_lang">All</string>
|
<string name="all_lang">All</string>
|
||||||
<string name="ext_details">Details</string>
|
<string name="ext_details">Details</string>
|
||||||
@ -263,7 +272,6 @@
|
|||||||
<string name="reader_theme_smart">Smart (based on page)</string>
|
<string name="reader_theme_smart">Smart (based on page)</string>
|
||||||
<string name="reader_theme_smart_theme">Smart (based on page and theme)</string>
|
<string name="reader_theme_smart_theme">Smart (based on page and theme)</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Downloads section -->
|
<!-- Downloads section -->
|
||||||
<string name="pref_download_directory">Download location</string>
|
<string name="pref_download_directory">Download location</string>
|
||||||
<string name="pref_download_only_over_wifi">Only download over Wi-Fi</string>
|
<string name="pref_download_only_over_wifi">Only download over Wi-Fi</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user