Browse Source

- use externalMediaDir to allow downloaded files to be scanned again
- do not show "unknown" storage path, instead show complete path

tobiasKaminsky 8 years ago
parent
commit
e68e8f6d32

+ 3 - 3
src/main/java/com/owncloud/android/datastorage/DataStorageProvider.java

@@ -24,7 +24,6 @@ package com.owncloud.android.datastorage;
 import android.os.Build;
 
 import com.owncloud.android.MainApp;
-import com.owncloud.android.R;
 import com.owncloud.android.datastorage.providers.EnvironmentStoragePointProvider;
 import com.owncloud.android.datastorage.providers.HardcodedStoragePointProvider;
 import com.owncloud.android.datastorage.providers.IStoragePointProvider;
@@ -65,7 +64,7 @@ public class DataStorageProvider {
         }
 
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            for (File f : MainApp.getAppContext().getExternalFilesDirs(null)) {
+            for (File f : MainApp.getAppContext().getExternalMediaDirs()) {
                 if (f != null) {
                     mCachedStoragePoints.add(new StoragePoint(f.getAbsolutePath(), f.getAbsolutePath()));
                 }
@@ -87,7 +86,8 @@ public class DataStorageProvider {
                 return s.getDescription();
             }
         }
-        return MainApp.getAppContext().getString(R.string.storage_description_unknown);
+        // Fallback to just display complete path
+        return path;
     }
 
     public void addStoragePointProvider(IStoragePointProvider provider) {

+ 13 - 4
src/main/java/com/owncloud/android/datastorage/providers/SystemDefaultStoragePointProvider.java

@@ -21,14 +21,15 @@
 
 package com.owncloud.android.datastorage.providers;
 
-import android.os.Environment;
-
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.datastorage.StoragePoint;
 
+import java.io.File;
 import java.util.Vector;
 
+import static android.os.Environment.getExternalStorageDirectory;
+
 /**
  * @author Bartosz Przybylski
  */
@@ -44,8 +45,16 @@ public class SystemDefaultStoragePointProvider extends AbstractStoragePointProvi
 
         final String defaultStringDesc =
                 MainApp.getAppContext().getString(R.string.storage_description_default);
-        final String path = Environment.getExternalStorageDirectory().getAbsolutePath();
-        result.add(new StoragePoint(defaultStringDesc, path));
+        File path;
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+            path = MainApp.getAppContext().getExternalMediaDirs()[0];
+        } else {
+            path = getExternalStorageDirectory();
+        }
+
+        if (path != null) {
+            result.add(new StoragePoint(defaultStringDesc, path.getAbsolutePath()));
+        }
 
         return result;
     }