summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java17
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java3
2 files changed, 16 insertions, 4 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 b55328a4..dfbbbd30 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -85,6 +85,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
private String mRemoteGW;
private final Object mProcessLock = new Object();
private Handler guiHandler;
+ private Toast mlastToast;
// From: http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java
public static String humanReadableByteCount(long bytes, boolean mbit) {
@@ -180,19 +181,26 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
startForeground(OPENVPN_STATUS, notification);
// Check if running on a TV
- UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
- if(uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
+ if(runningOnAndroidTV() && !lowpriority)
guiHandler.post(new Runnable() {
@Override
public void run() {
+ if (mlastToast!=null)
+ mlastToast.cancel();
String toastText = String.format(Locale.getDefault(), "%s - %s", mProfile.mName, msg);
- Toast.makeText(getBaseContext(), toastText, Toast.LENGTH_SHORT).show();
+ mlastToast = Toast.makeText(getBaseContext(), toastText, Toast.LENGTH_SHORT);
+ mlastToast.show();
}
});
}
+ private boolean runningOnAndroidTV() {
+ UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
+ return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
+ }
+
private int getIconByConnectionStatus(ConnectionStatus level) {
switch (level) {
case LEVEL_CONNECTED:
@@ -874,7 +882,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
} else if (level == LEVEL_CONNECTED) {
mDisplayBytecount = true;
mConnecttime = System.currentTimeMillis();
- lowpriority = true;
+ if (!runningOnAndroidTV())
+ lowpriority = true;
} else {
mDisplayBytecount = false;
}
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 c0f958c4..3ff41eee 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
@@ -98,6 +98,9 @@ public class VpnStatus {
break;
}
+ while(message.endsWith(","))
+ message = message.substring(0, message.length()-1);
+
String prefix = c.getString(mLastStateresid) + ":";
String status = mLaststate;
if (status.equals("NOPROCESS"))