aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/SelectMapfileActivity.java2
-rw-r--r--main/src/cgeo/geocaching/files/AbstractFileListActivity.java49
-rw-r--r--main/src/cgeo/geocaching/files/LocalStorage.java46
3 files changed, 48 insertions, 49 deletions
diff --git a/main/src/cgeo/geocaching/SelectMapfileActivity.java b/main/src/cgeo/geocaching/SelectMapfileActivity.java
index 8f82288..8b50c1f 100644
--- a/main/src/cgeo/geocaching/SelectMapfileActivity.java
+++ b/main/src/cgeo/geocaching/SelectMapfileActivity.java
@@ -47,7 +47,7 @@ public class SelectMapfileActivity extends AbstractFileListActivity<FileSelectio
@Override
protected List<File> getBaseFolders() {
List<File> folders = new ArrayList<File>();
- for (File dir : getStorages()) {
+ for (File dir : LocalStorage.getStorages()) {
folders.add(new File(dir, "mfmaps"));
folders.add(new File(new File(dir, "Locus"), "mapsVector"));
folders.add(new File(dir, LocalStorage.cache));
diff --git a/main/src/cgeo/geocaching/files/AbstractFileListActivity.java b/main/src/cgeo/geocaching/files/AbstractFileListActivity.java
index 8b02eeb..e3deab6 100644
--- a/main/src/cgeo/geocaching/files/AbstractFileListActivity.java
+++ b/main/src/cgeo/geocaching/files/AbstractFileListActivity.java
@@ -5,7 +5,6 @@ import cgeo.geocaching.R;
import cgeo.geocaching.StoredList;
import cgeo.geocaching.activity.AbstractListActivity;
import cgeo.geocaching.utils.FileUtils;
-import cgeo.geocaching.utils.IOUtils;
import cgeo.geocaching.utils.Log;
import org.apache.commons.collections.CollectionUtils;
@@ -19,10 +18,7 @@ import android.os.Handler;
import android.os.Message;
import android.widget.ArrayAdapter;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -172,7 +168,7 @@ public abstract class AbstractFileListActivity<T extends ArrayAdapter<File>> ext
}
if (!loaded) {
changeWaitDialogHandler.sendMessage(Message.obtain(changeWaitDialogHandler, MSG_SEARCH_WHOLE_SD_CARD, Environment.getExternalStorageDirectory().getName()));
- listDirs(list, getStorages(), selector, changeWaitDialogHandler);
+ listDirs(list, LocalStorage.getStorages(), selector, changeWaitDialogHandler);
}
} else {
Log.w("No external media mounted.");
@@ -202,49 +198,6 @@ public abstract class AbstractFileListActivity<T extends ArrayAdapter<File>> ext
}
}
- /*
- * Get all storages available on the device.
- * Will include paths like /mnt/sdcard /mnt/usbdisk /mnt/ext_card /mnt/sdcard/ext_card
- */
- protected static List<File> getStorages() {
-
- String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
- List<File> storages = new ArrayList<File>();
- storages.add(new File(extStorage));
- File file = new File("/system/etc/vold.fstab");
- if (file.canRead()) {
- FileReader fr = null;
- BufferedReader br = null;
- try {
- fr = new FileReader(file);
- br = new BufferedReader(fr);
- String s = br.readLine();
- while (s != null) {
- if (s.startsWith("dev_mount")) {
- String[] tokens = StringUtils.split(s);
- if (tokens.length >= 3) {
- String path = tokens[2]; // mountpoint
- if (!extStorage.equals(path)) {
- File directory = new File(path);
- if (directory.exists() && directory.isDirectory()) {
- storages.add(directory);
- }
- }
- }
- }
- s = br.readLine();
- }
- } catch (IOException e) {
- Log.e("Could not get additional mount points for user content. " +
- "Proceeding with external storage only (" + extStorage + ")");
- } finally {
- IOUtils.closeQuietly(fr);
- IOUtils.closeQuietly(br);
- }
- }
- return storages;
- }
-
/**
* Check if a filename belongs to the AbstractFileListActivity. This implementation checks for file extensions.
* Subclasses may override this method to filter out specific files.
diff --git a/main/src/cgeo/geocaching/files/LocalStorage.java b/main/src/cgeo/geocaching/files/LocalStorage.java
index ec09433..d10f12b 100644
--- a/main/src/cgeo/geocaching/files/LocalStorage.java
+++ b/main/src/cgeo/geocaching/files/LocalStorage.java
@@ -14,6 +14,7 @@ import android.os.Environment;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -24,6 +25,8 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
/**
* Handle local storage issues on phone and SD card.
@@ -389,4 +392,47 @@ public class LocalStorage {
};
return LocalStorage.getStorageDir(geocode).listFiles(filter);
}
+
+ /**
+ * Get all storages available on the device.
+ * Will include paths like /mnt/sdcard /mnt/usbdisk /mnt/ext_card /mnt/sdcard/ext_card
+ */
+ public static List<File> getStorages() {
+
+ String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
+ List<File> storages = new ArrayList<File>();
+ storages.add(new File(extStorage));
+ File file = new File("/system/etc/vold.fstab");
+ if (file.canRead()) {
+ FileReader fr = null;
+ BufferedReader br = null;
+ try {
+ fr = new FileReader(file);
+ br = new BufferedReader(fr);
+ String s = br.readLine();
+ while (s != null) {
+ if (s.startsWith("dev_mount")) {
+ String[] tokens = StringUtils.split(s);
+ if (tokens.length >= 3) {
+ String path = tokens[2]; // mountpoint
+ if (!extStorage.equals(path)) {
+ File directory = new File(path);
+ if (directory.exists() && directory.isDirectory()) {
+ storages.add(directory);
+ }
+ }
+ }
+ }
+ s = br.readLine();
+ }
+ } catch (IOException e) {
+ Log.e("Could not get additional mount points for user content. " +
+ "Proceeding with external storage only (" + extStorage + ")");
+ } finally {
+ IOUtils.closeQuietly(fr);
+ IOUtils.closeQuietly(br);
+ }
+ }
+ return storages;
+ }
}