summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/fragments
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/blinkt/openvpn/fragments')
-rw-r--r--src/de/blinkt/openvpn/fragments/FileSelectionFragment.java8
-rw-r--r--src/de/blinkt/openvpn/fragments/VPNProfileList.java39
2 files changed, 38 insertions, 9 deletions
diff --git a/src/de/blinkt/openvpn/fragments/FileSelectionFragment.java b/src/de/blinkt/openvpn/fragments/FileSelectionFragment.java
index 2cfe886b..03f6bb88 100644
--- a/src/de/blinkt/openvpn/fragments/FileSelectionFragment.java
+++ b/src/de/blinkt/openvpn/fragments/FileSelectionFragment.java
@@ -152,11 +152,11 @@ public class FileSelectionFragment extends ListFragment {
if (!currentPath.equals(ROOT)) {
item.add(ROOT);
- addItem(ROOT, R.drawable.folder);
+ addItem(ROOT, R.drawable.ic_root_folder_am);
path.add(ROOT);
item.add("../");
- addItem("../", R.drawable.folder);
+ addItem("../", R.drawable.ic_root_folder_am);
path.add(f.getParent());
parentPath = f.getParent();
@@ -204,11 +204,11 @@ public class FileSelectionFragment extends ListFragment {
ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage });
for (String dir : dirsMap.tailMap("").values()) {
- addItem(dir, R.drawable.folder);
+ addItem(dir, R.drawable.ic_root_folder_am);
}
for (String file : filesMap.tailMap("").values()) {
- addItem(file, R.drawable.file);
+ addItem(file, R.drawable.ic_doc_generic_am);
}
fileList.notifyDataSetChanged();
diff --git a/src/de/blinkt/openvpn/fragments/VPNProfileList.java b/src/de/blinkt/openvpn/fragments/VPNProfileList.java
index 4d54bc68..c1587ec0 100644
--- a/src/de/blinkt/openvpn/fragments/VPNProfileList.java
+++ b/src/de/blinkt/openvpn/fragments/VPNProfileList.java
@@ -1,5 +1,6 @@
package de.blinkt.openvpn.fragments;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListFragment;
@@ -8,11 +9,14 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
+import android.os.Parcelable;
import android.text.Html;
import android.text.Html.ImageGetter;
import android.view.*;
import android.view.View.OnClickListener;
+import android.webkit.MimeTypeMap;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.TextView;
@@ -22,6 +26,7 @@ import de.blinkt.openvpn.core.ProfileManager;
import java.util.Collection;
import java.util.Comparator;
+import java.util.Set;
import java.util.TreeSet;
public class VPNProfileList extends ListFragment {
@@ -201,19 +206,43 @@ public class VPNProfileList extends ListFragment {
onAddProfileClicked();
return true;
} else if (itemId == MENU_IMPORT_PROFILE) {
- startImportConfig();
- //startFilePicker();
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
+ startFilePicker();
+ else
+ startImportConfig();
+
return true;
} else {
return super.onOptionsItemSelected(item);
}
}
+ @TargetApi(Build.VERSION_CODES.KITKAT)
private void startFilePicker() {
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
- i.setType("*/*");
- startActivityForResult(i, FILE_PICKER_RESULT);
+ i.setType("application/x-openvpn-profile");
+
+
+ TreeSet<String> supportedMimeTypes = new TreeSet<String>();
+ supportedMimeTypes.add("application/x-openvpn-profile");
+ supportedMimeTypes.add("application/openvpn-profile");
+ supportedMimeTypes.add("application/ovpn");
+
+ MimeTypeMap mtm = MimeTypeMap.getSingleton();
+
+ for(String ext: new String[] {"ovpn", "conf"}) {
+ String mimeType = mtm.getMimeTypeFromExtension(ext);
+ if(mimeType!=null)
+ supportedMimeTypes.add(mimeType);
+ else
+ supportedMimeTypes.add("application/octet-stream");
+ }
+
+
+
+ i.putExtra(Intent.EXTRA_MIME_TYPES, supportedMimeTypes.toArray(new String[supportedMimeTypes.size()]));
+ startActivityForResult(i, FILE_PICKER_RESULT);
}
private void startImportConfig() {
@@ -301,7 +330,7 @@ public class VPNProfileList extends ListFragment {
} else if(requestCode == IMPORT_PROFILE) {
String profileUUID = data.getStringExtra(VpnProfile.EXTRA_PROFILEUUID);
mArrayadapter.add(ProfileManager.get(getActivity(), profileUUID));
- } else if(resultCode == FILE_PICKER_RESULT) {
+ } else if(requestCode == FILE_PICKER_RESULT) {
if (data != null) {
Uri uri = data.getData();
startConfigImport(uri);