Feature: add session data consumption information in GUI/text UIs (#287)
* Feature: add session data consumption information in GUI/text UIs Adds the total bytes downloaded and uploaded in the current session as well as the average data transfer rate for both UL/DL. The information is not added to the 1-line UI as the line will take 150+ characters in the screen.
This commit is contained in:
@@ -228,4 +228,24 @@ public class Utils {
|
||||
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public static String formatDataConsumption(long bytes) {
|
||||
float divider = 0;
|
||||
String suffix = "";
|
||||
|
||||
if (bytes > 1099511627776f) { // 1TB
|
||||
divider = 1099511627776f;
|
||||
suffix = "TB";
|
||||
}
|
||||
else if (bytes > 1073741824) { // 1GB
|
||||
divider = 1073741824;
|
||||
suffix = "GB";
|
||||
}
|
||||
else { // 1MB
|
||||
divider = 1048576;
|
||||
suffix = "MB";
|
||||
}
|
||||
|
||||
return String.format("%.2f%s", (bytes / divider), suffix);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user