mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-24 20:18:53 +02:00
Clean up storage usage info
- Show bar representation of used/total space - Handle all mounted storages - Also included a bunch of unrelated immutables changes, sorry
This commit is contained in:
@@ -3,13 +3,32 @@ package eu.kanade.tachiyomi.util.storage
|
||||
import android.content.Context
|
||||
import android.media.MediaScannerConnection
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.os.StatFs
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.util.lang.Hash
|
||||
import java.io.File
|
||||
|
||||
object DiskUtil {
|
||||
|
||||
/**
|
||||
* Returns the root folders of all the available external storages.
|
||||
*/
|
||||
fun getExternalStorages(context: Context): List<File> {
|
||||
return ContextCompat.getExternalFilesDirs(context, null)
|
||||
.filterNotNull()
|
||||
.mapNotNull {
|
||||
val file = File(it.absolutePath.substringBefore("/Android/"))
|
||||
val state = Environment.getExternalStorageState(file)
|
||||
if (state == Environment.MEDIA_MOUNTED || state == Environment.MEDIA_MOUNTED_READ_ONLY) {
|
||||
file
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun hashKeyForDisk(key: String): String {
|
||||
return Hash.md5(key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user