diff --git a/app/build.gradle b/app/build.gradle index 7049d7f7..e1bac656 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -58,7 +58,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:69346a62e0' + implementation 'com.github.SimpleMobileTools:Simple-Commons:cad50847e3' implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootShell:1.6' implementation 'com.alexvasilkov:gesture-views:2.5.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Long.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Long.kt new file mode 100644 index 00000000..61cee2fe --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Long.kt @@ -0,0 +1,14 @@ +package com.simplemobiletools.filemanager.pro.extensions + +import java.text.DecimalFormat + +// use 1000 instead of 1024 at dividing +fun Long.formatSizeThousand(): String { + if (this <= 0) { + return "0 B" + } + + val units = arrayOf("B", "kB", "MB", "GB", "TB") + val digitGroups = (Math.log10(toDouble()) / Math.log10(1000.0)).toInt() + return "${DecimalFormat("#,##0.#").format(this / Math.pow(1000.0, digitGroups.toDouble()))} ${units[digitGroups]}" +}