From f8e6c02a647eade2dbac4411914918408ab435eb Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 30 Apr 2012 18:26:01 +0200 Subject: - new Icon :) - Obscure settings - version 0.4.5 - quick launch --- src/de/blinkt/openvpn/VPNProfileList.java | 100 +++--------------------------- 1 file changed, 7 insertions(+), 93 deletions(-) (limited to 'src/de/blinkt/openvpn/VPNProfileList.java') diff --git a/src/de/blinkt/openvpn/VPNProfileList.java b/src/de/blinkt/openvpn/VPNProfileList.java index bc61dddb..42c881a8 100644 --- a/src/de/blinkt/openvpn/VPNProfileList.java +++ b/src/de/blinkt/openvpn/VPNProfileList.java @@ -5,7 +5,6 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.net.VpnService; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; @@ -13,7 +12,6 @@ import android.preference.PreferenceScreen; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.Toast; import de.blinkt.openvpn.VPNConfigPreference.VpnPreferencesClickListener; @@ -21,7 +19,6 @@ import de.blinkt.openvpn.VPNConfigPreference.VpnPreferencesClickListener; public class VPNProfileList extends PreferenceFragment implements VpnPreferencesClickListener { private static final int MENU_ADD_PROFILE = Menu.FIRST; - private static final int START_VPN_PROFILE= 70; private static final int START_VPN_CONFIG = 92; @@ -59,38 +56,7 @@ public class VPNProfileList extends PreferenceFragment implements VpnPreference } } - private void askForPW(String type) { - final EditText entry = new EditText(getActivity()); - entry.setSingleLine(); - entry.setInputType(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD); - - AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); - dialog.setTitle("Need " + type); - dialog.setMessage("Enter the password for profile " + mSelectedVPN.mName); - dialog.setView(entry); - - dialog.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - String pw = entry.getText().toString(); - mSelectedVPN.mTransientPW = pw; - onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); - - } - - }); - dialog.setNegativeButton(android.R.string.cancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - } - }); - - dialog.create().show(); - - } private void onAddProfileClicked() { Context context = getActivity(); @@ -192,15 +158,7 @@ public class VPNProfileList extends PreferenceFragment implements VpnPreference @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - if(requestCode==START_VPN_PROFILE && resultCode == Activity.RESULT_OK) { - - if(mSelectedVPN.needUserPWInput()!=null) { - askForPW(mSelectedVPN.needUserPWInput()); - } else { - new startOpenVpnThread().start(); - } - - } else if (requestCode == START_VPN_CONFIG && resultCode == Activity.RESULT_OK) { + if (requestCode == START_VPN_CONFIG && resultCode == Activity.RESULT_OK) { String configuredVPN = data.getStringExtra(getActivity().getPackageName() + ".profileUUID"); VpnProfile profile = ProfileManager.get(configuredVPN); @@ -211,41 +169,7 @@ public class VPNProfileList extends PreferenceFragment implements VpnPreference } - private class startOpenVpnThread extends Thread { - - @Override - public void run() { - startOpenVpn(); - } - - void startOpenVpn() { - Intent startLW = new Intent(getActivity().getBaseContext(),LogWindow.class); - startActivity(startLW); - - - OpenVPN.logMessage(0, "", "Building configration..."); - - Intent startVPN = mSelectedVPN.prepareIntent(getActivity()); - - getActivity().startService(startVPN); - getActivity().finish(); - - } - } - - void showConfigErrorDialog(int vpnok) { - - AlertDialog.Builder d = new AlertDialog.Builder(getActivity()); - - d.setTitle(R.string.config_error_found); - - d.setMessage(vpnok); - - d.setPositiveButton("Ok", null); - - d.show(); - } @Override public void onStartVPNClick(VPNConfigPreference preference) { @@ -253,23 +177,13 @@ public class VPNProfileList extends PreferenceFragment implements VpnPreference // Query the System for permission mSelectedVPN = ProfileManager.get(preference.getKey()); - int vpnok = mSelectedVPN.checkProfile(); - if(vpnok!= R.string.no_error_found) { - showConfigErrorDialog(vpnok); - return; - } - - getPM().saveProfile(getActivity(), mSelectedVPN); - Intent intent = VpnService.prepare(getActivity()); - - if (intent != null) { - // Start the query - intent.putExtra("FOO", "WAR BIER"); - startActivityForResult(intent, START_VPN_PROFILE); - } else { - onActivityResult(START_VPN_PROFILE, Activity.RESULT_OK, null); - } + Intent intent = new Intent(getActivity(),LaunchVPN.class); + intent.putExtra(LaunchVPN.EXTRA_KEY, mSelectedVPN.getUUID().toString()); + intent.setAction(Intent.ACTION_MAIN); + startActivity(intent); + + getActivity().finish(); } } -- cgit v1.2.3