summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2015-12-07 11:10:05 +0100
committerArne Schwabe <arne@rfc2549.org>2015-12-07 11:10:05 +0100
commitc3289433eeb53635dc27a7222e827008e4de645d (patch)
tree17a8dadb3dd649a6f2fbfbf56f7a8cff668cbe7e
parent73de674df39e0974b624a9890bf5419273114f64 (diff)
Use new status message and make connected status a bit nicer
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java3
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java27
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java8
-rwxr-xr-xmain/src/main/res/values/strings.xml2
4 files changed, 35 insertions, 5 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 7637df95..f0c788ee 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -860,7 +860,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
// CONNECTED
// Does not work :(
String msg = getString(resid);
- showNotification(msg + " " + logmessage, msg, lowpriority, 0, level);
+ showNotification(msg + " " + VpnStatus.getCleanLogMessage(level, logmessage),
+ msg, lowpriority, 0, level);
}
}
diff --git a/main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java b/main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
index 78deb7d3..1f866ab7 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
@@ -73,6 +73,33 @@ public class VpnStatus {
private static final int MAXLOGENTRIES = 1000;
+ public static String getCleanLogMessage(ConnectionStatus level, String logMessage) {
+ switch (level) {
+ case LEVEL_CONNECTED:
+ String[] parts = logMessage.split(",");
+ /*
+ (a) the integer unix date/time,
+ (b) the state name,
+ 0 (c) optional descriptive string (used mostly on RECONNECTING
+ and EXITING to show the reason for the disconnect),
+
+ 1 (d) optional TUN/TAP local IPv4 address
+ 2 (e) optional address of remote server,
+ 3 (f) optional port of remote server,
+ 4 (g) optional local address,
+ 5 (h) optional local port, and
+ 6 (i) optional TUN/TAP local IPv6 address.
+*/
+ // Return only the assigned IP addresses in the UI
+ if (parts.length < 7)
+ return logMessage;
+ return String.format(Locale.US, "%s %s", parts[1], parts[6]);
+ default:
+ return logMessage;
+ }
+
+ }
+
public enum ConnectionStatus {
LEVEL_CONNECTED,
LEVEL_VPNPAUSED,
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java b/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
index e1031e33..fb6f8371 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/LogFragment.java
@@ -650,6 +650,8 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar.
@Override
public void updateState(final String status, final String logMessage, final int resId, final ConnectionStatus level) {
if (isAdded()) {
+ final String cleanLogMessage = VpnStatus.getCleanLogMessage(level, logMessage);
+
getActivity().runOnUiThread(new Runnable() {
@Override
@@ -660,9 +662,9 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar.
prefix = "";
if (resId == R.string.unknown_state)
prefix += status;
- if (mSpeedView != null)
- mSpeedView.setText(prefix + logMessage);
-
+ if (mSpeedView != null) {
+ mSpeedView.setText(prefix + cleanLogMessage);
+ }
if (mConnectStatus != null)
mConnectStatus.setText(getString(resId));
}
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
index 5bafcc04..251c1e8e 100755
--- a/main/src/main/res/values/strings.xml
+++ b/main/src/main/res/values/strings.xml
@@ -192,7 +192,7 @@
<string name="warn_no_dns">No DNS servers being used. Name resolution may not work. Consider setting custom DNS Servers. Please also note that Android will keep using your proxy settings specified for your mobile/Wi-Fi connection when no DNS servers are set.</string>
<string name="dns_add_error">Could not add DNS Server \"%1$s\", rejected by the system: %2$s</string>
<string name="ip_add_error">Could not configure IP Address \"%1$s\", rejected by the system: %2$s</string>
- <string name="faq_howto">&lt;p&gt;Get a working config (tested on your computer or download from your provider/organisation)&lt;/p&gt;&lt;p&gt;If it is a single file with no extra pem/pks12 files you can email the file yourself and open the attachment. If you have multiple files put them on your sd card.&lt;/p&gt;&lt;p&gt;Click on the email attachment/Use the folder icon in the vpn list to import the config file&lt;/p&gt;&lt;p&gt;If there are errors about missing files put the missing files on your sd card.&lt;/p&gt;&lt;p&gt;Click on the save symbol to add the imported VPN to your VPN list&lt;/p&gt;&lt;p&gt;Connect the VPN by clicking on the name of the VPN&lt;/p&gt;&lt;p&gt;If there are error or warnings in the log try to understand the warnings/error and try to fix them&lt;/p&gt; </string>
+ <string name="faq_howto">&lt;p&gt;Get a working config (tested on your computer or download from your provider/organisation)&lt;/p&gt;&lt;p&gt;If it is a single file with no extra pem/pkcs12 files you can email the file yourself and open the attachment. If you have multiple files put them on your sd card.&lt;/p&gt;&lt;p&gt;Click on the email attachment/Use the folder icon in the vpn list to import the config file&lt;/p&gt;&lt;p&gt;If there are errors about missing files put the missing files on your sd card.&lt;/p&gt;&lt;p&gt;Click on the save symbol to add the imported VPN to your VPN list&lt;/p&gt;&lt;p&gt;Connect the VPN by clicking on the name of the VPN&lt;/p&gt;&lt;p&gt;If there are error or warnings in the log try to understand the warnings/error and try to fix them&lt;/p&gt; </string>
<string name="faq_howto_title">Quick Start</string>
<string name="setting_loadtun_summary">Try to load the tun.ko kernel module before trying to connect. Needs rooted devices.</string>
<string name="setting_loadtun">Load tun module</string>