Group advanced settings

This commit is contained in:
arkon 2020-05-23 10:46:07 -04:00
parent 259946cf0a
commit a2ece82197
2 changed files with 49 additions and 36 deletions

View File

@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.onClick
import eu.kanade.tachiyomi.util.preference.preference
import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
@ -51,42 +52,7 @@ class SettingsAdvancedController : SettingsController() {
summaryRes = R.string.pref_acra_summary
defaultValue = true
}
preference {
key = CLEAR_CACHE_KEY
titleRes = R.string.pref_clear_chapter_cache
summary = context.getString(R.string.used_cache, chapterCache.readableSize)
onClick { clearChapterCache() }
}
preference {
titleRes = R.string.pref_clear_cookies
onClick {
network.cookieManager.removeAll()
activity?.toast(R.string.cookies_cleared)
}
}
preference {
titleRes = R.string.pref_clear_database
summaryRes = R.string.pref_clear_database_summary
onClick {
val ctrl = ClearDatabaseDialogController()
ctrl.targetController = this@SettingsAdvancedController
ctrl.showDialog(router)
}
}
preference {
titleRes = R.string.pref_refresh_library_covers
onClick { LibraryUpdateService.start(context, target = Target.COVERS) }
}
preference {
titleRes = R.string.pref_refresh_library_tracking
summaryRes = R.string.pref_refresh_library_tracking_summary
onClick { LibraryUpdateService.start(context, target = Target.TRACKING) }
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
preference {
titleRes = R.string.pref_disable_battery_optimization
@ -110,6 +76,52 @@ class SettingsAdvancedController : SettingsController() {
}
}
}
preferenceCategory {
titleRes = R.string.label_data
preference {
key = CLEAR_CACHE_KEY
titleRes = R.string.pref_clear_chapter_cache
summary = context.getString(R.string.used_cache, chapterCache.readableSize)
onClick { clearChapterCache() }
}
preference {
titleRes = R.string.pref_clear_cookies
onClick {
network.cookieManager.removeAll()
activity?.toast(R.string.cookies_cleared)
}
}
preference {
titleRes = R.string.pref_clear_database
summaryRes = R.string.pref_clear_database_summary
onClick {
val ctrl = ClearDatabaseDialogController()
ctrl.targetController = this@SettingsAdvancedController
ctrl.showDialog(router)
}
}
}
preferenceCategory {
titleRes = R.string.label_library
preference {
titleRes = R.string.pref_refresh_library_covers
onClick { LibraryUpdateService.start(context, target = Target.COVERS) }
}
preference {
titleRes = R.string.pref_refresh_library_tracking
summaryRes = R.string.pref_refresh_library_tracking_summary
onClick { LibraryUpdateService.start(context, target = Target.TRACKING) }
}
}
}
private fun clearChapterCache() {

View File

@ -354,6 +354,7 @@
<string name="restoring_backup_canceled">Canceled restore</string>
<!-- Advanced section -->
<string name="label_data">Data</string>
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
<string name="used_cache">Used: %1$s</string>
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
@ -362,7 +363,7 @@
<string name="cookies_cleared">Cookies cleared</string>
<string name="choices_reset">Dialog choices reset</string>
<string name="pref_clear_database">Clear database</string>
<string name="pref_clear_database_summary">Delete manga and chapters that are not in your library</string>
<string name="pref_clear_database_summary">Delete history for manga that are not in saved your library</string>
<string name="clear_database_confirmation">Are you sure? Read chapters and progress of non-library manga will be lost</string>
<string name="clear_database_completed">Entries deleted</string>
<string name="pref_refresh_library_covers">Refresh library manga covers</string>