From aba8beb445436ec9eb1e81076a653e7fbe0ca70d Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 28 Jun 2016 15:20:27 +0200 Subject: More fixes for connection entry. --- .../java/de/blinkt/openvpn/core/Connection.java | 20 +++++++++---- .../openvpn/fragments/ConnectionsAdapter.java | 34 ++++------------------ main/src/main/res/layout/server_card.xml | 2 ++ 3 files changed, 22 insertions(+), 34 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/de/blinkt/openvpn/core/Connection.java b/main/src/main/java/de/blinkt/openvpn/core/Connection.java index 3455450b..04a5f6f0 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/Connection.java +++ b/main/src/main/java/de/blinkt/openvpn/core/Connection.java @@ -13,16 +13,17 @@ public class Connection implements Serializable, Cloneable { public String mServerName = "openvpn.blinkt.de"; public String mServerPort = "1194"; public boolean mUseUdp = true; - public String mCustomConfiguration=""; - public boolean mUseCustomConfig=false; - public boolean mEnabled=true; + public String mCustomConfiguration = ""; + public boolean mUseCustomConfig = false; + public boolean mEnabled = true; public int mConnectTimeout = 0; + public static final int CONNECTION_DEFAULT_TIMEOUT = 120; private static final long serialVersionUID = 92031902903829089L; public String getConnectionBlock() { - String cfg=""; + String cfg = ""; // Server Address cfg += "remote "; @@ -34,8 +35,8 @@ public class Connection implements Serializable, Cloneable { else cfg += " tcp-client\n"; - if (mConnectTimeout!=0) - cfg += String.format(" connect-timeout %d\n" , mConnectTimeout); + if (mConnectTimeout != 0) + cfg += String.format(" connect-timeout %d\n", mConnectTimeout); if (!TextUtils.isEmpty(mCustomConfiguration) && mUseCustomConfig) { @@ -53,4 +54,11 @@ public class Connection implements Serializable, Cloneable { public boolean isOnlyRemote() { return TextUtils.isEmpty(mCustomConfiguration) || !mUseCustomConfig; } + + public int getTimeout() { + if (mConnectTimeout <= 0) + return CONNECTION_DEFAULT_TIMEOUT; + else + return mConnectTimeout; + } } diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java index 5b070b63..af071d37 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java @@ -152,7 +152,7 @@ public class ConnectionsAdapter extends RecyclerView.Adapter