Sectioning Advanced section

This commit is contained in:
Jay 2020-08-09 20:18:45 -04:00
parent 696ffff401
commit 7a87714c88
2 changed files with 94 additions and 78 deletions

View File

@ -58,6 +58,8 @@ class SettingsAdvancedController : SettingsController() {
summaryRes = R.string.helps_fix_bugs summaryRes = R.string.helps_fix_bugs
defaultValue = true defaultValue = true
} }
preferenceCategory {
titleRes = R.string.data_management
preference { preference {
key = CLEAR_CACHE_KEY key = CLEAR_CACHE_KEY
titleRes = R.string.clear_chapter_cache titleRes = R.string.clear_chapter_cache
@ -68,7 +70,10 @@ class SettingsAdvancedController : SettingsController() {
preference { preference {
titleRes = R.string.clean_up_cached_covers titleRes = R.string.clean_up_cached_covers
summary = context.getString(R.string.delete_old_covers_in_library_used_, coverCache.getChapterCacheSize()) summary = context.getString(
R.string.delete_old_covers_in_library_used_,
coverCache.getChapterCacheSize()
)
onClick { onClick {
context.toast(R.string.starting_cleanup) context.toast(R.string.starting_cleanup)
@ -77,21 +82,16 @@ class SettingsAdvancedController : SettingsController() {
} }
preference { preference {
titleRes = R.string.clean_up_cached_covers_non_library titleRes = R.string.clean_up_cached_covers_non_library
summary = context.getString(R.string.delete_all_covers__not_in_library_used_, coverCache.getOnlineCoverCacheSize()) summary = context.getString(
R.string.delete_all_covers__not_in_library_used_,
coverCache.getOnlineCoverCacheSize()
)
onClick { onClick {
context.toast(R.string.starting_cleanup) context.toast(R.string.starting_cleanup)
coverCache.deleteAllCachedCovers() coverCache.deleteAllCachedCovers()
} }
} }
preference {
titleRes = R.string.clear_cookies
onClick {
network.cookieManager.removeAll()
activity?.toast(R.string.cookies_cleared)
}
}
preference { preference {
titleRes = R.string.clear_database titleRes = R.string.clear_database
summaryRes = R.string.clear_database_summary summaryRes = R.string.clear_database_summary
@ -102,6 +102,20 @@ class SettingsAdvancedController : SettingsController() {
ctrl.showDialog(router) ctrl.showDialog(router)
} }
} }
preference {
titleRes = R.string.clean_up_downloaded_chapters
summaryRes = R.string.delete_unused_chapters
onClick {
val ctrl = CleanupDownloadsDialogController()
ctrl.targetController = this@SettingsAdvancedController
ctrl.showDialog(router)
}
}
}
preferenceCategory {
titleRes = R.string.library
preference { preference {
titleRes = R.string.refresh_library_metadata titleRes = R.string.refresh_library_metadata
summaryRes = R.string.updates_covers_genres_desc summaryRes = R.string.updates_covers_genres_desc
@ -114,15 +128,15 @@ class SettingsAdvancedController : SettingsController() {
onClick { LibraryUpdateService.start(context, target = Target.TRACKING) } onClick { LibraryUpdateService.start(context, target = Target.TRACKING) }
} }
preference { }
titleRes = R.string.clean_up_downloaded_chapters
summaryRes = R.string.delete_unused_chapters preferenceCategory {
preference {
titleRes = R.string.clear_cookies
onClick { onClick {
val ctrl = CleanupDownloadsDialogController() network.cookieManager.removeAll()
ctrl.targetController = this@SettingsAdvancedController activity?.toast(R.string.cookies_cleared)
ctrl.showDialog(router)
} }
} }
@ -147,6 +161,7 @@ class SettingsAdvancedController : SettingsController() {
} }
} }
} }
}
class CleanupDownloadsDialogController() : DialogController() { class CleanupDownloadsDialogController() : DialogController() {
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {

View File

@ -527,6 +527,7 @@
<!-- Advanced section --> <!-- Advanced section -->
<string name="clear_chapter_cache">Clear chapter cache</string> <string name="clear_chapter_cache">Clear chapter cache</string>
<string name="data_management">Data Management</string>
<string name="used_">Used: %1$s</string> <string name="used_">Used: %1$s</string>
<plurals name="cache_cleared"> <plurals name="cache_cleared">
<item quantity="one">Cache cleared. %d file has been deleted</item> <item quantity="one">Cache cleared. %d file has been deleted</item>