\r
import java.io.File;\r
import java.io.FileFilter;\r
-import java.text.Collator;\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
import java.util.Comparator;\r
import net.sf.openrocket.R;\r
import net.sf.openrocket.android.actionbarcompat.ActionBarListActivity;\r
import android.app.AlertDialog;\r
+import android.app.Dialog;\r
import android.content.DialogInterface;\r
import android.content.Intent;\r
import android.content.SharedPreferences;\r
private List<File> path = null;\r
private final static File root = new File("/");\r
\r
+ private File previousDirectory = root;\r
+ \r
private String baseDirPrefKey;\r
private String baseDirName;\r
\r
\r
}\r
\r
- private void getDir(File dirPath) {\r
+ private void getDir(final File dirPath) {\r
+ \r
+ // A little sanity check. It could be possible the directory saved in the preference\r
+ // is no longer mounted, is not a directory (any more), or cannot be read.\r
+ // if any of these are the case, we display a little dialog, then revert to the\r
+ // previousDirectory.\r
+ if ( !dirPath.exists() || !dirPath.isDirectory() || !dirPath.canRead() ) {\r
+ \r
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);\r
+ builder.setTitle("Unable to open directory " + dirPath.getAbsolutePath() );\r
+ builder.setCancelable(true);\r
+ builder.setOnCancelListener( new Dialog.OnCancelListener() {\r
+\r
+ @Override\r
+ public void onCancel(DialogInterface arg0) {\r
+ if ( root.getAbsolutePath().equals(dirPath.getAbsolutePath()) ) {\r
+ SimpleFileBrowser.this.finish();\r
+ } else {\r
+ SimpleFileBrowser.this.getDir( previousDirectory );\r
+ }\r
+ }\r
+ \r
+ });\r
+ builder.show();\r
+ return;\r
+ }\r
+ \r
+ previousDirectory = dirPath;\r
+ \r
setTitle(dirPath.getAbsolutePath());\r
path = new ArrayList<File>();\r
\r