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

(cherry picked from commit cb8ea5eab0ec68ea02e8dc98c0a52771c460d5ab)

# Conflicts:
#	app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDataScreen.kt
This commit is contained in:
arkon
2023-10-29 16:57:38 -04:00
committed by Jobobby04
parent 1202409b25
commit cde00282c1
4 changed files with 71 additions and 11 deletions
@@ -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)