diff options
author | Sean Leonard <meanderingcode@aetherislands.net> | 2013-11-15 13:04:35 -0800 |
---|---|---|
committer | Sean Leonard <meanderingcode@aetherislands.net> | 2013-11-15 13:04:35 -0800 |
commit | 42d075e993fc345b7684ed4e0e89b732563f7a0c (patch) | |
tree | 9133c29cb27e8e3e0acc0a7fa81d2758589ed523 | |
parent | a95cc0fc7c364e60f2d82dd9ef6749c30a3b229f (diff) | |
parent | d0f6818f93a3978647336191aa104325879cfa13 (diff) |
Merge branch 'feature/disconnect-notification-icon' into develop
-rw-r--r-- | res/drawable-hdpi/ic_vpn_disconnected.png | bin | 0 -> 801 bytes | |||
-rw-r--r-- | res/drawable-ldpi/ic_vpn_disconnected.png | bin | 0 -> 455 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_vpn_disconnected.png | bin | 0 -> 586 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_vpn_disconnected.png | bin | 0 -> 1091 bytes | |||
-rwxr-xr-x | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/EipServiceFragment.java | 12 | ||||
-rw-r--r-- | src/se/leap/openvpn/OpenVpnService.java | 26 |
7 files changed, 27 insertions, 14 deletions
diff --git a/res/drawable-hdpi/ic_vpn_disconnected.png b/res/drawable-hdpi/ic_vpn_disconnected.png Binary files differnew file mode 100644 index 00000000..dfb962b9 --- /dev/null +++ b/res/drawable-hdpi/ic_vpn_disconnected.png diff --git a/res/drawable-ldpi/ic_vpn_disconnected.png b/res/drawable-ldpi/ic_vpn_disconnected.png Binary files differnew file mode 100644 index 00000000..22f3497e --- /dev/null +++ b/res/drawable-ldpi/ic_vpn_disconnected.png diff --git a/res/drawable-mdpi/ic_vpn_disconnected.png b/res/drawable-mdpi/ic_vpn_disconnected.png Binary files differnew file mode 100644 index 00000000..f8b02bfb --- /dev/null +++ b/res/drawable-mdpi/ic_vpn_disconnected.png diff --git a/res/drawable-xhdpi/ic_vpn_disconnected.png b/res/drawable-xhdpi/ic_vpn_disconnected.png Binary files differnew file mode 100644 index 00000000..7f44c46f --- /dev/null +++ b/res/drawable-xhdpi/ic_vpn_disconnected.png diff --git a/res/values/strings.xml b/res/values/strings.xml index 8281be25..91e72a60 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -321,5 +321,6 @@ <string name="eip_cancel_connect_text">There is a connection attempt in progress. Do you wish to cancel it?</string> <string name="eip_cancel_connect_cancel">Yes</string> <string name="eip_cancel_connect_false">No</string> - + <string name="eip_state_not_connected">"Not running! Connection not secure!"</string> + <string name="eip_state_connected">Connection Secure.</string> </resources> diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java index daf446a5..1b2cfb20 100644 --- a/src/se/leap/bitmaskclient/EipServiceFragment.java +++ b/src/se/leap/bitmaskclient/EipServiceFragment.java @@ -132,6 +132,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli @Override public void onClick(DialogInterface dialog, int which) { eipCommand(EIP.ACTION_STOP_EIP); + mEipStartPending = false; } }) .setNegativeButton(getResources().getString(R.string.eip_cancel_connect_false), new DialogInterface.OnClickListener() { @@ -177,18 +178,21 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli String statusMessage = ""; String prefix = getString(localizedResId); if (state.equals("CONNECTED")){ - statusMessage = "Connection Secure"; + statusMessage = getString(R.string.eip_state_connected); getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE); mEipStartPending = false; } else if (state.equals("BYTECOUNT")) { statusMessage = logmessage; } else if ( (state.equals("NOPROCESS") && !mEipStartPending ) || state.equals("EXITING")) { - statusMessage = "Not running! Connection not secure!"; + statusMessage = getString(R.string.eip_state_not_connected); getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE); mEipStartPending = false; switchState = false; - } else { - statusMessage = prefix + logmessage; + } else if (state.equals("NOPROCESS")){ + statusMessage = logmessage; + } + else { + statusMessage = prefix + " " + logmessage; } eipAutoSwitched = true; diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java index bec7dcee..620de204 100644 --- a/src/se/leap/openvpn/OpenVpnService.java +++ b/src/se/leap/openvpn/OpenVpnService.java @@ -7,7 +7,6 @@ import java.util.Vector; import se.leap.bitmaskclient.Dashboard; import se.leap.bitmaskclient.R; - import android.annotation.TargetApi; import android.app.Notification; import android.app.NotificationManager; @@ -103,12 +102,16 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac } } - private void showNotification(String msg, String tickerText, boolean lowpriority, long when, boolean persistant) { + private void showNotification(String state, String msg, String tickerText, boolean lowpriority, long when, boolean persistant) { String ns = Context.NOTIFICATION_SERVICE; mNotificationManager = (NotificationManager) getSystemService(ns); - - - int icon = R.drawable.ic_stat_vpn; + int icon; + if (state.equals("NOPROCESS") || state.equals("AUTH_FAILED") || state.equals("NONETWORK")){ + icon = R.drawable.ic_vpn_disconnected; + }else{ + icon = R.drawable.ic_stat_vpn; + } + android.app.Notification.Builder nbuilder = new Notification.Builder(this); nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName)); @@ -465,8 +468,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac // If the process is not running, ignore any state, // Notification should be invisible in this state if(mProcessThread==null) - return; - + return; if("CONNECTED".equals(state)) { mNotificationManager.cancel(OPENVPN_STATUS); } else if(!"BYTECOUNT".equals(state)) { @@ -475,8 +477,14 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac // This also mean we are no longer connected, ignore bytecount messages until next // CONNECTED String ticker = getString(resid); - boolean persist = ("NOPROCESS".equals(state)) ? false : true; - showNotification(getString(resid) +" " + logmessage,ticker,false,0,persist); + boolean persist = false; + if (("NOPROCESS".equals(state) ) || ("EXIT").equals(state)){ + showNotification(state, getString(R.string.eip_state_not_connected), ticker, false, 0, persist); + } + else{ + persist = true; + showNotification(state, getString(resid) +" " + logmessage,ticker,false,0,persist); + } } } |