From 4a7889b72c08d90d4fa61432ef4ed8257d504b53 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 2 Dec 2013 18:17:14 +0100 Subject: Fix finding configuration files --- src/de/blinkt/openvpn/ConfigConverter.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/de') 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 dirlist = new Vector(); + HashSet dirlist = new HashSet(); 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", ""); } -- cgit v1.2.3