Add basic storage usage info to "Data and storage" settings screen

This commit is contained in:
arkon
2023-10-29 16:57:38 -04:00
parent ce7bf396eb
commit cb8ea5eab0
4 changed files with 71 additions and 11 deletions

View File

@ -28,6 +28,30 @@ object DiskUtil {
return size
}
/**
* Gets the total space for the disk that a file path points to, in bytes.
*/
fun getTotalStorageSpace(file: File): Long {
return try {
val stat = StatFs(file.absolutePath)
stat.blockCountLong * stat.blockSizeLong
} catch (_: Exception) {
-1L
}
}
/**
* Gets the available space for the disk that a file path points to, in bytes.
*/
fun getAvailableStorageSpace(file: File): Long {
return try {
val stat = StatFs(file.absolutePath)
stat.availableBlocksLong * stat.blockSizeLong
} catch (_: Exception) {
-1L
}
}
/**
* Gets the available space for the disk that a file path points to, in bytes.
*/

View File

@ -35,7 +35,7 @@ interface Preference<T> {
/**
* A preference used for internal app state that isn't really a user preference
* and therefore should not be inplaces like backips.
* and therefore should not be in places like backups.
*/
fun isAppState(key: String): Boolean {
return key.startsWith(APP_STATE_PREFIX)