OSDN Git Service

Sizes: Let disk usage show sizes as doubles
authorStephen Bird <sbird@cyngn.com>
Mon, 8 Jun 2015 23:19:43 +0000 (16:19 -0700)
committerStephen Bird <sbird@cyngn.com>
Thu, 11 Jun 2015 20:14:07 +0000 (13:14 -0700)
This way, weird file system sizes display nicely.
Without this a mountpoint with a size of 1.68GB
displays as 1GB.

Change-Id: I72e0d8ff911dd942efd5860f2d86607ebbb30fcb

src/com/cyanogenmod/filemanager/util/FileHelper.java

index 4457cca..501092a 100644 (file)
@@ -202,16 +202,20 @@ public final class FileHelper {
                                  R.string.size_gigabytes
                                 };
 
-        long aux = size;
+        double aux = size;
         int cc = magnitude.length;
         for (int i = 0; i < cc; i++) {
-            long s = aux / 1024;
             if (aux < 1024) {
-                return Long.toString(aux) + " " + res.getString(magnitude[i]); //$NON-NLS-1$
+                double cleanSize = Math.round(aux * 100);
+                return Double.toString(cleanSize / 100) +
+                        " " + res.getString(magnitude[i]); //$NON-NLS-1$
+            } else {
+                aux = aux / 1024;
             }
-            aux = s;
         }
-        return Long.toString(aux) + " " + res.getString(magnitude[cc - 1]); //$NON-NLS-1$
+        double cleanSize = Math.round(aux * 100);
+        return Double.toString(cleanSize / 100) +
+                " " + res.getString(magnitude[cc - 1]); //$NON-NLS-1$
     }
 
     /**