diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index cd1b88c3..c8d522a4 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -622,7 +622,7 @@ public class Trigger try { String[] conditions = this.getTriggerParameter2().split(Trigger.triggerParameter2Split); - List calendarEvents = CalendarReceiver.readCalendarEvents(AutomationService.getInstance()); + List calendarEvents = CalendarReceiver.readCalendarEvents(AutomationService.getInstance(), false); /* 0 = titleDirection diff --git a/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java b/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java index 053b76b9..35adc998 100644 --- a/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java +++ b/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java @@ -107,7 +107,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis } } - public static List readCalendarEvents(Context context) + public static List readCalendarEvents(Context context, boolean includePastEvents) { Cursor cursor; @@ -128,6 +128,8 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis List eventlist = new ArrayList<>(); + Calendar now = Calendar.getInstance(); + for (int i = 0; i < CNames.length; i++) { try @@ -142,7 +144,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis event.end = Miscellaneous.calendarFromLong(Long.parseLong(cursor.getString(6))); event.location = cursor.getString(7); event.availability = cursor.getString(8); - eventlist.add(event); + + if(includePastEvents || event.end.getTimeInMillis() > now.getTimeInMillis()) + eventlist.add(event); } catch (Exception e) {}