diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java
index 018a88644..b81980cd0 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java
@@ -144,6 +144,21 @@ public final class ActFmSyncService {
}
}
+ public String refreshToken() {
+ try {
+ JSONObject result = invoke("refresh_token");
+ String newToken = result.optString("token");
+ if (!TextUtils.isEmpty(newToken)) {
+ actFmPreferenceService.setToken(newToken);
+ checkForToken();
+ }
+ return newToken;
+ } catch (IOException e) {
+ //
+ }
+ return null;
+ }
+
// --- generic invokation
/** invoke authenticated method against the server */
diff --git a/astrid/plugin-src/com/todoroo/astrid/core/OldTaskPreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/OldTaskPreferences.java
index ade6b9e6d..b192a2090 100644
--- a/astrid/plugin-src/com/todoroo/astrid/core/OldTaskPreferences.java
+++ b/astrid/plugin-src/com/todoroo/astrid/core/OldTaskPreferences.java
@@ -24,6 +24,8 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.andlib.utility.TodorooPreferenceActivity;
+import com.todoroo.astrid.actfm.sync.ActFmSyncService;
+import com.todoroo.astrid.actfm.sync.ActFmSyncThread;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.GCalHelper;
@@ -43,6 +45,8 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
@Autowired MetadataService metadataService;
@Autowired Database database;
+ @Autowired ActFmSyncService actFmSyncService;
+
ProgressDialog pd;
@Override
@@ -65,6 +69,15 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
}
});
+ preference = screen.findPreference(getString(R.string.EPr_reset_sync_state));
+ preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference p) {
+ showResetSyncStateDialog();
+ return true;
+ }
+ });
+
preference = screen.findPreference(getString(R.string.EPr_manage_purge_deleted));
preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference p) {
@@ -287,6 +300,22 @@ public class OldTaskPreferences extends TodorooPreferenceActivity {
}, null);
}
+ private void showResetSyncStateDialog() {
+ DialogUtilities.okCancelDialog(this, getString(R.string.EPr_reset_sync_state_detailed), new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ pd = DialogUtilities.runWithProgressDialog(OldTaskPreferences.this, new Runnable() {
+ @Override
+ public void run() {
+ actFmSyncService.refreshToken();
+ ActFmSyncThread.clearTablePushedAtValues();
+ //TODO: Maybe clear outstanding tables?
+ }
+ });
+ }
+ }, null);
+ }
+
protected void showResult(int resourceText, int result) {
DialogUtilities.okDialog(this, getString(resourceText, result), null);
}
diff --git a/astrid/res/values/strings-actfm.xml b/astrid/res/values/strings-actfm.xml
index d33db2433..ff39e2071 100644
--- a/astrid/res/values/strings-actfm.xml
+++ b/astrid/res/values/strings-actfm.xml
@@ -376,5 +376,9 @@
Sync ongoing...
+ Reset sync
+ Refreshes sync token and resets some local data to help resolve sync errors
+ The next time you sync, your tasks and lists will be changed to mirror what exists on Astrid.com, which may help resolve sync errors. Do you wish to continue?
+
diff --git a/astrid/res/xml/preferences_oldtasks.xml b/astrid/res/xml/preferences_oldtasks.xml
index 54ced4463..29d250f9e 100644
--- a/astrid/res/xml/preferences_oldtasks.xml
+++ b/astrid/res/xml/preferences_oldtasks.xml
@@ -8,6 +8,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/EPr_manage_header">
+
+