Fixed background synchronization - seems to work in initial tests.

pull/14/head
Tim Su 17 years ago
parent db6bba8cd2
commit 5ee4077427

@ -260,23 +260,18 @@ If you don\'t want to see the new task right after you complete the old one, you
<string name="p_sync_quiet">sync_dialogs</string> <string name="p_sync_quiet">sync_dialogs</string>
<string name="sync_quiet_title">Hide Dialogs</string> <string name="sync_quiet_title">Hide Dialogs</string>
<string name="sync_quiet_desc">Hide the Sync Results dialogs</string> <string name="sync_quiet_desc">Hide the Sync Results dialogs</string>
<string name="p_sync_background">sync_background</string> <string name="sync_bgwifi_title">Auto-Sync Wifi Only</string>
<string name="sync_background_title">In Background</string> <string name="sync_bgwifi_desc">If set, auto-sync only happens when Wifi is active</string>
<string name="sync_background_desc">Synchronize without bothering you</string>
<string name="sync_error">Sync Error! Sorry for the inconvenience! Error:</string> <string name="sync_error">Sync Error! Sorry for the inconvenience! Error:</string>
<string name="sync_auth_request"> <string name="sync_auth_request">
In order to synchronize, please log in to your %s account and authorize Astrid to read your data. In order to synchronize, please log in to your %s account and authorize Astrid to read your data.
\n\n \n\n
When finished, restart Astrid and come back here. When finished, restart Astrid and come back here.
</string> </string>
<string name="sync_rtm_notes"> <string name="sync_upgrade_v99">
Welcome to Astrid\'s RTM sync! Astrid 2.7 now performs synchronization with RTM in the background. You will
\n\n be directed to the preferences page to configure how often you want this to
Things that don\'t sync:\n occur (it is a minor drain on battery).
- Notifications and repeats\n
- In RTM, deleting, or moving+renaming tasks\n
\n
Wish me luck!\n
</string> </string>
<string name="sync_now">Synchronize Now!</string> <string name="sync_now">Synchronize Now!</string>
<string name="sync_forget">Clear Personal Data</string> <string name="sync_forget">Clear Personal Data</string>

@ -12,6 +12,14 @@ import android.util.Log;
import com.timsu.astrid.utilities.Preferences; import com.timsu.astrid.utilities.Preferences;
/**
* SynchronizationService is the service that performs Astrid's background
* synchronization with online task managers. Starting this service launches
* the timer, which handles timing for synchronization.
*
* @author Tim Su
*
*/
public class SynchronizationService extends Service { public class SynchronizationService extends Service {
/** Service timer */ /** Service timer */
@ -32,7 +40,7 @@ public class SynchronizationService extends Service {
return; return;
Intent service = new Intent(context, SynchronizationService.class); Intent service = new Intent(context, SynchronizationService.class);
context.stopService(service); context.startService(service);
} }
public static void stop() { public static void stop() {

@ -1,14 +1,18 @@
package com.timsu.astrid.utilities; package com.timsu.astrid.utilities;
import com.timsu.astrid.sync.SynchronizationService;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.util.Log; import android.util.Log;
import com.timsu.astrid.R;
import com.timsu.astrid.activities.SyncPreferences;
import com.timsu.astrid.sync.SynchronizationService;
public class StartupReceiver extends BroadcastReceiver { public class StartupReceiver extends BroadcastReceiver {
private static boolean hasStartedUp = false; private static boolean hasStartedUp = false;
@ -44,6 +48,13 @@ public class StartupReceiver extends BroadcastReceiver {
float value = Preferences.getSyncOldAutoSyncFrequency(context); float value = Preferences.getSyncOldAutoSyncFrequency(context);
Preferences.setSyncAutoSyncFrequency(context, Preferences.setSyncAutoSyncFrequency(context,
Math.round(value * 3600)); Math.round(value * 3600));
DialogUtilities.okDialog(context, context.getResources().getString(
R.string.sync_upgrade_v99), new OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
context.startActivity(new Intent(context, SyncPreferences.class));
}
});
} }
} }

Loading…
Cancel
Save