summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-04-02 17:08:32 +0200
committerParménides GV <parmegv@sdf.org>2014-04-02 17:08:32 +0200
commit4335ef38d5ce8040eca2a6bace5f2e4ae8a179e5 (patch)
tree15918e1f56ff9c0d60895da93c135e23065f04a9 /src/se/leap/bitmaskclient
parent6cb654d169c62653d652009d3c8de51ca877e38b (diff)
Eip switch turns off accordingly to log in state.
Diffstat (limited to 'src/se/leap/bitmaskclient')
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java8
-rw-r--r--src/se/leap/bitmaskclient/EipServiceFragment.java21
-rw-r--r--src/se/leap/bitmaskclient/LogInDialog.java20
3 files changed, 41 insertions, 8 deletions
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index b8d76f87..b388b84a 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -55,7 +55,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
protected static final int CONFIGURE_LEAP = 0;
protected static final int SWITCH_PROVIDER = 1;
- private static final String TAG_EIP_FRAGMENT = "EIP_DASHBOARD_FRAGMENT";
final public static String SHARED_PREFERENCES = "LEAPPreferences";
final public static String ACTION_QUIT = "quit";
public static final String REQUEST_CODE = "request_code";
@@ -168,7 +167,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
FragmentManager fragMan = getFragmentManager();
if ( provider.hasEIP()){
EipServiceFragment eipFragment = new EipServiceFragment();
- fragMan.beginTransaction().replace(R.id.servicesCollection, eipFragment, TAG_EIP_FRAGMENT).commit();
+ fragMan.beginTransaction().replace(R.id.servicesCollection, eipFragment, EipServiceFragment.TAG).commit();
}
}
@@ -264,6 +263,11 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
//mProgressBar.setMax(4);
startService(provider_API_command);
}
+
+ public void cancelAuthedEipOn() {
+ EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG);
+ eipFragment.checkEipSwitch(false);
+ }
/**
* Asks ProviderAPI to log out.
diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java
index bae1b942..ab4f9a5c 100644
--- a/src/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/src/se/leap/bitmaskclient/EipServiceFragment.java
@@ -26,7 +26,7 @@ import android.widget.TextView;
public class EipServiceFragment extends Fragment implements StateListener, OnCheckedChangeListener {
- private static final String IS_EIP_PENDING = "is_eip_pending";
+ protected static final String IS_EIP_PENDING = "is_eip_pending";
private View eipFragment;
private static Switch eipSwitch;
@@ -37,6 +37,8 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
private boolean mEipStartPending = false;
+ private boolean set_switch_off = false;
+
private static EIPReceiver mEIPReceiver;
@@ -90,8 +92,16 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
super.onResume();
OpenVPN.addStateListener(this);
+ if(set_switch_off) {
+ eipSwitch.setChecked(false);
+ set_switch_off = false;
+ }
}
+ protected void setSwitchOff(boolean value) {
+ set_switch_off = value;
+ }
+
@Override
public void onPause() {
super.onPause();
@@ -145,7 +155,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
}
else {
Dashboard dashboard = (Dashboard)getActivity();
- dashboard.logInDialog(getActivity().getCurrentFocus(), Bundle.EMPTY);
+ Bundle waiting_on_login = new Bundle();
+ waiting_on_login.putBoolean(IS_EIP_PENDING, true);
+ dashboard.logInDialog(getActivity().getCurrentFocus(), waiting_on_login);
}
}
eipAutoSwitched = true;
@@ -282,4 +294,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe
public static boolean isEipSwitchChecked() {
return eipSwitch.isChecked();
}
+
+ public void checkEipSwitch(boolean checked) {
+ eipSwitch.setChecked(checked);
+ onCheckedChanged(eipSwitch, checked);
+ }
}
diff --git a/src/se/leap/bitmaskclient/LogInDialog.java b/src/se/leap/bitmaskclient/LogInDialog.java
index 81a3f764..a28c9049 100644
--- a/src/se/leap/bitmaskclient/LogInDialog.java
+++ b/src/se/leap/bitmaskclient/LogInDialog.java
@@ -51,7 +51,8 @@ public class LogInDialog extends DialogFragment {
final public static String PASSWORD = "password";
final public static String USERNAME_MISSING = "username missing";
final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length";
-
+
+ private static boolean is_eip_pending = false;
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
@@ -79,8 +80,11 @@ public class LogInDialog extends DialogFragment {
password_field.requestFocus();
}
if (getArguments() != null && getArguments().containsKey(PASSWORD_INVALID_LENGTH)) {
- password_field.setError(getResources().getString(R.string.error_not_valid_password_user_message));
- }
+ password_field.setError(getResources().getString(R.string.error_not_valid_password_user_message));
+ }
+ if(getArguments() != null && getArguments().getBoolean(EipServiceFragment.IS_EIP_PENDING, false)) {
+ is_eip_pending = true;
+ }
builder.setView(log_in_dialog_view)
@@ -113,7 +117,8 @@ public class LogInDialog extends DialogFragment {
* @param username
* @param password
*/
- public void authenticate(String username, String password);
+ public void authenticate(String username, String password);
+ public void cancelAuthedEipOn();
}
LogInDialogInterface interface_with_Dashboard;
@@ -136,4 +141,11 @@ public class LogInDialog extends DialogFragment {
+ " must implement LogInDialogListener");
}
}
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if(is_eip_pending)
+ interface_with_Dashboard.cancelAuthedEipOn();
+ super.onCancel(dialog);
+ }
}