mirror of
https://github.com/etesync/android
synced 2025-06-03 14:49:00 +00:00
Better reminder (VALARM) handling
* handle WEEKS in duration correctly (fixes #398) * handle positive and negative TRIGGER duration values correctly
This commit is contained in:
parent
f19d528739
commit
33958ab548
@ -511,7 +511,7 @@ public class LocalCalendar extends LocalCollection<Event> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void populateReminder(Event event, ContentValues row) throws RemoteException {
|
void populateReminder(Event event, ContentValues row) throws RemoteException {
|
||||||
VAlarm alarm = new VAlarm(new Dur(0, 0, row.getAsInteger(Reminders.MINUTES), 0));
|
VAlarm alarm = new VAlarm(new Dur(0, 0, -row.getAsInteger(Reminders.MINUTES), 0));
|
||||||
|
|
||||||
PropertyList props = alarm.getProperties();
|
PropertyList props = alarm.getProperties();
|
||||||
props.add(Action.DISPLAY);
|
props.add(Action.DISPLAY);
|
||||||
@ -722,11 +722,17 @@ public class LocalCalendar extends LocalCollection<Event> {
|
|||||||
protected Builder buildReminder(Builder builder, VAlarm alarm) {
|
protected Builder buildReminder(Builder builder, VAlarm alarm) {
|
||||||
int minutes = 0;
|
int minutes = 0;
|
||||||
|
|
||||||
Dur duration;
|
if (alarm.getTrigger() != null) {
|
||||||
if (alarm.getTrigger() != null && (duration = alarm.getTrigger().getDuration()) != null)
|
Dur duration = alarm.getTrigger().getDuration();
|
||||||
minutes = duration.getDays() * 24*60 + duration.getHours()*60 + duration.getMinutes();
|
if (duration != null) {
|
||||||
|
// negative value in TRIGGER means positive value in Reminders.MINUTES and vice versa
|
||||||
|
minutes = -(((duration.getWeeks() * 7 + duration.getDays()) * 24 + duration.getHours()) * 60 + duration.getMinutes());
|
||||||
|
if (duration.isNegative())
|
||||||
|
minutes *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Adding alarm " + minutes + " min before");
|
Log.d(TAG, "Adding alarm " + minutes + " minutes before");
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
.withValue(Reminders.METHOD, Reminders.METHOD_ALERT)
|
.withValue(Reminders.METHOD, Reminders.METHOD_ALERT)
|
||||||
|
Loading…
Reference in New Issue
Block a user