mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:15:14 +01:00
Categorize library settings
This commit is contained in:
parent
e9e9e10805
commit
b92c6cfdab
@ -1,6 +1,5 @@
|
||||
package eu.kanade.tachiyomi.data.library
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.app.Notification
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
|
@ -26,150 +26,167 @@ class SettingsLibraryController : SettingsController() {
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
titleRes = R.string.pref_category_library
|
||||
|
||||
preference {
|
||||
titleRes = R.string.pref_library_columns
|
||||
onClick {
|
||||
LibraryColumnsDialog().showDialog(router)
|
||||
}
|
||||
|
||||
fun getColumnValue(value: Int): String {
|
||||
return if (value == 0)
|
||||
context.getString(R.string.default_columns)
|
||||
else
|
||||
value.toString()
|
||||
}
|
||||
|
||||
Observable.combineLatest(
|
||||
preferences.portraitColumns().asObservable(),
|
||||
preferences.landscapeColumns().asObservable(),
|
||||
{ portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) })
|
||||
.subscribeUntilDestroy { (portraitCols, landscapeCols) ->
|
||||
val portrait = getColumnValue(portraitCols)
|
||||
val landscape = getColumnValue(landscapeCols)
|
||||
summary = "${context.getString(R.string.portrait)}: $portrait, " +
|
||||
"${context.getString(R.string.landscape)}: $landscape"
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_library_display
|
||||
preference {
|
||||
titleRes = R.string.pref_library_columns
|
||||
onClick {
|
||||
LibraryColumnsDialog().showDialog(router)
|
||||
}
|
||||
}
|
||||
intListPreference(activity) {
|
||||
key = Keys.libraryUpdateInterval
|
||||
titleRes = R.string.pref_library_update_interval
|
||||
entriesRes = arrayOf(R.string.update_never, 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)
|
||||
defaultValue = 0
|
||||
|
||||
onChange { newValue ->
|
||||
// Always cancel the previous task, it seems that sometimes they are not updated.
|
||||
LibraryUpdateJob.cancelTask()
|
||||
|
||||
val interval = newValue as Int
|
||||
if (interval > 0) {
|
||||
LibraryUpdateJob.setupTask(interval)
|
||||
fun getColumnValue(value: Int): String {
|
||||
return if (value == 0) context.getString(R.string.default_columns)
|
||||
else value.toString()
|
||||
}
|
||||
true
|
||||
|
||||
Observable.combineLatest(preferences.portraitColumns().asObservable(),
|
||||
preferences.landscapeColumns().asObservable(),
|
||||
{ portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) })
|
||||
.subscribeUntilDestroy { (portraitCols, landscapeCols) ->
|
||||
val portrait = getColumnValue(portraitCols)
|
||||
val landscape = getColumnValue(landscapeCols)
|
||||
summary =
|
||||
"${context.getString(R.string.portrait)}: $portrait, " + "${context.getString(
|
||||
R.string.landscape
|
||||
)}: $landscape"
|
||||
}
|
||||
}
|
||||
}
|
||||
multiSelectListPreferenceMat(activity) {
|
||||
key = Keys.libraryUpdateRestriction
|
||||
titleRes = R.string.pref_library_update_restriction
|
||||
entriesRes = arrayOf(R.string.wifi, R.string.charging)
|
||||
entryValues = listOf("wifi", "ac")
|
||||
customSummaryRes = R.string.pref_library_update_restriction_summary
|
||||
|
||||
preferences.libraryUpdateInterval().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it > 0 }
|
||||
|
||||
onChange {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
Handler().post { LibraryUpdateJob.setupTask() }
|
||||
true
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.updateOnlyNonCompleted
|
||||
titleRes = R.string.pref_update_only_non_completed
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
val dbCategories = db.getCategories().executeAsBlocking()
|
||||
|
||||
multiSelectListPreferenceMat(activity) {
|
||||
key = Keys.libraryUpdateCategories
|
||||
titleRes = R.string.pref_library_update_categories
|
||||
entries = dbCategories.map { it.name }
|
||||
entryValues = dbCategories.map { it.id.toString() }
|
||||
allSelectionRes = R.string.all
|
||||
|
||||
preferences.libraryUpdateCategories().asObservable()
|
||||
.subscribeUntilDestroy {
|
||||
val selectedCategories = it
|
||||
.mapNotNull { id -> dbCategories.find { it.id == id.toInt() } }
|
||||
.sortedBy { it.order }
|
||||
|
||||
customSummary = if (selectedCategories.isEmpty())
|
||||
context.getString(R.string.all)
|
||||
else
|
||||
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
|
||||
}
|
||||
intListPreference(activity) {
|
||||
key = Keys.defaultCategory
|
||||
titleRes = R.string.default_category
|
||||
|
||||
val categories = listOf(Category.createDefault(context)) + dbCategories
|
||||
entries = listOf(context.getString(R.string.default_category_summary)) +
|
||||
categories.map { it.name }.toTypedArray()
|
||||
entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList()
|
||||
defaultValue = "-1"
|
||||
|
||||
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
|
||||
summary = selectedCategory?.name ?: context.getString(R.string.default_category_summary)
|
||||
onChange { newValue ->
|
||||
summary = categories.find {
|
||||
it.id == newValue as Int
|
||||
}?.name ?: context.getString(R.string.default_category_summary)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
// Only show this if someone has mass migrated manga once
|
||||
if (preferences.skipPreMigration().getOrDefault() || preferences.migrationSources()
|
||||
.getOrDefault().isNotEmpty()) {
|
||||
switchPreference {
|
||||
key = Keys.skipPreMigration
|
||||
titleRes = R.string.pref_skip_pre_migration
|
||||
summaryRes = R.string.pref_skip_pre_migration_summary
|
||||
key = Keys.removeArticles
|
||||
titleRes = R.string.pref_remove_articles
|
||||
summaryRes = R.string.pref_remove_articles_summary
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
key = Keys.libraryUpdateInterval
|
||||
titleRes = R.string.pref_library_update_interval
|
||||
entriesRes = arrayOf(
|
||||
R.string.update_never,
|
||||
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)
|
||||
defaultValue = 0
|
||||
|
||||
onChange { newValue ->
|
||||
// Always cancel the previous task, it seems that sometimes they are not updated.
|
||||
LibraryUpdateJob.cancelTask()
|
||||
|
||||
val interval = newValue as Int
|
||||
if (interval > 0) {
|
||||
LibraryUpdateJob.setupTask(interval)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
multiSelectListPreferenceMat(activity) {
|
||||
key = Keys.libraryUpdateRestriction
|
||||
titleRes = R.string.pref_library_update_restriction
|
||||
entriesRes = arrayOf(R.string.wifi, R.string.charging)
|
||||
entryValues = listOf("wifi", "ac")
|
||||
customSummaryRes = R.string.pref_library_update_restriction_summary
|
||||
|
||||
preferences.libraryUpdateInterval().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it > 0 }
|
||||
|
||||
onChange {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
Handler().post { LibraryUpdateJob.setupTask() }
|
||||
true
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.updateOnlyNonCompleted
|
||||
titleRes = R.string.pref_update_only_non_completed
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
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) {
|
||||
key = Keys.libraryUpdateCategories
|
||||
titleRes = R.string.pref_library_update_categories
|
||||
entries = dbCategories.map { it.name }
|
||||
entryValues = dbCategories.map { it.id.toString() }
|
||||
allSelectionRes = R.string.all
|
||||
|
||||
preferences.libraryUpdateCategories().asObservable().subscribeUntilDestroy {
|
||||
val selectedCategories =
|
||||
it.mapNotNull { id -> dbCategories.find { it.id == id.toInt() } }
|
||||
.sortedBy { it.order }
|
||||
|
||||
customSummary =
|
||||
if (selectedCategories.isEmpty()) context.getString(R.string.all)
|
||||
else selectedCategories.joinToString { it.name }
|
||||
}
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.refreshCoversToo
|
||||
titleRes = R.string.pref_refresh_covers_too
|
||||
summaryRes = R.string.pref_refresh_covers_too_summary
|
||||
defaultValue = true
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_library_categories
|
||||
intListPreference(activity) {
|
||||
key = Keys.defaultCategory
|
||||
titleRes = R.string.default_category
|
||||
|
||||
val categories = listOf(Category.createDefault(context)) + dbCategories
|
||||
entries =
|
||||
listOf(context.getString(R.string.default_category_summary)) + categories.map { it.name }.toTypedArray()
|
||||
entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList()
|
||||
defaultValue = "-1"
|
||||
|
||||
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
|
||||
summary =
|
||||
selectedCategory?.name ?: context.getString(R.string.default_category_summary)
|
||||
onChange { newValue ->
|
||||
summary = categories.find {
|
||||
it.id == newValue as Int
|
||||
}?.name ?: context.getString(R.string.default_category_summary)
|
||||
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
|
||||
|
||||
switchPreference {
|
||||
key = Keys.skipPreMigration
|
||||
titleRes = R.string.pref_skip_pre_migration
|
||||
summaryRes = R.string.pref_skip_pre_migration_summary
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,12 +134,16 @@
|
||||
<string name="pref_start_screen">Start screen</string>
|
||||
<string name="pref_language">Language</string>
|
||||
<string name="system_default">System default</string>
|
||||
<string name="pref_date_format">Date format</string>
|
||||
|
||||
<!-- Library section -->
|
||||
<string name="pref_category_library_display">Display</string>
|
||||
<string name="pref_library_columns">Library manga per row</string>
|
||||
<string name="portrait">Portrait</string>
|
||||
<string name="landscape">Landscape</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="update_never">Manual</string>
|
||||
<string name="update_1hour">Hourly</string>
|
||||
@ -150,8 +154,7 @@
|
||||
<string name="update_24hour">Daily</string>
|
||||
<string name="update_48hour">Every 2 days</string>
|
||||
<string name="update_weekly">Weekly</string>
|
||||
<string name="pref_library_update_categories">Categories to include in global update</string>
|
||||
<string name="all">All</string>
|
||||
<string name="update_monthly">Monthly</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_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_summary">Use last saved pre-migration preferences
|
||||
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_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_when_idle">Lock when idle</string>
|
||||
<string name="lock_always">Always</string>
|
||||
@ -181,6 +187,9 @@
|
||||
<string name="pref_refresh_covers_too_summary">Refresh covers in library as well
|
||||
when updating library (overwrites local covers)</string>
|
||||
|
||||
<string name="pref_category_library_migration">Migration</string>
|
||||
|
||||
|
||||
<!-- Extension section -->
|
||||
<string name="all_lang">All</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_theme">Smart (based on page and theme)</string>
|
||||
|
||||
|
||||
<!-- Downloads section -->
|
||||
<string name="pref_download_directory">Download location</string>
|
||||
<string name="pref_download_only_over_wifi">Only download over Wi-Fi</string>
|
||||
|
Loading…
Reference in New Issue
Block a user