Next-Improvement
authorPeter Henn <Peter.Henn@web.de>
Tue, 7 Jul 2015 23:14:18 +0000 (23:14 +0000)
committerPeter Henn <Peter.Henn@web.de>
Tue, 7 Jul 2015 23:14:18 +0000 (23:14 +0000)
Try to build the pathname by getBaseStorePathString, which
only helps getTemporalPath and getSavePath, but not
getUsableSpace. Anyway if we may assume that in case of
the usage of an external SD-CARD here we need to check
only the left space of that medium, which could make the
getBaseStorePath obsolete.

src/com/owncloud/android/utils/FileStorageUtils.java

index d0f457e..68f6e27 100644 (file)
@@ -53,11 +53,27 @@ public class FileStorageUtils {
         return baseStoragePath;
     }
 
         return baseStoragePath;
     }
 
+    @SuppressLint("NewApi")
+    private static final String getBaseStorePathString() {
+        File baseStoragePath = Environment.getExternalStorageDirectory();
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
+            File[] dirs = MainApp.getAppContext().getExternalFilesDirs(null);
+            if (dirs.length > 1) {
+                baseStoragePath = dirs[1];
+            }
+            return baseStoragePath.getAbsolutePath();
+        } else {
+            return baseStoragePath.getAbsolutePath() + "/" + MainApp.getDataFolder();
+        }
+    }
+
+
     public static final String getSavePath(String accountName) {
         //File sdCard = Environment.getExternalStorageDirectory();
         //return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/" + Uri.encode(accountName, "@");
         // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
     public static final String getSavePath(String accountName) {
         //File sdCard = Environment.getExternalStorageDirectory();
         //return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/" + Uri.encode(accountName, "@");
         // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
-        return getBaseStorePath().getAbsolutePath()  + "/" + Uri.encode(accountName, "@");
+        //return getBaseStorePath().getAbsolutePath()  + "/" + Uri.encode(accountName, "@");
+        return getBaseStorePathString()  + "/" + Uri.encode(accountName, "@");
     }
 
     public static final String getDefaultSavePathFor(String accountName, OCFile file) {
     }
 
     public static final String getDefaultSavePathFor(String accountName, OCFile file) {
@@ -68,7 +84,8 @@ public class FileStorageUtils {
         //File sdCard = Environment.getExternalStorageDirectory();
         //return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/tmp/" + Uri.encode(accountName, "@");
             // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
         //File sdCard = Environment.getExternalStorageDirectory();
         //return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/tmp/" + Uri.encode(accountName, "@");
             // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
-        return getBaseStorePath().getAbsolutePath() + "/tmp/" + Uri.encode(accountName, "@");
+        //return getBaseStorePath().getAbsolutePath() + "/tmp/" + Uri.encode(accountName, "@");
+        return getBaseStorePathString() + "/tmp/" + Uri.encode(accountName, "@");        
     }
 
     @SuppressLint("NewApi")
     }
 
     @SuppressLint("NewApi")