summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2016-06-28 15:20:27 +0200
committerArne Schwabe <arne@rfc2549.org>2016-06-28 15:20:27 +0200
commitaba8beb445436ec9eb1e81076a653e7fbe0ca70d (patch)
tree01fefa4f08690fc422e8fb5ec0ba56f0a16834a2 /main/src
parente10b5a4a1771cacf15072cfff90136cf655e12e7 (diff)
More fixes for connection entry.
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/Connection.java20
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java34
-rw-r--r--main/src/main/res/layout/server_card.xml2
3 files changed, 22 insertions, 34 deletions
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<ConnectionsAdapter.
mConnectSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser) {
+ if (fromUser && mConnection != null) {
mConnectText.setText(String.valueOf(progress));
mConnection.mConnectTimeout = progress;
}
@@ -202,26 +202,6 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
);
- mConnectSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser && mConnection!=null) {
- mConnectText.setText(String.valueOf(progress));
- mConnection.mConnectTimeout = progress;
- }
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
-
- }
- });
-
}
@@ -270,12 +250,10 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
cH.mPortNumberView.setText(connection.mServerPort);
cH.mRemoteSwitch.setChecked(connection.mEnabled);
- if (connection.mConnectTimeout == 0) {
- cH.mConnectText.setText("");
- } else {
- cH.mConnectText.setText(String.valueOf(connection.mConnectTimeout));
- }
- cH.mConnectSlider.setProgress(connection.mConnectTimeout);
+
+ cH.mConnectText.setText(String.valueOf(connection.getTimeout()));
+
+ cH.mConnectSlider.setProgress(connection.getTimeout());
cH.mProtoGroup.check(connection.mUseUdp ? R.id.udp_proto : R.id.tcp_proto);
@@ -284,7 +262,7 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
cH.mCustomOptionText.setText(connection.mCustomConfiguration);
cH.mCustomOptionCB.setChecked(connection.mUseCustomConfig);
- cH.mConnection=connection;
+ cH.mConnection = connection;
}
diff --git a/main/src/main/res/layout/server_card.xml b/main/src/main/res/layout/server_card.xml
index eaedcf58..acc07409 100644
--- a/main/src/main/res/layout/server_card.xml
+++ b/main/src/main/res/layout/server_card.xml
@@ -170,6 +170,8 @@
android:layout_alignParentEnd="true"
android:layout_below="@+id/connect_timeout_label"
android:ems="3"
+ tools:text="232"
+ android:gravity="end"
android:inputType="numberDecimal" />
<SeekBar