mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Show file details in overview dialog (#126)
When clicking the overview for an item, the dialog now shows details about each file/media source including video, audio, & subtitle information. It only shows the full file path if the user is an administrator.
This commit is contained in:
parent
ba09ac09e4
commit
1508fa1ea3
7 changed files with 143 additions and 19 deletions
|
|
@ -140,3 +140,27 @@ fun abbreviateNumber(number: Int): String {
|
|||
}
|
||||
return String.format(Locale.getDefault(), "%.1f%s", count, abbrevSuffixes[unit])
|
||||
}
|
||||
|
||||
val byteSuffixes = listOf("B", "KB", "MB", "GB", "TB")
|
||||
val byteRateSuffixes = listOf("bps", "kbps", "mbps", "gbps", "tbps")
|
||||
|
||||
/**
|
||||
* Format bytes
|
||||
*/
|
||||
fun formatBytes(
|
||||
bytes: Int,
|
||||
suffixes: List<String> = byteSuffixes,
|
||||
) = formatBytes(bytes.toLong(), suffixes)
|
||||
|
||||
fun formatBytes(
|
||||
bytes: Long,
|
||||
suffixes: List<String> = byteSuffixes,
|
||||
): String {
|
||||
var unit = 0
|
||||
var count = bytes.toDouble()
|
||||
while (count >= 1024 && unit + 1 < suffixes.size) {
|
||||
count /= 1024
|
||||
unit++
|
||||
}
|
||||
return String.format(Locale.getDefault(), "%.2f%s", count, suffixes[unit])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue