allow clearing the app cache, related to #1504

This commit is contained in:
tibbi 2021-01-17 10:31:22 +01:00
parent ce6e3315c0
commit 560aedfb6e
3 changed files with 51 additions and 1 deletions

View File

@ -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'

View File

@ -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<String, Any>().apply {

View File

@ -1236,6 +1236,38 @@
android:textAllCaps="true"
android:textSize="@dimen/smaller_text_size" />
<RelativeLayout
android:id="@+id/settings_clear_cache_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/bigger_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_clear_cache_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/settings_clear_cache_size"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:text="@string/clear_cache" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_clear_cache_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/medium_margin"
android:background="@null"
android:clickable="false" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_export_holder"
android:layout_width="match_parent"