From f4ff991e1d3f0da665e37f1fcb331924453d1523 Mon Sep 17 00:00:00 2001 From: ca1e Date: Sat, 7 Dec 2019 14:44:06 +0800 Subject: [PATCH] commit clean caches --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 3 +++ .../java/io/legado/app/ui/config/ConfigFragment.kt | 10 ++++++++-- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config.xml | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 24ac981e9..446efc0bf 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -10,4 +10,7 @@ object PreferKey { const val nextKey = "nextKeyCode" const val showRss = "showRss" const val bookshelfLayout = "bookshelfLayout" + const val recordLog = "recordLog" + const val processText = "process_text" + const val cleanCache = "cleanCache" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt index cee764420..a4a7bd62d 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt @@ -12,6 +12,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.constant.PreferKey import io.legado.app.help.BookHelp +import io.legado.app.help.FileHelp import io.legado.app.lib.theme.ATH import io.legado.app.receiver.SharedReceiverActivity import io.legado.app.ui.filechooser.FileChooserDialog @@ -59,6 +60,11 @@ class ConfigFragment : PreferenceFragmentCompat(), mode = FileChooserDialog.DIRECTORY, initPath = getPreferenceString(PreferKey.downloadPath) ) + PreferKey.cleanCache -> { + LogUtils.d("xxx","cleancaches") + FileHelp.deleteFile(getPreferenceString(PreferKey.downloadPath)) + toast("成功清理缓存") + } } return super.onPreferenceTreeClick(preference) } @@ -69,8 +75,8 @@ class ConfigFragment : PreferenceFragmentCompat(), BookHelp.upDownloadPath() findPreference(key)?.summary = getPreferenceString(key) } - "recordLog" -> LogUtils.upLevel() - "process_text" -> sharedPreferences?.let { + PreferKey.recordLog -> LogUtils.upLevel() + PreferKey.processText -> sharedPreferences?.let { setProcessTextEnable(it.getBoolean("process_text", true)) } PreferKey.showRss -> postEvent(PreferKey.showRss, PreferKey.showRss) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9e6327377..f4786808e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -313,6 +313,7 @@ 替换范围,选填书名或者源名 分组 内容缓存路径 + 清理缓存 系统文件选择器 新版本 下载更新 diff --git a/app/src/main/res/xml/pref_config.xml b/app/src/main/res/xml/pref_config.xml index 3e9a873b6..bc421509b 100644 --- a/app/src/main/res/xml/pref_config.xml +++ b/app/src/main/res/xml/pref_config.xml @@ -39,4 +39,8 @@ android:key="recordLog" android:title="记录日志" app:iconSpaceReserved="false" /> + \ No newline at end of file