Made some code cleaner when clearing data after logout

pull/14/head
Sam Bosley 12 years ago
parent 008c1b2184
commit 70239630cd

@ -635,10 +635,8 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
@SuppressWarnings("nls")
private void postAuthenticate(final JSONObject result, final String token) {
long lastLoggedInUser = Preferences.getLong(ActFmPreferenceService.PREF_USER_ID, 0);
boolean clearedOnLastLogOut = Preferences.getBoolean(ActFmPreferenceService.PREF_CLEARED_TASKS_ON_LOGOUT, false);
Preferences.setBoolean(ActFmPreferenceService.PREF_CLEARED_TASKS_ON_LOGOUT, false);
if (lastLoggedInUser > 0 && !clearedOnLastLogOut) {
if (lastLoggedInUser > 0) {
long newUserId = result.optLong("id");
if (lastLoggedInUser != newUserId) {
// In this case, we need to either make all data private or clear all data
@ -646,9 +644,16 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
DialogUtilities.okCancelCustomDialog(this,
getString(R.string.actfm_logged_in_different_user_title),
getString(R.string.actfm_logged_in_different_user_body),
R.string.actfm_logged_in_different_user_keep_data,
R.string.actfm_logged_in_different_user_clear_data,
R.string.actfm_logged_in_different_user_keep_data,
android.R.drawable.ic_dialog_alert,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteDatabase(database.getName());
finishSignIn(result, token, true);
}
},
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -668,13 +673,6 @@ public class ActFmLoginActivity extends FragmentActivity implements AuthListener
}
}).start();
}
},
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteDatabase(database.getName());
finishSignIn(result, token, true);
}
});
} else {
finishSignIn(result, token, false);

@ -112,9 +112,6 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
/** Act.fm last sync server time */
public static final String PREF_SERVER_TIME = IDENTIFIER + "_time"; //$NON-NLS-1$
/** Whether the user kept existing tasks after last logout */
public static final String PREF_CLEARED_TASKS_ON_LOGOUT = IDENTIFIER + "_logout_cleared_tasks"; //$NON-NLS-1$
private static JSONObject user = null;
@Override

@ -20,6 +20,7 @@ import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.billing.BillingConstants;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.MetadataService;
@ -78,8 +79,9 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Preferences.setLong(ActFmPreferenceService.PREF_USER_ID, 0); // As though no one has ever logged in
activity.deleteDatabase(database.getName());
Preferences.setBoolean(ActFmPreferenceService.PREF_CLEARED_TASKS_ON_LOGOUT, true);
RemoteModelDao.setOutstandingEntryFlags(RemoteModelDao.OUTSTANDING_FLAG_UNINITIALIZED);
System.exit(0);
}
},

Loading…
Cancel
Save