summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-12-02 18:17:14 +0100
committerArne Schwabe <arne@rfc2549.org>2013-12-02 18:17:14 +0100
commit4a7889b72c08d90d4fa61432ef4ed8257d504b53 (patch)
tree929d3c122a2c76da467c1b7b06a1724c7eea8e6f
parente827c55cdd14588585b1d12e4f8cba0ffb69381d (diff)
Fix finding configuration files
-rw-r--r--src/de/blinkt/openvpn/ConfigConverter.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/de/blinkt/openvpn/ConfigConverter.java b/src/de/blinkt/openvpn/ConfigConverter.java
index d0782a8a..11a3055a 100644
--- a/src/de/blinkt/openvpn/ConfigConverter.java
+++ b/src/de/blinkt/openvpn/ConfigConverter.java
@@ -7,6 +7,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.HashSet;
import java.util.List;
import java.util.Vector;
@@ -20,6 +21,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
+import android.text.TextUtils;
import android.util.Base64;
import android.view.Menu;
import android.view.MenuInflater;
@@ -247,13 +249,23 @@ public class ConfigConverter extends ListActivity {
File sdcard = Environment.getExternalStorageDirectory();
File root = new File("/");
- Vector<File> dirlist = new Vector<File>();
+ HashSet<File> dirlist = new HashSet<File>();
for(int i=mPathsegments.size()-1;i >=0 ;i--){
String path = "";
for (int j = 0;j<=i;j++) {
path += "/" + mPathsegments.get(j);
}
+ // Do a little hackish dance for the Android File Importer
+ // /document/primary:ovpn/openvpn-imt.conf
+
+ if (path.indexOf(':')!=-1) {
+ String possibleDir = path.substring(path.indexOf(':')+1,path.length());
+ possibleDir.substring(0,possibleDir.lastIndexOf('/'));
+ dirlist.add(new File(sdcard,possibleDir));
+
+
+ }
dirlist.add(new File(path));
}
dirlist.add(sdcard);
@@ -373,7 +385,10 @@ public class ConfigConverter extends ListActivity {
data.getLastPathSegment().endsWith(".conf"))
{
mPossibleName = data.getLastPathSegment();
- if(mPossibleName!=null){
+ if (mPossibleName.lastIndexOf('/')!=-1)
+ mPossibleName = mPossibleName.substring(mPossibleName.lastIndexOf('/')+1);
+
+ if(mPossibleName!=null){
mPossibleName =mPossibleName.replace(".ovpn", "");
mPossibleName =mPossibleName.replace(".conf", "");
}