Skip to content

Commit

Permalink
Let DueData and TimeData not set recurrence values. Fixes #858 (#859)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
dmfs authored Sep 27, 2019
1 parent 598a6c7 commit 230e212
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)));
}

Expand All @@ -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)
)));
}

Expand All @@ -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)
)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)));
}

Expand All @@ -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())
)));
}

Expand All @@ -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)
)));
}

Expand Down Expand Up @@ -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)
)));
}

Expand All @@ -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)
)));
}
}

0 comments on commit 230e212

Please sign in to comment.