diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-05-01 00:26:54 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-05-01 00:26:54 +0200 |
commit | f26bdab76d0632aa0f1489c58e9ccc28bf1c74ba (patch) | |
tree | 436cd91b85b5f1f704ea22e041c8d12dfb51ed8f | |
parent | 529dec2494c87181899d3479c5d631f5a84f715e (diff) |
The real 0.4.6 version as being pushed to the market.
adds working clear and disconnect buttons to log window
-rw-r--r-- | AndroidManifest.xml | 6 | ||||
-rw-r--r-- | res/drawable-hdpi/ic_menu_trash_holo_light.png | bin | 0 -> 1001 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_menu_trash_holo_light.png | bin | 0 -> 746 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_menu_trash_holo_light.png | bin | 0 -> 1279 bytes | |||
-rw-r--r-- | res/menu/logmenu.xml | 18 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/LaunchVPN.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/LogWindow.java | 22 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnManagementThread.java | 16 |
9 files changed, 57 insertions, 11 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3541f6c5..5b4bdef8 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -33,10 +33,13 @@ <activity android:name="com.lamerman.FileDialog" /> <activity android:name=".AboutFragment" /> <activity android:name=".VPNPreferences" /> - <activity android:name=".LogWindow" /> + <activity + android:name=".LogWindow" + android:label="OpenVPN Log" /> <activity android:name=".MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> @@ -54,6 +57,7 @@ android:label="@string/vpn_launch_title" > <intent-filter> <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> diff --git a/res/drawable-hdpi/ic_menu_trash_holo_light.png b/res/drawable-hdpi/ic_menu_trash_holo_light.png Binary files differnew file mode 100644 index 00000000..c62295aa --- /dev/null +++ b/res/drawable-hdpi/ic_menu_trash_holo_light.png diff --git a/res/drawable-mdpi/ic_menu_trash_holo_light.png b/res/drawable-mdpi/ic_menu_trash_holo_light.png Binary files differnew file mode 100644 index 00000000..08291855 --- /dev/null +++ b/res/drawable-mdpi/ic_menu_trash_holo_light.png diff --git a/res/drawable-xhdpi/ic_menu_trash_holo_light.png b/res/drawable-xhdpi/ic_menu_trash_holo_light.png Binary files differnew file mode 100644 index 00000000..bd3fd784 --- /dev/null +++ b/res/drawable-xhdpi/ic_menu_trash_holo_light.png diff --git a/res/menu/logmenu.xml b/res/menu/logmenu.xml index 5fcadae0..80331c5e 100644 --- a/res/menu/logmenu.xml +++ b/res/menu/logmenu.xml @@ -1,9 +1,17 @@ <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-<item android:id="@+id/clearlog"
- android:icon="@android:drawable/ic_menu_crop"
- android:title="clear log"
- android:showAsAction="ifRoom"
- />
+
+ <item
+ android:id="@+id/clearlog"
+ android:icon="@drawable/ic_menu_trash_holo_light"
+ android:showAsAction="ifRoom|withText"
+ android:title="@string/clear_log"/>
+
+ <item android:id="@+id/cancel"
+ android:icon="@android:drawable/ic_menu_close_clear_cancel"
+ android:showAsAction="ifRoom|withText"
+ android:title="@string/cancel_connection"
+ />
+
</menu>
\ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 7bc7ab95..28863ab9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -113,4 +113,8 @@ <string name="custom_config_summary">Specify custom options. Use with care!</string> <string name="route_rejected">Route rejected by Android</string> <string formatted="false" name="ip_not_cidr">Cannot make sense of %s and %s as IP and CIDR netmask, assuming P2P for local address (/32)</string> + <string name="cancel_connection">cancel</string> + <string name="clear_log">clear log</string> + <string name="title_cancel">Cancel Confirmation</string> + <string name="cancel_connection_query">Disconnect the connected VPN/cancel the connection attempt?</string> </resources> diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java index 38a3b5d7..2bd647f9 100644 --- a/src/de/blinkt/openvpn/LaunchVPN.java +++ b/src/de/blinkt/openvpn/LaunchVPN.java @@ -255,7 +255,7 @@ 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("Ok", null); + d.setPositiveButton(android.R.string.ok, null); d.show(); } diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java index f6004882..001dbf1f 100644 --- a/src/de/blinkt/openvpn/LogWindow.java +++ b/src/de/blinkt/openvpn/LogWindow.java @@ -2,7 +2,11 @@ package de.blinkt.openvpn; import java.util.Vector; +import android.app.AlertDialog; +import android.app.AlertDialog.Builder; import android.app.ListActivity; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; import android.database.DataSetObserver; import android.os.Bundle; import android.os.Handler; @@ -143,12 +147,14 @@ public class LogWindow extends ListActivity { for (DataSetObserver observer : observers) { observer.onInvalidated(); } - } + } return true; } void clearLog() { + // Actually is probably called from GUI Thread as result of the user + // pressing a button. But better safe than sorry OpenVPN.clearLog(); OpenVPN.logMessage(0,"","Log cleared."); mHandler.sendEmptyMessage(MESSAGE_CLEARLOG); @@ -165,6 +171,20 @@ public class LogWindow extends ListActivity { if(item.getItemId()==R.id.clearlog) { ladapter.clearLog(); return true; + } else if(item.getItemId()==R.id.cancel){ + Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.title_cancel); + builder.setMessage(R.string.cancel_connection_query); + builder.setPositiveButton(android.R.string.yes, new OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + OpenVpnManagementThread.stopOpenVPN(); + } + }); + builder.setNegativeButton(android.R.string.no, null); + builder.show(); + return true; } return super.onOptionsItemSelected(item); diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java index 00d8fe9b..02e5dc46 100644 --- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java @@ -2,6 +2,7 @@ package de.blinkt.openvpn; import java.io.IOException;
import java.io.InputStream;
+import java.util.Vector;
import android.net.LocalSocket;
import android.util.Log;
@@ -11,7 +12,8 @@ public class OpenVpnManagementThread implements Runnable { private static final String TAG = "openvpn";
private LocalSocket mSocket;
private VpnProfile mProfile;
-
+private static Vector<OpenVpnManagementThread> active=new Vector<OpenVpnManagementThread>();
+
public OpenVpnManagementThread(VpnProfile profile, LocalSocket mgmtsocket) {
mProfile = profile;
mSocket = mgmtsocket;
@@ -48,6 +50,7 @@ public class OpenVpnManagementThread implements Runnable { e.printStackTrace();
}
String pendingInput="";
+ active.add(this);
try {
@@ -68,6 +71,7 @@ public class OpenVpnManagementThread implements Runnable { } catch (IOException e) {
e.printStackTrace();
}
+ active.remove(this);
}
@@ -133,8 +137,14 @@ public class OpenVpnManagementThread implements Runnable { private void logStatusMessage(String command) {
- // TODO Auto-generated method stub
-
+ OpenVPN.logMessage(0,"MGMT:", command);
+ }
+
+
+ public static void stopOpenVPN() {
+ for (OpenVpnManagementThread mt: active){
+ mt.managmentCommand("signal SIGINT\n");
+ }
}
}
|