mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-26 02:57:50 +02:00
Add basic storage usage info to "Data and storage" settings screen
This commit is contained in:
@ -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.
|
||||
*/
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user