From 1baf6675aaeea3aee46f3e2d2709ab2bc9579113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 24 Mar 2014 19:37:25 +0100 Subject: Prompt to login if no anon and no existing cert. Now we need to turn on eip if the log in dialog was triggered by the eip switch. --- src/se/leap/bitmaskclient/EipServiceFragment.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java index 0534838d..c2849bbd 100644 --- a/src/se/leap/bitmaskclient/EipServiceFragment.java +++ b/src/se/leap/bitmaskclient/EipServiceFragment.java @@ -108,6 +108,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (buttonView.equals(eipSwitch) && !eipAutoSwitched){ + boolean allowed_anon = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).getBoolean(EIP.ALLOWED_ANON, false); + String certificate = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).getString(EIP.CERTIFICATE, ""); + if(allowed_anon || !certificate.isEmpty()) { if (isChecked){ mEipStartPending = true; eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE); @@ -139,6 +142,11 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe eipCommand(EIP.ACTION_STOP_EIP); } } + } + else { + Dashboard dashboard = (Dashboard)getActivity(); + dashboard.logInDialog(getActivity().getCurrentFocus(), Bundle.EMPTY); + } } eipAutoSwitched = true; } -- cgit v1.2.3 From 1790250865f8c017745591f4d35823d33d62047f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 24 Mar 2014 20:20:41 +0100 Subject: After logging in, eip starts. Now we need to start eip only if the eip switch is on. --- src/se/leap/bitmaskclient/Dashboard.java | 9 +++++++++ src/se/leap/bitmaskclient/EipServiceFragment.java | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index aa3cd4d9..4ad6d029 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -375,6 +375,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf setResult(RESULT_OK); changeStatusMessage(resultCode); mProgressBar.setVisibility(ProgressBar.GONE); + eipStart(); } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) { setResult(RESULT_CANCELED); changeStatusMessage(resultCode); @@ -462,4 +463,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf startService(eip_intent); } + + private void eipStart(){ + Intent eip_intent = new Intent(this, EIP.class); + eip_intent.setAction(EIP.ACTION_START_EIP); + eip_intent.putExtra(EIP.RECEIVER_TAG, EipServiceFragment.getReceiver()); + startService(eip_intent); + + } } diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java index c2849bbd..318e4024 100644 --- a/src/se/leap/bitmaskclient/EipServiceFragment.java +++ b/src/se/leap/bitmaskclient/EipServiceFragment.java @@ -37,7 +37,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe private boolean mEipStartPending = false; - private EIPReceiver mEIPReceiver; + private static EIPReceiver mEIPReceiver; public static String TAG = "se.leap.bitmask.EipServiceFragment"; @@ -273,4 +273,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe eipAutoSwitched = false; } } + + + public static EIPReceiver getReceiver() { + return mEIPReceiver; + } } -- cgit v1.2.3 From 6cb654d169c62653d652009d3c8de51ca877e38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 24 Mar 2014 20:36:08 +0100 Subject: eip switch off && logged in != autostart eip --- src/se/leap/bitmaskclient/Dashboard.java | 3 ++- src/se/leap/bitmaskclient/EipServiceFragment.java | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index 4ad6d029..b8d76f87 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -375,7 +375,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf setResult(RESULT_OK); changeStatusMessage(resultCode); mProgressBar.setVisibility(ProgressBar.GONE); - eipStart(); + if(EipServiceFragment.isEipSwitchChecked()) + eipStart(); } else if(resultCode == ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE) { setResult(RESULT_CANCELED); changeStatusMessage(resultCode); diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java index 318e4024..bae1b942 100644 --- a/src/se/leap/bitmaskclient/EipServiceFragment.java +++ b/src/se/leap/bitmaskclient/EipServiceFragment.java @@ -29,7 +29,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe private static final String IS_EIP_PENDING = "is_eip_pending"; private View eipFragment; - private Switch eipSwitch; + private static Switch eipSwitch; private View eipDetail; private TextView eipStatus; @@ -278,4 +278,8 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe public static EIPReceiver getReceiver() { return mEIPReceiver; } + + public static boolean isEipSwitchChecked() { + return eipSwitch.isChecked(); + } } -- cgit v1.2.3 From 4335ef38d5ce8040eca2a6bace5f2e4ae8a179e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 2 Apr 2014 17:08:32 +0200 Subject: Eip switch turns off accordingly to log in state. --- src/se/leap/bitmaskclient/Dashboard.java | 8 ++++++-- src/se/leap/bitmaskclient/EipServiceFragment.java | 21 +++++++++++++++++++-- src/se/leap/bitmaskclient/LogInDialog.java | 20 ++++++++++++++++---- 3 files changed, 41 insertions(+), 8 deletions(-) (limited to 'src') 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); + } } -- cgit v1.2.3 From f6447292f733df5085c7de138c1e9f05f4428a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 2 Apr 2014 17:16:23 +0200 Subject: Message updated when login was cancelled. --- src/se/leap/bitmaskclient/EipServiceFragment.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java index ab4f9a5c..b4cb541a 100644 --- a/src/se/leap/bitmaskclient/EipServiceFragment.java +++ b/src/se/leap/bitmaskclient/EipServiceFragment.java @@ -160,6 +160,10 @@ public class EipServiceFragment extends Fragment implements StateListener, OnChe dashboard.logInDialog(getActivity().getCurrentFocus(), waiting_on_login); } } + else { + if(!eipSwitch.isChecked()) + eipStatus.setText(R.string.state_noprocess); + } eipAutoSwitched = true; } -- cgit v1.2.3