From 35acb15c9113c68259d7b45b7209ad2921383489 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 14 Mar 2013 10:55:17 -0700 Subject: [PATCH] Sanity check for weird repeat values --- .../astrid/actfm/sync/AstridNewSyncMigrator.java | 7 +++++-- .../actfm/sync/messages/ChangesHappened.java | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java index 8fe916556..a894abfd1 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/AstridNewSyncMigrator.java @@ -170,12 +170,15 @@ public class AstridNewSyncMigrator { String recurrence = instance.getValue(Task.RECURRENCE); if (!TextUtils.isEmpty(recurrence)) { + String fromCompletion = ";FROM=COMPLETION"; boolean repeatAfterCompletion = instance.getFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION); instance.setFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION, false); recurrence = recurrence.replaceAll("BYDAY=;", ""); - if (repeatAfterCompletion) - recurrence = recurrence + ";FROM=COMPLETION"; + if (fromCompletion.equals(recurrence)) + recurrence = ""; + else if (repeatAfterCompletion) + recurrence = recurrence + fromCompletion; instance.setValue(Task.RECURRENCE, recurrence); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ChangesHappened.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ChangesHappened.java index 12cd11537..ac07e0d69 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ChangesHappened.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/ChangesHappened.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import org.apache.http.entity.mime.MultipartEntity; import org.apache.http.entity.mime.content.FileBody; @@ -110,6 +111,7 @@ public class ChangesHappened valueRef = new AtomicReference(); for (OE change : changes) { try { String localColumn = change.getValue(OutstandingEntry.COLUMN_STRING_PROPERTY); @@ -150,9 +152,12 @@ public class ChangesHappened property, Object value) { + private boolean validateValue(Property property, AtomicReference valueRef) { if (Task.TITLE.equals(property)) { - if (!(value instanceof String) || TextUtils.isEmpty((String) value)) + if (!(valueRef.get() instanceof String) || TextUtils.isEmpty((String) valueRef.get())) return false; + } else if (Task.RECURRENCE.equals(property)) { + if (";FROM=COMPLETION".equals(valueRef.get())) + valueRef.set(""); } return true; }