From 6c79290b1783a303fad5ea8be3c3583cc79dad84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 4 Dec 2014 00:46:25 +0100 Subject: Learning to use Butterknife, refactoring small things. --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 94de2fe8..c4f845b8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -86,8 +86,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); handleVersion(); - boolean provider_configured = preferences.getString(Constants.KEY, "").isEmpty(); - if (provider_configured) + boolean no_provider_configured = preferences.getString(Constants.KEY, "").isEmpty(); + if (no_provider_configured) startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); else buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); @@ -135,6 +135,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply(); preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); updateEipService(); + buildDashboard(false); invalidateOptionsMenu(); if(data != null && data.hasExtra(LogInDialog.TAG)) { logInDialog(Bundle.EMPTY); -- cgit v1.2.3 From f9a200a7004b74cb2d64e37129e6234427c84c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 4 Dec 2014 16:38:21 +0100 Subject: Renderers and dagger, refactoring CW. --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index c4f845b8..e1d08d08 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -71,9 +71,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf private TextView status_message; public ProviderAPIResultReceiver providerAPI_result_receiver; + private Provider provider; private static boolean authed_eip; - - @Override + + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -137,9 +138,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf updateEipService(); buildDashboard(false); invalidateOptionsMenu(); - if(data != null && data.hasExtra(LogInDialog.TAG)) { + if(data != null) + if(data.hasExtra(LogInDialog.TAG)) { logInDialog(Bundle.EMPTY); } + if(data.hasExtra(Provider.KEY)) + provider = data.getParcelableExtra(Provider.KEY); } else if(resultCode == RESULT_CANCELED && (data == null || data.hasExtra(ACTION_QUIT))) { finish(); } else @@ -180,9 +184,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * service dependent UI elements to include. */ private void buildDashboard(boolean hide_and_turn_on_eip) { - Provider provider = Provider.getInstance(); - provider.init( this ); - setContentView(R.layout.client_dashboard); TextView providerNameTV = (TextView) findViewById(R.id.providerName); @@ -262,7 +263,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf startActivity(startLW); return true; case R.id.switch_provider: - if (Provider.getInstance().hasEIP()){ + if (provider.hasEIP()){ if (preferences.getBoolean(Constants.AUTHED_EIP, false)){ logOut(); } -- cgit v1.2.3 From 84f71ca604abb2b4aeb410dcec2c3cc5dff9bc39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 9 Dec 2014 11:20:31 +0100 Subject: Switching provider doesn't refresh provider list. It shows just one provider, and it's not the one that gets configured if selected. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index e1d08d08..e277221b 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -87,8 +87,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); handleVersion(); - boolean no_provider_configured = preferences.getString(Constants.KEY, "").isEmpty(); - if (no_provider_configured) + + if (provider == null) startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); else buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); @@ -132,21 +132,21 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf Log.d(TAG, "onActivityResult: requestCode = " + requestCode); if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) { // It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) { - if ( resultCode == RESULT_OK ){ - preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply(); - preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); - updateEipService(); - buildDashboard(false); - invalidateOptionsMenu(); - if(data != null) - if(data.hasExtra(LogInDialog.TAG)) { - logInDialog(Bundle.EMPTY); - } - if(data.hasExtra(Provider.KEY)) + if ( resultCode == RESULT_OK ) { + preferences.edit().putInt(Constants.PARSED_SERIAL, 0).apply(); + preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); + updateEipService(); + + if (data.hasExtra(Provider.KEY)) provider = data.getParcelableExtra(Provider.KEY); - } else if(resultCode == RESULT_CANCELED && (data == null || data.hasExtra(ACTION_QUIT))) { - finish(); - } else + buildDashboard(false); + invalidateOptionsMenu(); + if (data.hasExtra(LogInDialog.TAG)) { + logInDialog(Bundle.EMPTY); + } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { + finish(); + } + } else configErrorDialog(); } else if(requestCode == EIP.DISCONNECT) { EipStatus.getInstance().setConnectedOrDisconnected(); -- cgit v1.2.3 From 7da04dc635505c0bcfdcc2c86d186a7a6f0535f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 9 Dec 2014 12:08:40 +0100 Subject: Release flavor updated, back button works. --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index e277221b..e3bd9b7d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -143,9 +143,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf invalidateOptionsMenu(); if (data.hasExtra(LogInDialog.TAG)) { logInDialog(Bundle.EMPTY); - } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { - finish(); } + } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { + finish(); } else configErrorDialog(); } else if(requestCode == EIP.DISCONNECT) { -- cgit v1.2.3 From 5978db9bf758b7b229616d0575e327c58ad8cf94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 9 Dec 2014 14:08:17 +0100 Subject: EIP fragment shown correctly. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 47 ++++++++++++++-------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index e3bd9b7d..b84b834c 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -37,6 +37,9 @@ import android.widget.TextView; import org.json.JSONException; import org.json.JSONObject; +import java.net.MalformedURLException; +import java.net.URL; + import de.blinkt.openvpn.activities.LogWindow; import se.leap.bitmaskclient.eip.Constants; import se.leap.bitmaskclient.eip.EIP; @@ -74,6 +77,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf private Provider provider; private static boolean authed_eip; + @Override + protected void onSaveInstanceState(Bundle outState) { + if(provider != null) + outState.putParcelable(Provider.KEY, provider); + super.onSaveInstanceState(outState); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -88,7 +98,19 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); handleVersion(); - if (provider == null) + if(savedInstanceState != null) + provider = savedInstanceState.getParcelable(Provider.KEY); + if(provider == null && preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false)) + try { + provider = new Provider(new URL(preferences.getString(Provider.MAIN_URL, ""))); + provider.define(new JSONObject(preferences.getString(Provider.KEY, ""))); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (JSONException e) { + e.printStackTrace(); + } + + if (provider == null || provider.getName().isEmpty()) startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); else buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false)); @@ -116,16 +138,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf Log.d(TAG, "Handle version didn't find any " + getPackageName() + " package"); } } - - @Override - protected void onDestroy() { - - super.onDestroy(); - } - - protected void onPause() { - super.onPause(); - } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ @@ -137,8 +149,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply(); updateEipService(); - if (data.hasExtra(Provider.KEY)) + if (data.hasExtra(Provider.KEY)) { provider = data.getParcelableExtra(Provider.KEY); + preferences.edit().putBoolean(Constants.PROVIDER_CONFIGURED, true).commit(); + preferences.edit().putString(Provider.MAIN_URL, provider.mainUrl().toString()).apply(); + preferences.edit().putString(Provider.KEY, provider.definition().toString()).apply(); + } buildDashboard(false); invalidateOptionsMenu(); if (data.hasExtra(LogInDialog.TAG)) { @@ -172,7 +188,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf .setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - preferences.edit().remove(Provider.KEY).apply(); + preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_CONFIGURED).apply(); finish(); } }) @@ -194,9 +210,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if ( provider.hasEIP()){ - EipServiceFragment eip_fragment = (EipServiceFragment) fragment_manager.findFragmentByTag(EipServiceFragment.TAG); - if(eip_fragment == null) - eip_fragment = new EipServiceFragment(); + fragment_manager.removePreviousFragment(EipServiceFragment.TAG); + EipServiceFragment eip_fragment = new EipServiceFragment(); if (hide_and_turn_on_eip) { preferences.edit().remove(Dashboard.START_ON_BOOT).apply(); -- cgit v1.2.3 From 062e4c4597f947816282b1c9c5e63c034549f057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 9 Dec 2014 18:57:35 +0100 Subject: Final refactoring for this bug. Removed the sign up dialog, log in one is enough with the third button I added some time ago to sign up. Removed classes we don't need due to the libraries I have recently introduced. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 148 +++++++++------------ 1 file changed, 62 insertions(+), 86 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index b84b834c..c7691ed4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -40,6 +40,8 @@ import org.json.JSONObject; import java.net.MalformedURLException; import java.net.URL; +import butterknife.ButterKnife; +import butterknife.InjectView; import de.blinkt.openvpn.activities.LogWindow; import se.leap.bitmaskclient.eip.Constants; import se.leap.bitmaskclient.eip.EIP; @@ -52,7 +54,7 @@ import se.leap.bitmaskclient.eip.EipStatus; * @author Sean Leonard * @author parmegv */ -public class Dashboard extends Activity implements LogInDialog.LogInDialogInterface, SignUpDialog.SignUpDialogInterface, ProviderAPIResultReceiver.Receiver { +public class Dashboard extends Activity implements SessionDialog.LogInDialogInterface, ProviderAPIResultReceiver.Receiver { protected static final int CONFIGURE_LEAP = 0; protected static final int SWITCH_PROVIDER = 1; @@ -70,12 +72,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf protected static SharedPreferences preferences; private FragmentManagerEnhanced fragment_manager; - private ProgressBar mProgressBar; - private TextView status_message; - public ProviderAPIResultReceiver providerAPI_result_receiver; + @InjectView(R.id.providerName) + TextView provider_name; + EipServiceFragment eip_fragment; private Provider provider; private static boolean authed_eip; + public ProviderAPIResultReceiver providerAPI_result_receiver; @Override protected void onSaveInstanceState(Bundle outState) { @@ -91,8 +94,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf app = this; PRNGFixes.apply(); - - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); @@ -157,7 +158,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf } buildDashboard(false); invalidateOptionsMenu(); - if (data.hasExtra(LogInDialog.TAG)) { + if (data.hasExtra(SessionDialog.TAG)) { logInDialog(Bundle.EMPTY); } } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { @@ -200,24 +201,21 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * service dependent UI elements to include. */ private void buildDashboard(boolean hide_and_turn_on_eip) { - setContentView(R.layout.client_dashboard); - - TextView providerNameTV = (TextView) findViewById(R.id.providerName); - providerNameTV.setText(provider.getDomain()); - providerNameTV.setTextSize(28); - - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); + setContentView(R.layout.dashboard); + ButterKnife.inject(this); + + provider_name.setText(provider.getDomain()); if ( provider.hasEIP()){ fragment_manager.removePreviousFragment(EipServiceFragment.TAG); - EipServiceFragment eip_fragment = new EipServiceFragment(); + eip_fragment = new EipServiceFragment(); if (hide_and_turn_on_eip) { preferences.edit().remove(Dashboard.START_ON_BOOT).apply(); Bundle arguments = new Bundle(); arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true); - eip_fragment.setArguments(arguments); + if(eip_fragment != null) eip_fragment.setArguments(arguments); } fragment_manager.replace(R.id.servicesCollection, eip_fragment, EipServiceFragment.TAG); @@ -279,10 +277,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf return true; case R.id.switch_provider: if (provider.hasEIP()){ - if (preferences.getBoolean(Constants.AUTHED_EIP, false)){ - logOut(); - } - eipStop(); + if (preferences.getBoolean(Constants.AUTHED_EIP, false)) { + logOut(); + } + eip_fragment.stopEIP(); } preferences.edit().clear().apply(); startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); @@ -302,10 +300,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf } - private Intent prepareProviderAPICommand() { - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - status_message = (TextView) findViewById(R.id.status_message); - + private Intent prepareProviderAPICommand() { providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); providerAPI_result_receiver.setReceiver(this); @@ -319,12 +314,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * Shows the log in dialog. */ public void logInDialog(Bundle resultData) { - FragmentTransaction transaction = fragment_manager.removePreviousFragment(LogInDialog.TAG); + FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); - DialogFragment newFragment = LogInDialog.newInstance(); + DialogFragment newFragment = SessionDialog.newInstance(); if(resultData != null && !resultData.isEmpty()) newFragment.setArguments(resultData); - newFragment.show(transaction, LogInDialog.TAG); + newFragment.show(transaction, SessionDialog.TAG); } @Override @@ -334,12 +329,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if(parameters == null) parameters = new Bundle(); - parameters.putString(SessionDialogInterface.USERNAME, username); - parameters.putString(SessionDialogInterface.PASSWORD, password); - - mProgressBar.setVisibility(ProgressBar.VISIBLE); - status_message.setText(R.string.authenticating_message); + parameters.putString(SessionDialog.USERNAME, username); + parameters.putString(SessionDialog.PASSWORD, password); + if(eip_fragment != null) { + eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); + eip_fragment.status_message.setText(R.string.authenticating_message); + } provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); provider_API_command.setAction(ProviderAPI.SRP_AUTH); startService(provider_API_command); @@ -354,12 +350,11 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf */ public void logOut() { Intent provider_API_command = prepareProviderAPICommand(); - - if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - mProgressBar.setVisibility(ProgressBar.VISIBLE); - if(status_message == null) status_message = (TextView) findViewById(R.id.status_message); - status_message.setText(R.string.logout_message); - + if(eip_fragment != null) { + + eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); + eip_fragment.status_message.setText(R.string.logout_message); + } provider_API_command.setAction(ProviderAPI.LOG_OUT); startService(provider_API_command); } @@ -368,13 +363,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * Shows the sign up dialog. */ public void signUpDialog(Bundle resultData) { - FragmentTransaction transaction = fragment_manager.removePreviousFragment(SignUpDialog.TAG); + FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); - DialogFragment newFragment = SignUpDialog.newInstance(); + DialogFragment newFragment = SessionDialog.newInstance(); if(resultData != null && !resultData.isEmpty()) { newFragment.setArguments(resultData); } - newFragment.show(transaction, SignUpDialog.TAG); + newFragment.show(transaction, SessionDialog.TAG); } @Override @@ -384,12 +379,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if(parameters == null) parameters = new Bundle(); - parameters.putString(SessionDialogInterface.USERNAME, username); - parameters.putString(SessionDialogInterface.PASSWORD, password); - - mProgressBar.setVisibility(ProgressBar.VISIBLE); - status_message.setText(R.string.signingup_message); - + parameters.putString(SessionDialog.USERNAME, username); + parameters.putString(SessionDialog.PASSWORD, password); + if(eip_fragment != null) { + eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); + eip_fragment.status_message.setText(R.string.signingup_message); + } provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); provider_API_command.setAction(ProviderAPI.SRP_REGISTER); startService(provider_API_command); @@ -418,8 +413,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf public void onReceiveResult(int resultCode, Bundle resultData) { Log.d(TAG, "onReceiveResult"); if(resultCode == ProviderAPI.SRP_REGISTRATION_SUCCESSFUL) { - String username = resultData.getString(SessionDialogInterface.USERNAME); - String password = resultData.getString(SessionDialogInterface.PASSWORD); + String username = resultData.getString(SessionDialog.USERNAME); + String password = resultData.getString(SessionDialog.PASSWORD); logIn(username, password); } else if(resultCode == ProviderAPI.SRP_REGISTRATION_FAILED) { changeStatusMessage(resultCode); @@ -477,8 +472,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf String request = resultData.getString(Constants.REQUEST_TAG); if(request.equalsIgnoreCase(Constants.ACTION_UPDATE_EIP_SERVICE)) { if(resultCode == Activity.RESULT_OK) { - if(authed_eip) - eipStart(); + if(authed_eip && eip_fragment != null) eip_fragment.startEipFromScratch(); } } } @@ -493,17 +487,16 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf protected void onReceiveResult(int resultCode, Bundle resultData){ super.onReceiveResult(resultCode, resultData); String request = resultData.getString(Constants.REQUEST_TAG); - if(status_message == null) status_message = (TextView) findViewById(R.id.status_message); - if (request.equalsIgnoreCase(Constants.ACTION_IS_EIP_RUNNING)){ + if (request.equalsIgnoreCase(Constants.ACTION_IS_EIP_RUNNING)){ if (resultCode == Activity.RESULT_OK){ switch(previous_result_code){ - case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.SRP_AUTHENTICATION_FAILED: status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: status_message.setText(R.string.authed_secured_status); break; - case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.LOGOUT_SUCCESSFUL: status_message.setText(R.string.logged_out_message); break; - case ProviderAPI.LOGOUT_FAILED: status_message.setText(R.string.log_out_failed_message); break; + case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; + case ProviderAPI.SRP_AUTHENTICATION_FAILED: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; + case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.authed_secured_status); break; + case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; + case ProviderAPI.LOGOUT_SUCCESSFUL: eip_fragment.status_message.setText(R.string.logged_out_message); break; + case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; } } @@ -511,13 +504,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf switch(previous_result_code){ - case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.SRP_AUTHENTICATION_FAILED: status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.SRP_REGISTRATION_FAILED: status_message.setText(R.string.registration_failed_message); break; + case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; + case ProviderAPI.SRP_AUTHENTICATION_FAILED: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; + case ProviderAPI.SRP_REGISTRATION_FAILED: eip_fragment.status_message.setText(R.string.registration_failed_message); break; case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: break; - case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.LOGOUT_SUCCESSFUL: status_message.setText(R.string.logged_out_message); break; - case ProviderAPI.LOGOUT_FAILED: status_message.setText(R.string.log_out_failed_message); break; + case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; + case ProviderAPI.LOGOUT_SUCCESSFUL: eip_fragment.status_message.setText(R.string.logged_out_message); break; + case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; } } } @@ -528,11 +521,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf } private void hideProgressBar() { - if(mProgressBar == null) - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - - mProgressBar.setProgress(0); - mProgressBar.setVisibility(ProgressBar.GONE); + if(eip_fragment != null) { + eip_fragment.progress_bar.setProgress(0); + eip_fragment.progress_bar.setVisibility(ProgressBar.GONE); + } } /** @@ -559,20 +551,4 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf eip_intent.putExtra(Constants.RECEIVER_TAG, eip_receiver); startService(eip_intent); } - - private void eipStop(){ - EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG); - eipFragment.stopEIP(); - } - - private void eipStart() { - EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG); - eipFragment.startEipFromScratch(); - } - - protected void showProgressBar() { - if(mProgressBar == null) - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - mProgressBar.setVisibility(ProgressBar.VISIBLE); - } } -- cgit v1.2.3 From 56a998deef38a635e2a2e61dd1f516b78d24c9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 9 Dec 2014 21:30:25 +0100 Subject: SessionDialog restores eip switch if necessary. --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index c7691ed4..3ecf5e52 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -54,7 +54,7 @@ import se.leap.bitmaskclient.eip.EipStatus; * @author Sean Leonard * @author parmegv */ -public class Dashboard extends Activity implements SessionDialog.LogInDialogInterface, ProviderAPIResultReceiver.Receiver { +public class Dashboard extends Activity implements SessionDialog.SessionDialogInterface, ProviderAPIResultReceiver.Receiver { protected static final int CONFIGURE_LEAP = 0; protected static final int SWITCH_PROVIDER = 1; -- cgit v1.2.3