|
|
|
@ -345,6 +345,61 @@ object FolderSettingsModule: SettingModule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"clear_info_jsons" -> {
|
|
|
|
|
|
|
|
pref.apply {
|
|
|
|
|
|
|
|
val infoJsonSize = File(FileUtil.getInfoJsonPath(context)).walkBottomUp().fold(0L) { acc, file -> acc + file.length() }
|
|
|
|
|
|
|
|
val filesize = if (infoJsonSize < 10000) {
|
|
|
|
|
|
|
|
"0B"
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
FileUtil.convertFileSize(infoJsonSize)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summary = "(${filesize})"
|
|
|
|
|
|
|
|
onPreferenceClickListener =
|
|
|
|
|
|
|
|
Preference.OnPreferenceClickListener {
|
|
|
|
|
|
|
|
host.hostLifecycleOwner.lifecycleScope.launch {
|
|
|
|
|
|
|
|
activeDownloadCount = withContext(Dispatchers.IO) {
|
|
|
|
|
|
|
|
downloadViewModel.getActiveDownloadsCount()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (activeDownloadCount == 0){
|
|
|
|
|
|
|
|
fun clearInfoJsonFolder(folder: File) {
|
|
|
|
|
|
|
|
if (folder.exists() && folder.isDirectory) {
|
|
|
|
|
|
|
|
folder.listFiles()?.forEach { file ->
|
|
|
|
|
|
|
|
if (file.isDirectory) {
|
|
|
|
|
|
|
|
clearInfoJsonFolder(file)
|
|
|
|
|
|
|
|
file.delete()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
file.delete()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clearInfoJsonFolder(File(FileUtil.getInfoJsonPath(context)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (host.hostView != null && host.hostView!!.isAttachedToWindow) {
|
|
|
|
|
|
|
|
Snackbar.make(host.hostView!!, context.getString(R.string.cache_cleared), Snackbar.LENGTH_SHORT).show()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if (host.hostView != null && host.hostView!!.isAttachedToWindow) {
|
|
|
|
|
|
|
|
Snackbar.make(host.hostView!!, context.getString(R.string.downloads_running_try_later), Snackbar.LENGTH_SHORT).show()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val infoJsonSize = File(FileUtil.getInfoJsonPath(context)).walkBottomUp().fold(0L) { acc, file -> acc + file.length() }
|
|
|
|
|
|
|
|
val filesize = if (infoJsonSize < 10000) {
|
|
|
|
|
|
|
|
"0B"
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
FileUtil.convertFileSize(infoJsonSize)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summary = "(${filesize})"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
host.refreshUI()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
"move_cache" -> {
|
|
|
|
"move_cache" -> {
|
|
|
|
pref.apply {
|
|
|
|
pref.apply {
|
|
|
|
onPreferenceClickListener =
|
|
|
|
onPreferenceClickListener =
|
|
|
|
|