Add: More info on top of the screen

Fix: Show real size of apk
This commit is contained in:
LooKeR
2021-10-22 19:29:47 +05:30
parent 3ea6dab407
commit fd7746f8b3
6 changed files with 235 additions and 24 deletions

View File

@ -13,12 +13,23 @@ private val sizeFormats = listOf("%.0f B", "%.0f kB", "%.1f MB", "%.2f GB")
fun Long.formatSize(): String {
val (size, index) = generateSequence(Pair(this.toFloat(), 0)) { (size, index) ->
if (size >= 1000f)
Pair(size / 1000f, index + 1) else null
if (size >= 1024f)
Pair(size / 1024f, index + 1) else null
}.take(sizeFormats.size).last()
return sizeFormats[index].format(Locale.US, size)
}
fun String?.trimAfter(char: Char, repeated: Int): String? {
var count = 0
this?.let {
for (i in it.indices) {
if (it[i] == char) count++
if (repeated == count) return it.substring(0, i)
}
}
return null
}
fun Char.halfByte(): Int {
return when (this) {
in '0'..'9' -> this - '0'