OSDN Git Service

CMFileManager:
authorMartin Brabham <optedoblivion@cyngn.com>
Wed, 17 Dec 2014 20:17:04 +0000 (12:17 -0800)
committerMartin Brabham <optedoblivion@cyngn.com>
Thu, 18 Dec 2014 04:40:03 +0000 (20:40 -0800)
 - Use Environment function to be more compatible.
 - Take into account the directory sizes
 - Fix usage dialog jumping on first open.
 - Fix Java DiskUsageCommand to return correct DiskUsage based on MountPoint

Change-Id: I62c4e734a99f5eba8eb596db360e760cb8404b51

src/com/cyanogenmod/filemanager/FileManagerApplication.java
src/com/cyanogenmod/filemanager/service/MimeTypeIndexService.java
src/com/cyanogenmod/filemanager/ui/dialogs/FilesystemInfoDialog.java
src/com/cyanogenmod/filemanager/util/CommandHelper.java

index 0529b97..3855c04 100644 (file)
@@ -181,7 +181,7 @@ public final class FileManagerApplication extends Application {
         // file manager
         File externalStorage = Environment.getExternalStorageDirectory();
         MimeTypeIndexService.indexFileRoot(this, externalStorage.getAbsolutePath());
-        MimeTypeIndexService.indexFileRoot(this, "/system");
+        MimeTypeIndexService.indexFileRoot(this, Environment.getRootDirectory().getAbsolutePath());
 
     }
 
index 7f92692..ad7192e 100644 (file)
@@ -124,6 +124,13 @@ public class MimeTypeIndexService extends IntentService {
         if (dirs != null) {
             // Recurse directories
             for (File dir : dirs) {
+                long size = dir.length();
+                if (!groupUsageMap.containsKey(MimeTypeCategory.NONE)) {
+                    groupUsageMap.put(MimeTypeCategory.NONE, size);
+                } else {
+                    long newSum = groupUsageMap.get(MimeTypeCategory.NONE) + size;
+                    groupUsageMap.put(MimeTypeCategory.NONE, newSum);
+                }
                 calculateUsageByType(dir, groupUsageMap);
             }
         }
index 5ead319..e5b05f4 100644 (file)
@@ -89,17 +89,18 @@ public class FilesystemInfoDialog implements OnClickListener, OnCheckedChangeLis
 
         }
 
+        if (mIsInUsageTab) {
+            if (mLegendLayout.getVisibility() != View.VISIBLE) {
+                populateLegend();
+                mLegendLayout.setVisibility(View.VISIBLE);
+            }
+        }
+
         this.mDiskUsageGraph.post(new Runnable() {
             @Override
             public void run() {
                 //Animate disk usage graph
                 FilesystemInfoDialog.this.mDiskUsageGraph.drawDiskUsage(mDiskUsage);
-                if (mIsInUsageTab) {
-                    if (mLegendLayout.getVisibility() != View.VISIBLE) {
-                        populateLegend();
-                        mLegendLayout.setVisibility(View.VISIBLE);
-                    }
-                }
                 isFetching = false;
             }
         });
@@ -386,17 +387,17 @@ public class FilesystemInfoDialog implements OnClickListener, OnCheckedChangeLis
                     // Apply theme
                     applyTabTheme();
                 }
+                if (mIsInUsageTab) {
+                    if (mLegendLayout.getVisibility() != View.VISIBLE) {
+                        populateLegend();
+                        mLegendLayout.setVisibility(View.VISIBLE);
+                    }
+                }
                 this.mDiskUsageGraph.post(new Runnable() {
                     @Override
                     public void run() {
                         //Animate disk usage graph
                         FilesystemInfoDialog.this.mDiskUsageGraph.drawDiskUsage(mDiskUsage);
-                        if (mIsInUsageTab) {
-                            if (mLegendLayout.getVisibility() != View.VISIBLE) {
-                                populateLegend();
-                                mLegendLayout.setVisibility(View.VISIBLE);
-                            }
-                        }
                     }
                 });
                 break;
index edba969..6c33a2f 100644 (file)
@@ -1115,8 +1115,10 @@ public final class CommandHelper {
                     c.getExecutableFactory().newCreator().createDiskUsageExecutable(dir);
             execute(context, executable, c);
             List<DiskUsage> du = executable.getResult();
-            if (du != null && du.size() > 0) {
-                return du.get(0);
+            for (DiskUsage d : du) {
+                if (d.getMountPoint().equals(dir)) {
+                    return d;
+                }
             }
         }
         return null;