diff --git a/src/com/timsu/astrid/activities/TaskList.java b/src/com/timsu/astrid/activities/TaskList.java index 6bd4c72dc..b020fa8eb 100644 --- a/src/com/timsu/astrid/activities/TaskList.java +++ b/src/com/timsu/astrid/activities/TaskList.java @@ -127,9 +127,10 @@ public class TaskList extends Activity { // sync now if requested if(synchronizeNow) { - Synchronizer.synchronize(this, true, null); + synchronizeNow = false; + Synchronizer.synchronize(this, false, null); } - + // if we have no filter tag, we're not on the last task if(getCurrentSubActivity() == taskListWTag && ((TaskListSubActivity)taskListWTag).getFilterTag() == null) { diff --git a/src/com/timsu/astrid/sync/RTMSyncProvider.java b/src/com/timsu/astrid/sync/RTMSyncProvider.java index be9e49fb3..8cb27336f 100644 --- a/src/com/timsu/astrid/sync/RTMSyncProvider.java +++ b/src/com/timsu/astrid/sync/RTMSyncProvider.java @@ -238,6 +238,9 @@ public class RTMSyncProvider extends SynchronizationProvider { Date syncTime = new Date(System.currentTimeMillis() + 1000); Preferences.setSyncRTMLastSync(context, syncTime); + // on with the synchronization + Synchronizer.continueSynchronization(context); + } catch (Exception e) { showError(context, e, null); } diff --git a/src/com/timsu/astrid/sync/SynchronizationProvider.java b/src/com/timsu/astrid/sync/SynchronizationProvider.java index 4895bef20..06d6c6a2a 100644 --- a/src/com/timsu/astrid/sync/SynchronizationProvider.java +++ b/src/com/timsu/astrid/sync/SynchronizationProvider.java @@ -27,7 +27,6 @@ import java.util.LinkedList; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.res.Resources; import android.os.Handler; import android.util.Log; @@ -497,15 +496,11 @@ public abstract class SynchronizationProvider { progressDialog.hide(); Resources r = context.getResources(); - if(Preferences.shouldSuppressSyncDialogs(context)) + if(Preferences.shouldSuppressSyncDialogs(context)) { return; + } - Dialog.OnClickListener finishListener = new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - Synchronizer.continueSynchronization(context); - } - }; + Dialog.OnClickListener finishListener = null; // nothing updated if(localCreatedTasks + localUpdatedTasks + localDeletedTasks + diff --git a/src/com/timsu/astrid/sync/SynchronizationService.java b/src/com/timsu/astrid/sync/SynchronizationService.java index 18081b2c3..866b8d48c 100644 --- a/src/com/timsu/astrid/sync/SynchronizationService.java +++ b/src/com/timsu/astrid/sync/SynchronizationService.java @@ -60,14 +60,17 @@ public class SynchronizationService extends Service { // figure out last synchronize time Date lastSyncDate = Preferences.getSyncLastSync(context); Date lastAutoSyncDate = Preferences.getSyncLastSyncAttempt(context); - long latestSyncMillis = 0; + + // if user never synchronized, give them a full offset period before bg sync + long latestSyncMillis = System.currentTimeMillis(); if(lastSyncDate != null) latestSyncMillis = lastSyncDate.getTime(); if(lastAutoSyncDate != null && lastAutoSyncDate.getTime() > latestSyncMillis) latestSyncMillis = lastAutoSyncDate.getTime(); long offset = 0; if(latestSyncMillis != 0) - offset = Math.max(0, latestSyncMillis + interval - System.currentTimeMillis()); + offset = Math.min(offset, Math.max(0, latestSyncMillis + interval - + System.currentTimeMillis())); timer.scheduleAtFixedRate(new TimerTask() { @Override diff --git a/src/com/timsu/astrid/sync/Synchronizer.java b/src/com/timsu/astrid/sync/Synchronizer.java index c9a37f46e..90514abf0 100644 --- a/src/com/timsu/astrid/sync/Synchronizer.java +++ b/src/com/timsu/astrid/sync/Synchronizer.java @@ -114,7 +114,7 @@ public class Synchronizer { private static boolean autoSync; - /** Called to do the next step of synchronization. Run me on the UI thread! */ + /** Called to do the next step of synchronization. */ static void continueSynchronization(Context context) { ServiceWrapper serviceWrapper = ServiceWrapper.values()[currentStep]; @@ -124,7 +124,7 @@ public class Synchronizer { continueSynchronization(context); break; case RTM: - if(Preferences.shouldSyncRTM(context)) { + if(serviceWrapper.isActivated(context)) { servicesSynced++; serviceWrapper.service.synchronizeService(context, autoSync); } else {