diff --git a/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java b/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java index 602cf3e4b..7c839017d 100644 --- a/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java +++ b/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java @@ -75,6 +75,7 @@ abstract public class SyncV2BackgroundService extends Service { getSyncProvider().synchronizeActiveTasks(false, new SyncResultCallbackAdapter() { @Override public void finished() { + getSyncUtilities().recordSuccessfulSync(); context.sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); } }); diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java index e9694552d..27834e7eb 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java @@ -32,13 +32,18 @@ public class ActFmPreferences extends SyncProviderPreferences { @Override public void startSync() { - new ActFmSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() { - @Override - public void finished() { - ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); - } - }); - finish(); + if (!actFmPreferenceService.isLoggedIn()) { + Intent intent = new Intent(this, ActFmLoginActivity.class); + startActivityForResult(intent, 0); + } else { + new ActFmSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() { + @Override + public void finished() { + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); + } + }); + finish(); + } } @Override diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java index 0f037131f..65559ebe9 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java @@ -103,8 +103,10 @@ public class ActFmSyncV2Provider extends SyncV2Provider { exceptionService.reportError("actfm-sync", e); //$NON-NLS-1$ } finally { callback.incrementProgress(20); - if(finisher.decrementAndGet() == 0) + if(finisher.decrementAndGet() == 0) { + actFmPreferenceService.recordSuccessfulSync(); callback.finished(); + } } } }).start(); @@ -119,8 +121,10 @@ public class ActFmSyncV2Provider extends SyncV2Provider { pushQueued(callback, finisher); callback.incrementProgress(30); - if(finisher.decrementAndGet() == 0) + if(finisher.decrementAndGet() == 0) { + actFmPreferenceService.recordSuccessfulSync(); callback.finished(); + } } }); } @@ -149,8 +153,10 @@ public class ActFmSyncV2Provider extends SyncV2Provider { actFmSyncService.pushTaskOnSave(task, task.getMergedValues()); } finally { callback.incrementProgress(20); - if(finisher.decrementAndGet() == 0) + if(finisher.decrementAndGet() == 0) { + actFmPreferenceService.recordSuccessfulSync(); callback.finished(); + } } } }).start(); diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java index 07c4ac1cb..456d180c8 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferences.java @@ -8,6 +8,7 @@ import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.astrid.api.AstridApiConstants; +import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity; import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider; import com.todoroo.astrid.sync.SyncProviderPreferences; import com.todoroo.astrid.sync.SyncProviderUtilities; @@ -41,13 +42,18 @@ public class GtasksPreferences extends SyncProviderPreferences { @Override public void startSync() { - new GtasksSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() { - @Override - public void finished() { - ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); - } - }); - finish(); + if (!gtasksPreferenceService.isLoggedIn()) { + Intent intent = new Intent(this, GtasksLoginActivity.class); + startActivityForResult(intent, 0); + } else { + new GtasksSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() { + @Override + public void finished() { + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); + } + }); + finish(); + } } @Override diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java index eb8e5e4f2..cf2095dc2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncV2Provider.java @@ -112,6 +112,7 @@ public class GtasksSyncV2Provider extends SyncV2Provider { public void run() { synchronizeListHelper(list, invoker, callback); if (finisher.decrementAndGet() == 0) { + gtasksPreferenceService.recordSuccessfulSync(); callback.finished(); } }