Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
ical4android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
bitfire web engineering
ical4android
Commits
be1e1e9b
Commit
be1e1e9b
authored
Apr 20, 2017
by
Ricki Hirner
🐑
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle events with zero duration correctly (convert to all-day event)
parent
2f6a94e8
Pipeline
#7765078
passed with stage
in 7 minutes and 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
src/androidTest/java/at/bitfire/ical4android/AndroidEventTest.java
...idTest/java/at/bitfire/ical4android/AndroidEventTest.java
+39
-1
src/main/java/at/bitfire/ical4android/AndroidEvent.java
src/main/java/at/bitfire/ical4android/AndroidEvent.java
+1
-0
No files found.
src/androidTest/java/at/bitfire/ical4android/AndroidEventTest.java
View file @
be1e1e9b
...
...
@@ -33,6 +33,7 @@ import net.fortuna.ical4j.model.parameter.Value;
import
net.fortuna.ical4j.model.property.Attendee
;
import
net.fortuna.ical4j.model.property.DtEnd
;
import
net.fortuna.ical4j.model.property.DtStart
;
import
net.fortuna.ical4j.model.property.Duration
;
import
net.fortuna.ical4j.model.property.ExDate
;
import
net.fortuna.ical4j.model.property.Organizer
;
import
net.fortuna.ical4j.model.property.RRule
;
...
...
@@ -248,7 +249,7 @@ public class AndroidEventTest extends InstrumentationTestCase {
}
}
public
void
test
BuildAllDayEntr
y
()
throws
ParseException
,
FileNotFoundException
,
CalendarStorageException
{
public
void
test
AllDa
y
()
throws
ParseException
,
FileNotFoundException
,
CalendarStorageException
{
// add all-day event to calendar provider
Event
event
=
new
Event
();
event
.
summary
=
"All-day event"
;
...
...
@@ -272,6 +273,24 @@ public class AndroidEventTest extends InstrumentationTestCase {
assertTrue
(
event2
.
isAllDay
());
}
public
void
testAllDayWithoutDuration
()
throws
ParseException
,
FileNotFoundException
,
CalendarStorageException
{
// add all-day event with 0 sec duration to calendar provider
Event
event
=
new
Event
();
event
.
summary
=
"Event without duration"
;
event
.
dtStart
=
new
DtStart
(
new
Date
(
"20150501"
));
event
.
duration
=
new
Duration
(
new
Dur
(
"PT0S"
));
Uri
uri
=
new
TestEvent
(
calendar
,
event
).
add
();
assertNotNull
(
"Couldn't add event"
,
uri
);
// read again and verify result
@Cleanup
(
"delete"
)
TestEvent
testEvent
=
new
TestEvent
(
calendar
,
ContentUris
.
parseId
(
uri
));
Event
event2
=
testEvent
.
getEvent
();
// should now be an all-day event (converted by ical4android because events without duration don't show up in Android calendar)
assertEquals
(
event
.
dtStart
,
event2
.
dtStart
);
assertEquals
(
event
.
dtStart
.
getDate
().
getTime
()
+
86400000
,
event2
.
dtEnd
.
getDate
().
getTime
());
assertTrue
(
event2
.
isAllDay
());
}
public
void
testNoOrganizerWithoutAttendees
()
throws
ParseException
,
URISyntaxException
,
CalendarStorageException
,
FileNotFoundException
{
Event
event
=
new
Event
();
event
.
summary
=
"Not a group-scheduled event"
;
...
...
@@ -311,4 +330,23 @@ public class AndroidEventTest extends InstrumentationTestCase {
assertNull
(
testEvent
.
getEvent
().
dtEnd
);
}
public
void
testWithoutDuration
()
throws
ParseException
,
FileNotFoundException
,
CalendarStorageException
{
// add event with 0 sec duration to calendar provider
Event
event
=
new
Event
();
event
.
summary
=
"Event without duration"
;
event
.
dtStart
=
new
DtStart
(
new
Date
(
"20150501T152010Z"
));
event
.
duration
=
new
Duration
(
new
Dur
(
"PT0S"
));
Uri
uri
=
new
TestEvent
(
calendar
,
event
).
add
();
assertNotNull
(
"Couldn't add event"
,
uri
);
// read again and verify result
@Cleanup
(
"delete"
)
TestEvent
testEvent
=
new
TestEvent
(
calendar
,
ContentUris
.
parseId
(
uri
));
Event
event2
=
testEvent
.
getEvent
();
// should now be an all-day event (converted by ical4android because events without duration don't show up in Android calendar)
assertEquals
(
event
.
dtStart
,
event2
.
dtStart
);
assertEquals
(
event
.
dtStart
.
getDate
().
getTime
()
+
86400000
,
event2
.
dtEnd
.
getDate
().
getTime
());
assertTrue
(
event2
.
isAllDay
());
}
}
src/main/java/at/bitfire/ical4android/AndroidEvent.java
View file @
be1e1e9b
...
...
@@ -530,6 +530,7 @@ public abstract class AndroidEvent {
c
.
setTime
(
event
.
dtStart
.
getDate
());
c
.
add
(
java
.
util
.
Calendar
.
DATE
,
1
);
event
.
dtEnd
=
new
DtEnd
(
new
Date
(
c
.
getTimeInMillis
()));
event
.
duration
=
null
;
}
/* For cases where a "VEVENT" calendar component
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment