Calendar reminders should get scheduled when the preference is turned on

pull/14/head
Sam Bosley 12 years ago
parent 07284c3b17
commit 296c659b47

@ -16,11 +16,11 @@ public class CalendarStartupReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
scheduleCalendarAlarms(context);
scheduleCalendarAlarms(context, false);
}
public static void scheduleCalendarAlarms(final Context context) {
if (!Preferences.getBoolean(R.string.p_calendar_reminders, true))
public static void scheduleCalendarAlarms(final Context context, boolean force) {
if (!Preferences.getBoolean(R.string.p_calendar_reminders, true) && !force)
return;
new Thread(new Runnable() {
@Override

@ -52,6 +52,7 @@ import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.files.FileExplore;
import com.todoroo.astrid.files.FileMetadata;
import com.todoroo.astrid.gcal.CalendarStartupReceiver;
import com.todoroo.astrid.gtasks.GtasksPreferences;
import com.todoroo.astrid.helper.MetadataHelper;
import com.todoroo.astrid.producteev.ProducteevPreferences;
@ -650,6 +651,15 @@ public class EditPreferences extends TodorooPreferenceActivity {
}
});
findPreference(getString(R.string.p_calendar_reminders)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (newValue != null && ((Boolean) newValue))
CalendarStartupReceiver.scheduleCalendarAlarms(EditPreferences.this, true);
return true;
}
});
findPreference(getString(R.string.p_statistics)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {

@ -227,7 +227,6 @@ public class StartupService {
// perform initialization
ReminderStartupReceiver.startReminderSchedulingService(context);
CalendarStartupReceiver.scheduleCalendarAlarms(context);
BackupService.scheduleService(context);
actFmSyncService.initialize();
@ -242,6 +241,7 @@ public class StartupService {
}).start();
AstridPreferences.setPreferenceDefaults();
CalendarStartupReceiver.scheduleCalendarAlarms(context, false); // This needs to be after set preference defaults for the purposes of ab testing
// check for task killers
if(!Constants.OEM)

Loading…
Cancel
Save