summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/Settings_Authentication.java17
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/Utils.java7
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java20
3 files changed, 30 insertions, 14 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Authentication.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Authentication.java
index 8d6d3835..4d2bd508 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Authentication.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Authentication.java
@@ -27,8 +27,8 @@ import java.io.IOException;
public class Settings_Authentication extends OpenVpnPreferencesFragment implements OnPreferenceChangeListener, OnPreferenceClickListener {
- private static final int SELECT_TLS_FILE = 23223232;
- private static final int SELECT_TLS_FILE_KITKAT = SELECT_TLS_FILE +1;
+ private static final int SELECT_TLS_FILE_LEGACY_DIALOG = 23223232;
+ private static final int SELECT_TLS_FILE_KITKAT = SELECT_TLS_FILE_LEGACY_DIALOG +1;
private CheckBoxPreference mExpectTLSCert;
private CheckBoxPreference mCheckRemoteCN;
private RemoteCNPreference mRemoteCN;
@@ -169,14 +169,17 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen
}
void startFileDialog() {
+ Intent startFC = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- Intent startFC = Utils.getFilePickerIntent (getActivity(), Utils.FileType.TLS_AUTH_FILE);
+ startFC = Utils.getFilePickerIntent(getActivity(), Utils.FileType.TLS_AUTH_FILE);
startActivityForResult(startFC, SELECT_TLS_FILE_KITKAT);
- } else {
- Intent startFC = new Intent(getActivity(), FileSelect.class);
+ }
+
+ if (startFC == null) {
+ startFC = new Intent(getActivity(), FileSelect.class);
startFC.putExtra(FileSelect.START_DATA, mTlsAuthFileData);
startFC.putExtra(FileSelect.WINDOW_TITLE, R.string.tls_auth_file);
- startActivityForResult(startFC, SELECT_TLS_FILE);
+ startActivityForResult(startFC, SELECT_TLS_FILE_LEGACY_DIALOG);
}
}
@@ -190,7 +193,7 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if(requestCode==SELECT_TLS_FILE && resultCode == Activity.RESULT_OK){
+ if(requestCode== SELECT_TLS_FILE_LEGACY_DIALOG && resultCode == Activity.RESULT_OK){
String result = data.getStringExtra(FileSelect.RESULT_DATA);
mTlsAuthFileData=result;
setTlsAuthSummary(result);
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java
index d5ed39a7..c1ae41fc 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java
@@ -120,7 +120,14 @@ public class Utils {
if (!isIntentAvailable(c,i)) {
i.setAction(Intent.ACTION_OPEN_DOCUMENT);
i.setPackage(null);
+
+ // Check for really broken devices ... :(
+ if (!isIntentAvailable(c,i)) {
+ return null;
+ }
}
+
+
/*
final PackageManager packageManager = c.getPackageManager();
ResolveInfo list = packageManager.resolveActivity(i, 0);
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
index 70a2208d..ace03007 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/VPNProfileList.java
@@ -20,7 +20,6 @@ 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;
@@ -44,7 +43,7 @@ public class VPNProfileList extends ListFragment {
private static final int START_VPN_CONFIG = 92;
private static final int SELECT_PROFILE = 43;
private static final int IMPORT_PROFILE = 231;
- private static final int FILE_PICKER_RESULT = 392;
+ private static final int FILE_PICKER_RESULT_KITKAT = 392;
private static final int MENU_IMPORT_PROFILE = Menu.FIRST +1;
@@ -212,9 +211,11 @@ public class VPNProfileList extends ListFragment {
onAddProfileClicked();
return true;
} else if (itemId == MENU_IMPORT_PROFILE) {
+ boolean startOldFileDialog=true;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
- startFilePicker();
- else
+ startOldFileDialog = ! startFilePicker();
+
+ if (startOldFileDialog)
startImportConfig();
return true;
@@ -224,9 +225,14 @@ public class VPNProfileList extends ListFragment {
}
@TargetApi(Build.VERSION_CODES.KITKAT)
- private void startFilePicker() {
+ private boolean startFilePicker() {
+
Intent i = Utils.getFilePickerIntent(getActivity(), Utils.FileType.OVPN_CONFIG);
- startActivityForResult(i, FILE_PICKER_RESULT);
+ if (i!=null) {
+ startActivityForResult(i, FILE_PICKER_RESULT_KITKAT);
+ return true;
+ } else
+ return false;
}
private void startImportConfig() {
@@ -314,7 +320,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(requestCode == FILE_PICKER_RESULT) {
+ } else if(requestCode == FILE_PICKER_RESULT_KITKAT) {
if (data != null) {
Uri uri = data.getData();
startConfigImport(uri);