/** If there is an active user, makes the active use no longer active. */ public void removeActiveUser() { synchronized (this) { if (activeUser != null) { activeUser.setActive(false); activeUser = null; GoogleLoginPrefs.removeActiveUser(); notifyLoginStatusChange(); } } }
/** * Remove <code>userEmail</code> from the list of logged in users if <code>userEmail</code> is a * logged in user. If <code>userEmail</code> is the active user, there would no longer be an * active user once <code>userEmail</code> is removed. Another user will have to explicitly * selected for there to be an active user again. * * @param userEmail The user to be removed. * @return True if <code>userEmail</code> was successfully removed from the list of logged in * users and false if <code>userEmail</code> is not a logged in user. */ public boolean removeUser(String userEmail) { synchronized (this) { if (!allUsers.containsKey(userEmail)) { return false; } if (activeUser.getEmail().equals(userEmail)) { activeUser = null; GoogleLoginPrefs.removeActiveUser(); } allUsers.remove(userEmail); notifyLoginStatusChange(); return true; } }
@Test public void testActiveUser() { GoogleLoginPrefs.saveActiveUser("cheese"); Assert.assertEquals("cheese", GoogleLoginPrefs.getActiveUser()); GoogleLoginPrefs.removeActiveUser(); Assert.assertNull(GoogleLoginPrefs.getActiveUser()); } }