summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle2
-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
4 files changed, 23 insertions, 35 deletions
diff --git a/build.gradle b/build.gradle
index 4c697cda..83fc6dc1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
}
}
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