summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-15 13:01:10 +0200
committerParménides GV <parmegv@sdf.org>2015-04-15 13:01:10 +0200
commit106502134068155563f877966e1c5b0edfae2d51 (patch)
tree7685a467593481fbb6bad604cc6a2b327c933911
parent435bf8afa374eab51cc87390db999e28386432b9 (diff)
Wants to disconnect and is connecting work fine.
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java20
2 files changed, 15 insertions, 14 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 02eedd77..bfa67815 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -50,7 +50,6 @@ public class EipFragment extends Fragment implements Observer {
private static Dashboard dashboard;
private static EIPReceiver mEIPReceiver;
private static EipStatus eip_status;
- private boolean is_starting_to_connect;
private boolean wants_to_connect;
public void onAttach(Activity activity) {
@@ -180,7 +179,7 @@ public class EipFragment extends Fragment implements Observer {
public void startEipFromScratch() {
wants_to_connect = false;
- is_starting_to_connect = true;
+ eip_status.setConnecting();
progress_bar.setVisibility(View.VISIBLE);
eip_switch.setVisibility(View.VISIBLE);
String status = dashboard.getString(R.string.eip_status_start_pending);
@@ -269,7 +268,7 @@ public class EipFragment extends Fragment implements Observer {
private void handleNewState(EipStatus eip_status) {
if (eip_status.wantsToDisconnect())
setDisconnectedUI();
- else if (eip_status.isConnecting() || is_starting_to_connect)
+ else if (eip_status.isConnecting())
setInProgressUI(eip_status);
else if (eip_status.isConnected())
setConnectedUI();
@@ -280,7 +279,6 @@ public class EipFragment extends Fragment implements Observer {
private void setConnectedUI() {
hideProgressBar();
adjustSwitch();
- is_starting_to_connect = false;
status_message.setText(dashboard.getString(R.string.eip_state_connected));
}
@@ -296,7 +294,7 @@ public class EipFragment extends Fragment implements Observer {
}
private void adjustSwitch() {
- if (eip_status.isConnected() || eip_status.isConnecting() || is_starting_to_connect) {
+ if (eip_status.isConnected() || eip_status.isConnecting()) {
if (!eip_switch.isChecked()) {
eip_switch.setChecked(true);
}
@@ -315,7 +313,6 @@ public class EipFragment extends Fragment implements Observer {
showProgressBar();
status_message.setText(prefix + " " + logmessage);
- is_starting_to_connect = false;
adjustSwitch();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
index ad68f96e..b7f95277 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
@@ -27,7 +27,10 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
private static EipStatus current_status;
private static VpnStatus.ConnectionStatus level = VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED;
- private static boolean wants_to_disconnect = false;
+ private static boolean
+ wants_to_disconnect = false,
+ is_connecting = false;
+
private String state, log_message;
private int localized_res_id;
@@ -46,9 +49,9 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
@Override
public void updateState(final String state, final String logmessage, final int localizedResId, final VpnStatus.ConnectionStatus level) {
updateStatus(state, logmessage, localizedResId, level);
- if (isConnected() || isDisconnected()) {
+ if (isConnected() || isDisconnected() || wantsToDisconnect()) {
setConnectedOrDisconnected();
- } else if (isConnecting())
+ } else
setConnecting();
}
@@ -66,10 +69,7 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
}
public boolean isConnecting() {
- return
- !isConnected() &&
- !isDisconnected() &&
- !isPaused();
+ return is_connecting;
}
public boolean isConnected() {
@@ -85,19 +85,23 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
}
public void setConnecting() {
+ is_connecting = true;
+
wants_to_disconnect = false;
current_status.setChanged();
current_status.notifyObservers();
}
public void setConnectedOrDisconnected() {
+ is_connecting = false;
wants_to_disconnect = false;
current_status.setChanged();
current_status.notifyObservers();
}
public void setDisconnecting() {
- wants_to_disconnect = false;
+ wants_to_disconnect = true;
+ is_connecting = false;
}
public String getState() {