From fa471e879986df23315c6308bd67a026b35398d7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 28 Aug 2020 15:32:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E7=BC=93=E5=AD=98=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/OtherConfigFragment.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index bf130b50e..c0efd5698 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -20,6 +20,9 @@ import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat +import io.legado.app.lib.dialogs.alert +import io.legado.app.lib.dialogs.noButton +import io.legado.app.lib.dialogs.okButton import io.legado.app.lib.dialogs.selector import io.legado.app.lib.theme.ATH import io.legado.app.receiver.SharedReceiverActivity @@ -79,11 +82,7 @@ class OtherConfigFragment : BasePreferenceFragment(), .show { putPrefInt(PreferKey.webPort, it) } - PreferKey.cleanCache -> { - BookHelp.clearCache() - FileUtils.deleteFile(requireActivity().cacheDir.absolutePath) - toast(R.string.clear_cache_success) - } + PreferKey.cleanCache -> clearCache() PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) { selectDefaultCover() } else { @@ -145,6 +144,18 @@ class OtherConfigFragment : BasePreferenceFragment(), } } + private fun clearCache() { + requireContext().alert(titleResource = R.string.clear_cache, + messageResource = R.string.sure_del) { + okButton { + BookHelp.clearCache() + FileUtils.deleteFile(requireActivity().cacheDir.absolutePath) + toast(R.string.clear_cache_success) + } + noButton() + }.show().applyTint() + } + private fun selectDefaultCover() { val intent = Intent(Intent.ACTION_GET_CONTENT) intent.addCategory(Intent.CATEGORY_OPENABLE)