diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java index 004eb99ec..fa75954fe 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevFilterExposer.java @@ -47,8 +47,8 @@ public class ProducteevFilterExposer extends BroadcastReceiver { values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY); values.put(ProducteevTask.DASHBOARD_ID.name, dashboard.getId()); values.put(ProducteevTask.ID.name, 0); - values.put(ProducteevTask.CREATOR_ID.name, 0); - values.put(ProducteevTask.RESPONSIBLE_ID.name, 0); + values.put(ProducteevTask.CREATOR_ID.name, currentUserId); + values.put(ProducteevTask.RESPONSIBLE_ID.name, currentUserId); Filter filter; if (currentUserId != -1) filter = new Filter(dashboardTitle, title, new QueryTemplate().join( @@ -97,7 +97,7 @@ public class ProducteevFilterExposer extends BroadcastReceiver { values.put(Metadata.KEY.name, ProducteevTask.METADATA_KEY); values.put(ProducteevTask.ID.name, 0); values.put(ProducteevTask.CREATOR_ID.name, 0); - values.put(ProducteevTask.RESPONSIBLE_ID.name, user.getId()); + values.put(ProducteevTask.RESPONSIBLE_ID.name, currentUserId); Filter filter = new Filter(user.toString(), title, new QueryTemplate().join( ProducteevDataService.METADATA_JOIN).where(Criterion.and( MetadataCriteria.withKey(ProducteevTask.METADATA_KEY), diff --git a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java index 60c624dff..fd5d49dc5 100644 --- a/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java +++ b/astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java @@ -21,6 +21,7 @@ import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.utility.Flags; public class RepeatTaskCompleteListener extends BroadcastReceiver { @@ -73,6 +74,7 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver { broadcastIntent.putExtra(AstridApiConstants.EXTRAS_OLD_DUE_DATE, task.getValue(Task.DUE_DATE)); broadcastIntent.putExtra(AstridApiConstants.EXTRAS_NEW_DUE_DATE, newDueDate); context.sendOrderedBroadcast(broadcastIntent, null); + Flags.set(Flags.REFRESH); } } @@ -82,15 +84,24 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver { DateValue today = new DateValueImpl(repeatFromDate.getYear() + 1900, repeatFromDate.getMonth() + 1, repeatFromDate.getDate()); - if(task.hasDueDate() && !task.getFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION)) { + boolean repeatAfterCompletion = task.getFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION); + if(task.hasDueDate() && !repeatAfterCompletion) { repeatFromDate = new Date(task.getValue(Task.DUE_DATE)); if(task.hasDueTime()) { repeatFrom = new DateTimeValueImpl(repeatFromDate.getYear() + 1900, repeatFromDate.getMonth() + 1, repeatFromDate.getDate(), repeatFromDate.getHours(), repeatFromDate.getMinutes(), repeatFromDate.getSeconds()); } else { - repeatFrom = new DateValueImpl(repeatFromDate.getYear() + 1900, - repeatFromDate.getMonth() + 1, repeatFromDate.getDate()); + repeatFrom = today; + } + } else if (task.hasDueDate() && repeatAfterCompletion) { + repeatFromDate = new Date(task.getValue(Task.DUE_DATE)); + if(task.hasDueTime()) { + repeatFrom = new DateTimeValueImpl(today.year(), + today.month(), today.day(), + repeatFromDate.getHours(), repeatFromDate.getMinutes(), repeatFromDate.getSeconds()); + } else { + repeatFrom = today; } } else { repeatFrom = today; @@ -141,7 +152,7 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver { nextDate.day()).getTime()); } - if(newDueDate > DateUtilities.now() && newDueDate != repeatFromDate.getTime()) + if(newDueDate > DateUtilities.now() && (repeatAfterCompletion || (newDueDate != repeatFromDate.getTime()))) break; } diff --git a/astrid/src/com/todoroo/astrid/dao/TaskDao.java b/astrid/src/com/todoroo/astrid/dao/TaskDao.java index f2fbad3f5..8da00587e 100644 --- a/astrid/src/com/todoroo/astrid/dao/TaskDao.java +++ b/astrid/src/com/todoroo/astrid/dao/TaskDao.java @@ -175,12 +175,6 @@ public class TaskDao extends DatabaseDao { @Override public boolean createNew(Task item) { - ContentValues values = item.getSetValues(); - if(values == null || values.size() == 0) { - if(item.getDatabaseValues() != null) - return false; - } - if(!item.containsValue(Task.CREATION_DATE)) item.setValue(Task.CREATION_DATE, DateUtilities.now()); item.setValue(Task.MODIFICATION_DATE, DateUtilities.now()); diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java index 8f3af2934..3514a19f1 100644 --- a/astrid/src/com/todoroo/astrid/service/TaskService.java +++ b/astrid/src/com/todoroo/astrid/service/TaskService.java @@ -115,15 +115,17 @@ public class TaskService { for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { metadata.readFromCursor(cursor); - // don't clone sync metadata if(GtasksMetadata.METADATA_KEY.equals(metadata.getValue(Metadata.KEY))) - continue; + { + metadata.setValue(GtasksMetadata.ID, "0"); + } if(ProducteevTask.METADATA_KEY.equals(metadata.getValue(Metadata.KEY))) - continue; + { + metadata.setValue(ProducteevTask.ID, 0L); + } + // don't clone sync metadata if(MilkTaskFields.METADATA_KEY.equals(metadata.getValue(Metadata.KEY))) - continue; - if(OpencrxCoreUtils.OPENCRX_ACTIVITY_METADATA_KEY.equals(metadata.getValue(Metadata.KEY))) - continue; + continue; // FIXME do the same as for the others metadata.setValue(Metadata.TASK, newId); metadata.clearValue(Metadata.ID);