From: Steve Block Date: Thu, 10 Sep 2009 14:01:37 +0000 (+0100) Subject: Rounds up to the nearest 0.1MB when displaying the storage used by a website. X-Git-Tag: android-x86-2.2~176^2~178^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=764f0c9765aadeaadd3fbad11b18ab67dd96967d;p=android-x86%2Fpackages-apps-Browser.git Rounds up to the nearest 0.1MB when displaying the storage used by a website. This fixes bug http://b/issue?id=2024901. Change-Id: Ifa8d12e3a5844c8e5b27ce9ddd817058257eabc6 --- diff --git a/src/com/android/browser/WebsiteSettingsActivity.java b/src/com/android/browser/WebsiteSettingsActivity.java index 6e1ea0a..577fc1c 100644 --- a/src/com/android/browser/WebsiteSettingsActivity.java +++ b/src/com/android/browser/WebsiteSettingsActivity.java @@ -278,14 +278,17 @@ public class WebsiteSettingsActivity extends ListActivity { return mCurrentSite.getFeatureCount(); } - public String sizeValueToString(long value) { - float mb = (float) value / (1024.0F * 1024.0F); - int val = (int) (mb * 10); - float ret = (float) (val / 10.0F); - if (ret <= 0) { + public String sizeValueToString(long bytes) { + // We display the size in MB, to 1dp, rounding up to the next 0.1MB. + // bytes should always be greater than zero. + if (bytes <= 0) { + Log.e(LOGTAG, "sizeValueToString called with non-positive value"); return "0"; } - return String.valueOf(ret); + float megabytes = (float) bytes / (1024.0F * 1024.0F); + int truncated = (int) Math.ceil(megabytes * 10.0F); + float result = (float) (truncated / 10.0F); + return String.valueOf(result); } /*