Fix for not creating alarms during RTM sync, minor updates to alarm scheduling, now overdue alarms are by default on

pull/14/head
Tim Su 14 years ago
parent a53c6dca03
commit 6701ce3fad

@ -4,7 +4,7 @@
<booleanAttribute key="ch.zork.quicklaunch" value="true"/>
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<intAttribute key="ch.zork.quicklaunch.index" value="0"/>
<stringAttribute key="ch.zork.quicklaunch.mode" value="run"/>
<stringAttribute key="ch.zork.quicklaunch.mode" value="debug"/>
<intAttribute key="com.android.ide.eclipse.adt.action" value="0"/>
<stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/>
<intAttribute key="com.android.ide.eclipse.adt.delay" value="0"/>

@ -24,7 +24,6 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Preferences;
@ -185,7 +184,7 @@ public final class ReminderService {
long dueDate = task.getValue(Task.DUE_DATE);
if(dueDate > DateUtilities.now())
return NO_ALARM;
return DateUtilities.now() + (long)((4 + 20 * random.nextFloat()) * DateUtilities.ONE_HOUR);
return DateUtilities.now() + (long)((4 + 30 * random.nextFloat()) * DateUtilities.ONE_HOUR);
}
return NO_ALARM;
}
@ -302,9 +301,8 @@ public final class ReminderService {
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
intent, 0);
if(Constants.DEBUG || true)
Log.e("Astrid", "Alarm (" + task.getId() + ", " + type +
") set for " + new Date(time));
Log.e("Astrid", "Alarm (" + task.getId() + ", " + type +
") set for " + new Date(time));
am.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);
}
}

@ -22,6 +22,7 @@ package com.todoroo.astrid.rmilk.api.data;
import java.util.Date;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.Text;
import android.util.Log;
@ -37,13 +38,13 @@ public class RtmTaskNote
extends RtmData
{
private String id;
private final String id;
private Date created;
private final Date created;
private Date modified;
private final Date modified;
private String title;
private final String title;
private String text;
@ -58,6 +59,10 @@ public class RtmTaskNote
// note element, so get all of the children.
for (int i=0; i < element.getChildNodes().getLength(); i++) {
Object innerNote = element.getChildNodes().item(i);
if(innerNote instanceof EntityReference) // this node is empty
continue;
if(!(innerNote instanceof Text)) {
Log.w("rtm-note", "Expected text type, got " + innerNote.getClass());
continue;

@ -301,9 +301,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
task.setValue(Task.COMPLETION_DATE,
completedItems.get(task.getId()) ? DateUtilities.now() : 0);
}
System.err.println("look it read " + task.getId() + " was " +
task.isCompleted()
+ ", cache had " + completedItems.get(task.getId()));
completeBox.setChecked(task.isCompleted());
}

@ -146,13 +146,13 @@ public class TaskDao extends GenericDao<Task> {
if (task.getId() == Task.NO_ID) {
saveSuccessful = createNew(task);
} else {
beforeSave(task, values, skipHooks);
saveSuccessful = saveExisting(task);
afterSave(task, values, skipHooks);
}
if(saveSuccessful)
if(saveSuccessful) {
task.markSaved();
afterSave(task, values, skipHooks);
}
return saveSuccessful;
}
@ -183,7 +183,7 @@ public class TaskDao extends GenericDao<Task> {
0));
}
if(!item.containsValue(Task.REMINDER_FLAGS)) {
item.setValue(Task.REMINDER_FLAGS, Task.NOTIFY_AT_DEADLINE);
item.setValue(Task.REMINDER_FLAGS, Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE);
}
return super.createNew(item);
@ -195,24 +195,6 @@ public class TaskDao extends GenericDao<Task> {
return super.saveExisting(item);
}
/**
* Called before the task is saved.
* <ul>
* <li>Update notifications based on task status
* <li>Update associated calendar event
*
* @param database
* @param task
* task that was just changed
* @param values
* values that were changed
* @param duringSync
* whether this save occurs as part of a sync
*/
private void beforeSave(Task task, ContentValues values, boolean duringSync) {
//
}
/**
* Called after the task is saved.
* <ul>
@ -222,16 +204,16 @@ public class TaskDao extends GenericDao<Task> {
* @param database
* @param task task that was just changed
* @param values values to be persisted to the database
* @param duringSync whether this save occurs as part of a sync
* @param skipHooks whether this save occurs as part of a sync
*/
private void afterSave(Task task, ContentValues values, boolean duringSync) {
private void afterSave(Task task, ContentValues values, boolean skipHooks) {
if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted())
afterComplete(task, values, duringSync);
afterComplete(task, values, skipHooks);
else {
ReminderService.getInstance().scheduleAlarm(task);
}
if(duringSync)
if(skipHooks)
return;
// TODO due date was updated, update calendar event

@ -99,7 +99,7 @@ public class ReminderServiceTests extends DatabaseTestCase {
public void createAlarm(Task task, long time, int type) {
super.createAlarm(task, time, type);
assertTrue(time > DateUtilities.now());
assertTrue(time < DateUtilities.now() + DateUtilities.ONE_DAY);
assertTrue(time < DateUtilities.now() + 2 * DateUtilities.ONE_DAY);
assertEquals(type, ReminderService.TYPE_OVERDUE);
}
});

Loading…
Cancel
Save