Remove clear image cache option (#165)

This commit is contained in:
vfsfitvnm 2022-08-03 21:26:41 +02:00
parent 0824a4ecfa
commit 2eea488fc9

View file

@ -15,9 +15,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
@ -34,7 +32,6 @@ import it.vfsfitvnm.vimusic.enums.ExoPlayerDiskCacheMaxSize
import it.vfsfitvnm.vimusic.ui.components.TopAppBar import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.screens.EnumValueSelectorSettingsEntry import it.vfsfitvnm.vimusic.ui.screens.EnumValueSelectorSettingsEntry
import it.vfsfitvnm.vimusic.ui.screens.SettingsDescription import it.vfsfitvnm.vimusic.ui.screens.SettingsDescription
import it.vfsfitvnm.vimusic.ui.screens.SettingsEntry
import it.vfsfitvnm.vimusic.ui.screens.SettingsEntryGroupText import it.vfsfitvnm.vimusic.ui.screens.SettingsEntryGroupText
import it.vfsfitvnm.vimusic.ui.screens.SettingsGroupDescription import it.vfsfitvnm.vimusic.ui.screens.SettingsGroupDescription
import it.vfsfitvnm.vimusic.ui.screens.SettingsTitle import it.vfsfitvnm.vimusic.ui.screens.SettingsTitle
@ -43,8 +40,6 @@ import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.utils.coilDiskCacheMaxSizeKey import it.vfsfitvnm.vimusic.utils.coilDiskCacheMaxSizeKey
import it.vfsfitvnm.vimusic.utils.exoPlayerDiskCacheMaxSizeKey import it.vfsfitvnm.vimusic.utils.exoPlayerDiskCacheMaxSizeKey
import it.vfsfitvnm.vimusic.utils.rememberPreference import it.vfsfitvnm.vimusic.utils.rememberPreference
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@OptIn(ExperimentalCoilApi::class) @OptIn(ExperimentalCoilApi::class)
@ExperimentalAnimationApi @ExperimentalAnimationApi
@ -70,8 +65,6 @@ fun CacheSettingsScreen() {
ExoPlayerDiskCacheMaxSize.`2GB` ExoPlayerDiskCacheMaxSize.`2GB`
) )
val coroutineScope = rememberCoroutineScope()
Column( Column(
modifier = Modifier modifier = Modifier
.background(colorPalette.background) .background(colorPalette.background)
@ -99,8 +92,8 @@ fun CacheSettingsScreen() {
SettingsDescription(text = "When the cache runs out of space, the resources that haven't been accessed for the longest time are cleared.") SettingsDescription(text = "When the cache runs out of space, the resources that haven't been accessed for the longest time are cleared.")
Coil.imageLoader(context).diskCache?.let { diskCache -> Coil.imageLoader(context).diskCache?.let { diskCache ->
var diskCacheSize by remember(diskCache) { val diskCacheSize = remember(diskCache) {
mutableStateOf(diskCache.size) diskCache.size
} }
SettingsEntryGroupText(title = "IMAGE CACHE") SettingsEntryGroupText(title = "IMAGE CACHE")
@ -114,17 +107,6 @@ fun CacheSettingsScreen() {
coilDiskCacheMaxSize = it coilDiskCacheMaxSize = it
} }
) )
SettingsEntry(
title = "Clear space",
text = "Wipe every cached image",
onClick = {
coroutineScope.launch(Dispatchers.IO) {
diskCache.clear()
diskCacheSize = diskCache.size
}
}
)
} }
binder?.cache?.let { cache -> binder?.cache?.let { cache ->