#8 Fixed how it was logging out after changing settings

master
Keith Irwin 2017-04-25 01:46:11 -04:00
parent 9d1af6585b
commit 948eb6f5f2
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
2 changed files with 30 additions and 25 deletions

View File

@ -128,6 +128,33 @@ public class LoginActivity extends AppCompatActivity implements
}
/**
* if onResume() is called, the user has returned from SettingsActivity.
* Their user account must be disassociated and the LocationService must be stopped.
*/
@Override
public void onResume() {
super.onResume();
// Get sharedPrefs
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = sharedPref.edit();
// Stop LocationService
Log.v(TAG, "Stopping location service...");
stopService(new Intent(LoginActivity.this, LocationService.class));
editor.putBoolean("gps_switch",false);
// Remove saved loggedInUser
Log.v(TAG, "Removing saved user...");
editor.remove("loggedInUser");
editor.remove("loggedInUserId");
editor.remove("loggedInUserName");
editor.remove("loggedInUserSk");
editor.apply();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

View File

@ -205,35 +205,13 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
loadHeadersFromResource(R.xml.pref_headers, target);
}
public void signOut() {
Log.v(TAG, "signOut() called");
// Get sharedPrefs
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = sharedPref.edit();
// Stop LocationService
Log.v(TAG, "Stopping location service...");
stopService(new Intent(SettingsActivity.this, LocationService.class));
editor.putBoolean("gps_switch",false);
// Remove saved loggedInUser
Log.v(TAG, "Removing saved user...");
editor.remove("loggedInUser");
editor.remove("loggedInUserId");
editor.remove("loggedInUserName");
editor.remove("loggedInUserSk");
editor.commit();
@Override
public void onBackPressed() {
Log.v(TAG,"onBackPressed() called");
// Return to LoginActivity and don't sign back in again
setResult(SIGN_OUT, new Intent());
}
@Override
public void onBackPressed() {
if (true) {
signOut();
}
super.onBackPressed();
}