diff options
-rw-r--r-- | res/layout/vpn_list_item.xml | 5 | ||||
-rw-r--r-- | res/layout/vpn_preference_layout.xml | 94 | ||||
-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 |
9 files changed, 60 insertions, 217 deletions
diff --git a/res/layout/vpn_list_item.xml b/res/layout/vpn_list_item.xml index dc6254e..75da3cf 100644 --- a/res/layout/vpn_list_item.xml +++ b/res/layout/vpn_list_item.xml @@ -19,11 +19,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" - android:focusable="false" android:minHeight="?android:attr/listPreferredItemHeight" > <LinearLayout - android:id="@+id/vpnconfig_pref" + android:id="@+id/vpn_list_item_left" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" @@ -52,6 +51,7 @@ android:layout_width="2dip" android:layout_height="match_parent" android:layout_marginBottom="5dip" + android:focusable="false" android:layout_marginTop="5dip" android:background="@android:drawable/divider_horizontal_dark" /> @@ -60,7 +60,6 @@ android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="center" - android:focusable="true" android:background="?android:attr/selectableItemBackground" android:contentDescription="@string/configure_the_vpn" android:paddingLeft="15dip" diff --git a/res/layout/vpn_preference_layout.xml b/res/layout/vpn_preference_layout.xml deleted file mode 100644 index fbb1811..0000000 --- a/res/layout/vpn_preference_layout.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2011 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center_vertical" - android:minHeight="?android:attr/listPreferredItemHeight" > - - <LinearLayout - android:id="@+id/vpnconfig_pref" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="?android:attr/selectableItemBackground" - android:clickable="true" - android:focusable="true" - android:gravity="center_vertical" > - - <LinearLayout - android:id="@android:id/widget_frame" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:gravity="center_vertical" - android:orientation="vertical" /> - - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="6dip" - android:layout_marginRight="6dip" - android:layout_marginTop="6dip" - android:layout_weight="1" > - - <TextView - android:id="@+android:id/title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:ellipsize="marquee" - android:fadingEdge="horizontal" - android:singleLine="true" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <TextView - android:id="@android:id/summary" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignLeft="@android:id/title" - android:layout_below="@android:id/title" - android:focusable="false" - android:maxLines="4" - android:paddingBottom="3dip" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textColor="?android:attr/textColorSecondary" - android:textSize="13sp" - android:visibility="gone" /> - </RelativeLayout> - </LinearLayout> - - <View - android:layout_width="2dip" - android:layout_height="match_parent" - android:layout_marginBottom="5dip" - android:layout_marginTop="5dip" - android:background="@android:drawable/divider_horizontal_dark" /> - - <ImageView - android:id="@+id/quickedit_settings" - android:layout_width="wrap_content" - android:layout_height="fill_parent" - android:layout_gravity="center" - android:background="?android:attr/selectableItemBackground" - android:clickable="true" - android:contentDescription="@string/configure_the_vpn" - android:focusable="true" - android:paddingLeft="15dip" - android:paddingRight="?android:attr/scrollbarSize" - android:src="@drawable/ic_sysbar_quicksettings" /> - -</LinearLayout>
\ No newline at end of file diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java index e0832f2..d74834c 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 86bd366..daa2971 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 19f8d7e..f05f58d 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 7eb224a..ad58a77 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 d1a3346..0000000 --- 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 56cc7ae..a578251 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 18fe59d..31f32f8 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) |