From 560aedfb6e1cd7a6b215db9228d4f4f0ae1c0e3a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Jan 2021 10:31:22 +0100 Subject: [PATCH] allow clearing the app cache, related to #1504 --- app/build.gradle | 2 +- .../pro/activities/SettingsActivity.kt | 18 +++++++++++ app/src/main/res/layout/activity_settings.xml | 32 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index c07608bc0..c543a4927 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.32.25' + implementation 'com.simplemobiletools:commons:5.32.28' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 84e089a88..274394aaa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -90,6 +90,7 @@ class SettingsActivity : SimpleActivity() { setupEmptyRecycleBin() updateTextColors(settings_holder) setupSectionColors() + setupClearCache() setupExportSettings() setupImportSettings() invalidateOptionsMenu() @@ -624,6 +625,23 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupClearCache() { + ensureBackgroundThread { + runOnUiThread { + settings_clear_cache_size.text = cacheDir.getProperSize(true).formatSize() + } + } + + settings_clear_cache_holder.setOnClickListener { + ensureBackgroundThread { + cacheDir.deleteRecursively() + runOnUiThread { + settings_clear_cache_size.text = cacheDir.getProperSize(true).formatSize() + } + } + } + } + private fun setupExportSettings() { settings_export_holder.setOnClickListener { val configItems = LinkedHashMap().apply { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 399715167..b8bfda998 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1236,6 +1236,38 @@ android:textAllCaps="true" android:textSize="@dimen/smaller_text_size" /> + + + + + + + +