diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-05-04 22:28:20 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-05-04 22:28:20 +0200 |
commit | d4f8b628995e6711ec653360e4b89edef912e3ae (patch) | |
tree | 6d6d188189b617b84d990b0e476a52234f0da943 /src/de/blinkt | |
parent | 3a1284b0635257df99840614c153e23ff3d99e80 (diff) |
Version 0.4.7 :)
Diffstat (limited to 'src/de/blinkt')
-rw-r--r-- | src/de/blinkt/openvpn/LaunchVPN.java | 12 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVPN.java | 1 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnManagementThread.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/Settings_Basic.java | 8 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VPNConfigPreference.java | 72 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VPNProfileList.java | 77 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VpnProfile.java | 6 |
7 files changed, 58 insertions, 120 deletions
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java index e0832f21..d74834ca 100644 --- a/src/de/blinkt/openvpn/LaunchVPN.java +++ b/src/de/blinkt/openvpn/LaunchVPN.java @@ -24,6 +24,7 @@ import android.app.AlertDialog; import android.app.ListActivity; import android.content.ActivityNotFoundException; import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.net.VpnService; import android.os.Bundle; @@ -263,13 +264,18 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener { AlertDialog.Builder d = new AlertDialog.Builder(this); d.setTitle(R.string.config_error_found); d.setMessage(vpnok); - d.setPositiveButton(android.R.string.ok, null); + d.setPositiveButton(android.R.string.ok, new OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + + } + }); d.show(); } void launchVPN () { - - int vpnok = mSelectedProfile.checkProfile(); if(vpnok!= R.string.no_error_found) { showConfigErrorDialog(vpnok); diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 86bd3665..daa29717 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -3,7 +3,6 @@ package de.blinkt.openvpn; import java.util.LinkedList; import java.util.Vector; -import android.os.ParcelFileDescriptor; import android.util.Log; public class OpenVPN { diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java index 19f8d7e5..f05f58dc 100644 --- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java @@ -3,11 +3,9 @@ package de.blinkt.openvpn; import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
-import java.net.DatagramSocket;
import java.util.Vector;
import android.net.LocalSocket;
-import android.os.ParcelFileDescriptor;
import android.util.Log;
public class OpenVpnManagementThread implements Runnable {
diff --git a/src/de/blinkt/openvpn/Settings_Basic.java b/src/de/blinkt/openvpn/Settings_Basic.java index 7eb224a8..ad58a778 100644 --- a/src/de/blinkt/openvpn/Settings_Basic.java +++ b/src/de/blinkt/openvpn/Settings_Basic.java @@ -281,8 +281,12 @@ public class Settings_Basic extends Fragment implements View.OnClickListener, On showCertDialog(); } } - - + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(getActivity().getPackageName() + "profileUUID", mProfile.getUUID().toString()); + } @Override public void onNothingSelected(AdapterView<?> parent) { diff --git a/src/de/blinkt/openvpn/VPNConfigPreference.java b/src/de/blinkt/openvpn/VPNConfigPreference.java deleted file mode 100644 index d1a3346e..00000000 --- a/src/de/blinkt/openvpn/VPNConfigPreference.java +++ /dev/null @@ -1,72 +0,0 @@ -package de.blinkt.openvpn; - -import android.preference.Preference; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ImageView; - -public class VPNConfigPreference extends Preference implements OnClickListener { - class startClickListener implements OnClickListener{ - private VPNConfigPreference mvp; - - public startClickListener(VPNConfigPreference vp) { - mvp = vp; - } - - @Override - public void onClick(View v) { - mOnQuickSettingsListener.onStartVPNClick(mvp); - } - - } - - private VpnPreferencesClickListener mOnQuickSettingsListener; - private ImageView mQuickPrefButton; - - - public VPNConfigPreference(VPNProfileList vpnProfileList) { - super(vpnProfileList.getActivity()); - setLayoutResource(R.layout.vpn_preference_layout); - - } - - private View mProfilesPref; - - @Override - protected void onBindView(View view) { - super.onBindView(view); - mProfilesPref = view.findViewById(R.id.vpnconfig_pref); - mProfilesPref.setOnClickListener(new startClickListener(this)); - mProfilesPref.setClickable(true); - - mQuickPrefButton = (ImageView) view.findViewById(R.id.quickedit_settings); - mQuickPrefButton.setOnClickListener(this); - - } - - - public interface VpnPreferencesClickListener { - /** - * Called when a Preference has been clicked. - * - * @param preference The Preference that was clicked. - * @return True if the click was handled. - */ - boolean onQuickSettingsClick(Preference preference); - - void onStartVPNClick(VPNConfigPreference vpnConfigPreference); - } - - - - public void setOnQuickSettingsClickListener(VpnPreferencesClickListener onQuickSettingsListener) { - mOnQuickSettingsListener = onQuickSettingsListener; - } - - @Override - public void onClick(View v) { - mOnQuickSettingsListener.onQuickSettingsClick(this); - } - - -} diff --git a/src/de/blinkt/openvpn/VPNProfileList.java b/src/de/blinkt/openvpn/VPNProfileList.java index 56cc7ae1..a578251c 100644 --- a/src/de/blinkt/openvpn/VPNProfileList.java +++ b/src/de/blinkt/openvpn/VPNProfileList.java @@ -12,9 +12,8 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.AdapterView.OnItemLongClickListener; +import android.view.View.OnClickListener; +import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; @@ -26,9 +25,42 @@ public class VPNProfileList extends ListFragment { public VPNArrayAdapter(Context context, int resource, int textViewResourceId) { super(context, resource, textViewResourceId); - + } + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + View v = super.getView(position, convertView, parent); + + View titleview = v.findViewById(R.id.vpn_list_item_left); + titleview.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + VpnProfile profile =(VpnProfile) getListAdapter().getItem(position); + startVPN(profile); + } + }); + + View settingsview = v.findViewById(R.id.quickedit_settings); + settingsview.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + if (mActionMode != null) { + return; + } + + // Start the CAB using the ActionMode.Callback defined above + mActionMode = getActivity().startActionMode(mActionModeCallback); + mEditProfile =(VpnProfile) getListAdapter().getItem(position); + + } + }); + + + return v; } + } @@ -56,46 +88,15 @@ public class VPNProfileList extends ListFragment { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - ListView lv = getListView(); - lv.setOnItemLongClickListener(new OnItemLongClickListener() { - - // Called when the user long-clicks on someView - - @Override - public boolean onItemLongClick(AdapterView<?> parent, View view, - int position, long id) { - if (mActionMode != null) { - return false; - } - - // Start the CAB using the ActionMode.Callback defined above - mActionMode = getActivity().startActionMode(mActionModeCallback); - mEditProfile =(VpnProfile) getListAdapter().getItem(position); - - //getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); - //getListView().setSelection(position); - return true; - } - }); - lv.setOnItemClickListener(new OnItemClickListener() { - - @Override - public void onItemClick(AdapterView<?> parent, View view, - int position, long id) { - VpnProfile profile =(VpnProfile) getListAdapter().getItem(position); - startVPN(profile); - } - }); - - -// mArrayadapter = new ArrayAdapter<VpnProfile>(getActivity(),R.layout.vpn_list_item,R.id.vpn_item_title); - mArrayadapter = new ArrayAdapter<VpnProfile>(getActivity(),android.R.layout.simple_list_item_activated_1); + mArrayadapter = new VPNArrayAdapter(getActivity(),R.layout.vpn_list_item,R.id.vpn_item_title); mArrayadapter.addAll(getPM().getProfiles()); setListAdapter(mArrayadapter); } + + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.add(0, MENU_ADD_PROFILE, 0, R.string.menu_add_profile) diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 18fe59d5..31f32f85 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -180,11 +180,13 @@ public class VpnProfile implements Serializable{ cfg += " unix\n"; cfg += "management-hold\n\n"; - cfg+="# tmp does not exist on Android\n"; + /* only needed if client is compiled with P2MP Server support as early version + * accidently were + cfg+="# /tmp does not exist on Android\n"; cfg+="tmp-dir "; cfg+=cacheDir.getAbsolutePath(); cfg+="\n\n"; - + */ boolean useTLSClient = (mAuthenticationType != TYPE_STATICKEYS); if(useTLSClient && mUsePull) |