diff options
author | Sean Leonard <meanderingcode@aetherislands.net> | 2014-02-28 17:21:36 -0800 |
---|---|---|
committer | Sean Leonard <meanderingcode@aetherislands.net> | 2014-02-28 17:21:36 -0800 |
commit | dfc259473a26bb71bca226c8290d227fa954bcb8 (patch) | |
tree | 1132b8e00b08bfdd690693bcd9ef25db482bc5d0 /src/se/leap/bitmaskclient/Dashboard.java | |
parent | e6149d1d9ef77409e84d5982a92dd727f0bae2f7 (diff) | |
parent | 1fe78d00244f52f903435c970c0ebf0071a08f36 (diff) |
Merge branch 'feature/remove-shared-preferences-methods-from-ConfigHelper' into develop
Conflicts:
src/se/leap/bitmaskclient/Dashboard.java
Diffstat (limited to 'src/se/leap/bitmaskclient/Dashboard.java')
-rw-r--r-- | src/se/leap/bitmaskclient/Dashboard.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index d50aa7e0..07039a78 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -85,11 +85,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - ConfigHelper.setSharedPreferences(getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE)); - preferences = ConfigHelper.shared_preferences; + preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); - authed_eip = ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP); - if (ConfigHelper.getStringFromSharedPref(Provider.KEY).isEmpty()) + authed_eip = preferences.getBoolean(EIP.AUTHED_EIP, false); + if (preferences.getString(Provider.KEY, "").isEmpty()) startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); else buildDashboard(); @@ -105,9 +104,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf 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 ){ - ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL, 0); - ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); - + getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putInt(EIP.PARSED_SERIAL, 0).commit(); + getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); startService( new Intent(EIP.ACTION_UPDATE_EIP_SERVICE) ); buildDashboard(); @@ -176,8 +174,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf public boolean onPrepareOptionsMenu(Menu menu) { JSONObject provider_json; try { - provider_json = ConfigHelper.getJsonFromSharedPref(Provider.KEY); + provider_json = new JSONObject(getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE).getString(Provider.KEY, "")); JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); + if(service_description.getBoolean(Provider.ALLOW_REGISTRATION)) { if(authed_eip) { menu.findItem(R.id.login_button).setVisible(false); @@ -210,12 +209,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf return true; case R.id.switch_provider: if (Provider.getInstance().hasEIP()){ - if (ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP)){ + if (getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).getBoolean(EIP.AUTHED_EIP, false)){ logOut(); } eipStop(); } - ConfigHelper.removeFromSharedPref(Provider.KEY); + getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().remove(Provider.KEY).commit(); startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); return true; case R.id.login_button: @@ -347,7 +346,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf setResult(RESULT_OK); authed_eip = true; - ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); + getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); + invalidateOptionsMenu(); mProgressBar.setVisibility(ProgressBar.GONE); changeStatusMessage(resultCode); @@ -358,7 +358,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf logInDialog(getCurrentFocus(), resultData); } else if(resultCode == ProviderAPI.LOGOUT_SUCCESSFUL) { authed_eip = false; - ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip); + getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); mProgressBar.setVisibility(ProgressBar.GONE); mProgressBar.setProgress(0); invalidateOptionsMenu(); |