From 4817f11cb0181f66e3724404b391706d09829b3c Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 21 Nov 2013 06:53:01 +0100 Subject: Fix lints warnings, change folder icons --- .../blinkt/openvpn/fragments/Settings_Basic.java | 8 +++-- .../blinkt/openvpn/fragments/VPNProfileList.java | 39 ++++++++++++---------- 2 files changed, 27 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/de/blinkt/openvpn/fragments/Settings_Basic.java b/src/de/blinkt/openvpn/fragments/Settings_Basic.java index 88941bea..a559cda2 100644 --- a/src/de/blinkt/openvpn/fragments/Settings_Basic.java +++ b/src/de/blinkt/openvpn/fragments/Settings_Basic.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.AlertDialog.Builder; @@ -88,9 +89,10 @@ public class Settings_Basic extends Fragment implements View.OnClickListener, On X509Certificate cert = KeyChain.getCertificateChain(getActivity(), mProfile.mAlias)[0]; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - String algorithm= KeyChain.getPrivateKey(getActivity(),mProfile.mAlias).getAlgorithm(); - if (KeyChain.isBoundKeyAlgorithm(algorithm)) - certstr+=getString(R.string.hwkeychain); + String algorithm= KeyChain.getPrivateKey(getActivity(),mProfile.mAlias).getAlgorithm(); + if (KeyChain.isBoundKeyAlgorithm(algorithm)) + certstr+=getString(R.string.hwkeychain); + } certstr+=X509Utils.getCertificateFriendlyName(cert); diff --git a/src/de/blinkt/openvpn/fragments/VPNProfileList.java b/src/de/blinkt/openvpn/fragments/VPNProfileList.java index 447ed1e0..4d54bc68 100644 --- a/src/de/blinkt/openvpn/fragments/VPNProfileList.java +++ b/src/de/blinkt/openvpn/fragments/VPNProfileList.java @@ -201,8 +201,8 @@ public class VPNProfileList extends ListFragment { onAddProfileClicked(); return true; } else if (itemId == MENU_IMPORT_PROFILE) { - //startImportConfig(); - startFilePicker(); + startImportConfig(); + //startFilePicker(); return true; } else { return super.onOptionsItemSelected(item); @@ -212,8 +212,8 @@ public class VPNProfileList extends ListFragment { private void startFilePicker() { Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT); i.addCategory(Intent.CATEGORY_OPENABLE); - i.setType("application/x-openvpn-profile"); - startActivityForResult(i,FILE_PICKER_RESULT); + i.setType("*/*"); + startActivityForResult(i, FILE_PICKER_RESULT); } private void startImportConfig() { @@ -261,7 +261,6 @@ public class VPNProfileList extends ListFragment { } - private void addProfile(VpnProfile profile) { getPM().addProfile(profile); getPM().saveProfileList(getActivity()); @@ -269,10 +268,6 @@ public class VPNProfileList extends ListFragment { mArrayadapter.add(profile); } - - - - private ProfileManager getPM() { return ProfileManager.getInstance(getActivity()); } @@ -299,21 +294,31 @@ public class VPNProfileList extends ListFragment { setListAdapter(); } else if(requestCode== SELECT_PROFILE) { - String filedata = data.getStringExtra(FileSelect.RESULT_DATA); - Intent startImport = new Intent(getActivity(),ConfigConverter.class); - startImport.setAction(ConfigConverter.IMPORT_PROFILE); - Uri uri = new Uri.Builder().path(filedata).scheme("file").build(); - startImport.setData(uri); - startActivityForResult(startImport, IMPORT_PROFILE); + String fileData = data.getStringExtra(FileSelect.RESULT_DATA); + Uri uri = new Uri.Builder().path(fileData).scheme("file").build(); + + startConfigImport(uri); } else if(requestCode == IMPORT_PROFILE) { String profileUUID = data.getStringExtra(VpnProfile.EXTRA_PROFILEUUID); mArrayadapter.add(ProfileManager.get(getActivity(), profileUUID)); - } + } else if(resultCode == FILE_PICKER_RESULT) { + if (data != null) { + Uri uri = data.getData(); + startConfigImport(uri); + } + } } + private void startConfigImport(Uri uri) { + Intent startImport = new Intent(getActivity(),ConfigConverter.class); + startImport.setAction(ConfigConverter.IMPORT_PROFILE); + startImport.setData(uri); + startActivityForResult(startImport, IMPORT_PROFILE); + } + - private void editVPN(VpnProfile profile) { + private void editVPN(VpnProfile profile) { mEditProfile =profile; Intent vprefintent = new Intent(getActivity(),VPNPreferences.class) .putExtra(getActivity().getPackageName() + ".profileUUID", profile.getUUID().toString()); -- cgit v1.2.3