From 1bc117012c4d97ba1378dfc582b6ccff1c903196 Mon Sep 17 00:00:00 2001 From: Marten Gajda Date: Fri, 27 Sep 2019 17:22:03 +0200 Subject: [PATCH] Let Due and Time data not set recurrence values. Fixes #858 `DueData` and `TimeData` should not set recurrence values. That's not allowed on the instances table and, apparently, it's very unexpected and error prone. --- .../org/dmfs/opentaskspal/tasks/DueData.java | 11 ++--- .../org/dmfs/opentaskspal/tasks/TimeData.java | 11 ++--- .../dmfs/opentaskspal/tasks/DueDataTest.java | 24 ++--------- .../dmfs/opentaskspal/tasks/TimeDataTest.java | 40 +++---------------- 4 files changed, 14 insertions(+), 72 deletions(-) diff --git a/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/DueData.java b/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/DueData.java index 84e24e533..ad53dfea3 100644 --- a/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/DueData.java +++ b/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/DueData.java @@ -17,13 +17,14 @@ package org.dmfs.opentaskspal.tasks; import android.content.ContentProviderOperation; -import androidx.annotation.NonNull; import org.dmfs.android.contentpal.RowData; import org.dmfs.android.contentpal.TransactionContext; import org.dmfs.rfc5545.DateTime; import org.dmfs.tasks.contract.TaskContract; +import androidx.annotation.NonNull; + /** * {@link RowData} for setting only the due datetime of the task, for setting start as well use {@link TimeData}. @@ -49,14 +50,8 @@ public ContentProviderOperation.Builder updatedBuilder(@NonNull TransactionConte .withValue(TaskContract.Tasks.DUE, mDue.getTimestamp()) .withValue(TaskContract.Tasks.TZ, mDue.isAllDay() ? "UTC" : mDue.getTimeZone().getID()) .withValue(TaskContract.Tasks.IS_ALLDAY, mDue.isAllDay() ? 1 : 0) - .withValue(TaskContract.Tasks.DTSTART, null) - - .withValue(TaskContract.Tasks.DURATION, null) - - .withValue(TaskContract.Tasks.RDATE, null) - .withValue(TaskContract.Tasks.RRULE, null) - .withValue(TaskContract.Tasks.EXDATE, null); + .withValue(TaskContract.Tasks.DURATION, null); } } diff --git a/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/TimeData.java b/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/TimeData.java index afa1c0003..43799ab22 100644 --- a/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/TimeData.java +++ b/opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/TimeData.java @@ -17,7 +17,6 @@ package org.dmfs.opentaskspal.tasks; import android.content.ContentProviderOperation; -import androidx.annotation.NonNull; import org.dmfs.android.contentpal.RowData; import org.dmfs.android.contentpal.TransactionContext; @@ -28,6 +27,8 @@ import org.dmfs.rfc5545.Duration; import org.dmfs.tasks.contract.TaskContract; +import androidx.annotation.NonNull; + /** * {@link RowData} for adding start, start+due, or start+duration times. @@ -95,13 +96,7 @@ private static ContentProviderOperation.Builder doUpdateBuilder(DateTime start, .withValue(TaskContract.Tasks.DTSTART, start.getTimestamp()) .withValue(TaskContract.Tasks.TZ, start.isAllDay() ? "UTC" : start.getTimeZone().getID()) .withValue(TaskContract.Tasks.IS_ALLDAY, start.isAllDay() ? 1 : 0) - .withValue(TaskContract.Tasks.DUE, due.isPresent() ? due.value().getTimestamp() : null) - - .withValue(TaskContract.Tasks.DURATION, duration.isPresent() ? duration.value().toString() : null) - - .withValue(TaskContract.Tasks.RDATE, null) - .withValue(TaskContract.Tasks.RRULE, null) - .withValue(TaskContract.Tasks.EXDATE, null); + .withValue(TaskContract.Tasks.DURATION, duration.isPresent() ? duration.value().toString() : null); } } diff --git a/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/DueDataTest.java b/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/DueDataTest.java index 461ba9829..cc6a99ed8 100644 --- a/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/DueDataTest.java +++ b/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/DueDataTest.java @@ -53,14 +53,8 @@ public void test_whenNoTimeZoneNotAllDay_setsValuesAccordingly_andNullsOtherTime containing(Tasks.DUE, due.getTimestamp()), containing(Tasks.TZ, "UTC"), containing(Tasks.IS_ALLDAY, 0), - withNullValue(Tasks.DTSTART), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } @@ -76,14 +70,8 @@ public void test_whenHasTimeZoneNotAllDay_setsValuesAccordingly_andNullsOtherTim containing(Tasks.DUE, due.getTimestamp()), containing(Tasks.TZ, "GMT+04:00"), containing(Tasks.IS_ALLDAY, 0), - withNullValue(Tasks.DTSTART), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } @@ -99,14 +87,8 @@ public void test_whenNoTimeZoneAndAllDay_setsValuesAccordingly_andNullsOtherTime containing(Tasks.DUE, due.getTimestamp()), containing(Tasks.TZ, "UTC"), containing(Tasks.IS_ALLDAY, 1), - withNullValue(Tasks.DTSTART), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } diff --git a/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/TimeDataTest.java b/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/TimeDataTest.java index 592f0d53a..f9c767532 100644 --- a/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/TimeDataTest.java +++ b/opentaskspal/src/test/java/org/dmfs/opentaskspal/tasks/TimeDataTest.java @@ -58,14 +58,8 @@ public void test_whenStartAndDueAreProvided_setsThemAndNullsDuration() containing(Tasks.DTSTART, start.getTimestamp()), containing(Tasks.TZ, "UTC"), containing(Tasks.IS_ALLDAY, 0), - containing(Tasks.DUE, due.getTimestamp()), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } @@ -82,14 +76,8 @@ public void test_whenStartAndDurationAreProvided_setsThemAndNullsDue() containing(Tasks.DTSTART, start.getTimestamp()), containing(Tasks.TZ, "UTC"), containing(Tasks.IS_ALLDAY, 0), - withNullValue(Tasks.DUE), - - containing(Tasks.DURATION, duration.toString()), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + containing(Tasks.DURATION, duration.toString()) ))); } @@ -105,14 +93,8 @@ public void test_whenOnlyStartIsProvided_setsItAndNullsDueAndDuration() containing(Tasks.DTSTART, start.getTimestamp()), containing(Tasks.TZ, "UTC"), containing(Tasks.IS_ALLDAY, 0), - withNullValue(Tasks.DUE), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } @@ -147,14 +129,8 @@ public void test_whenStartHasDifferentTimeZoneFromDue_shiftsStartsToDue() containing(Tasks.DTSTART, startExpected.getTimestamp()), containing(Tasks.TZ, "GMT+06:00"), containing(Tasks.IS_ALLDAY, 0), - containing(Tasks.DUE, due.getTimestamp()), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } @@ -171,14 +147,8 @@ public void test_whenStartHasAllDayFlag_correspondingValueIsOne() containing(Tasks.DTSTART, start.getTimestamp()), containing(Tasks.TZ, "UTC"), containing(Tasks.IS_ALLDAY, 1), - containing(Tasks.DUE, due.getTimestamp()), - - withNullValue(Tasks.DURATION), - - withNullValue(Tasks.RDATE), - withNullValue(Tasks.RRULE), - withNullValue(Tasks.EXDATE) + withNullValue(Tasks.DURATION) ))); } } \ No newline at end of file