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

@ -12,6 +12,14 @@ import android.util.Log;
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 {
/** Service timer */
@ -32,7 +40,7 @@ public class SynchronizationService extends Service {
return;
Intent service = new Intent(context, SynchronizationService.class);
context.stopService(service);
context.startService(service);
}
public static void stop() {

@ -1,14 +1,18 @@
package com.timsu.astrid.utilities;
import com.timsu.astrid.sync.SynchronizationService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
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 {
private static boolean hasStartedUp = false;
@ -42,11 +46,18 @@ public class StartupReceiver extends BroadcastReceiver {
if(latestSetVersion <= 99) {
if(Preferences.getSyncOldAutoSyncFrequency(context) != null) {
float value = Preferences.getSyncOldAutoSyncFrequency(context);
Preferences.setSyncAutoSyncFrequency(context,
Preferences.setSyncAutoSyncFrequency(context,
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));
}
});
}
}
new Thread(new Runnable() {
public void run() {
Notifications.scheduleAllAlarms(context);
@ -64,7 +75,7 @@ public class StartupReceiver extends BroadcastReceiver {
SynchronizationService.setContext(context);
Intent service = new Intent(context, SynchronizationService.class);
context.startService(service);
hasStartedUp = true;
}
}

Loading…
Cancel
Save