diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerCalendar.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerCalendar.java index 097c093..6c2280e 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerCalendar.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerCalendar.java @@ -53,8 +53,6 @@ public class ActivityManageTriggerCalendar extends Activity Miscellaneous.setDisplayLanguage(this); setContentView(R.layout.activity_manage_trigger_calendar); - //TODO: Hint text about multiple rule execution and reoccurring events always being included in the query - chkCalendarEventActive = (CheckBox) findViewById(R.id.chkCalendarEventActive); spinnerCalendarTitleDirection = (Spinner)findViewById(R.id.spinnerCalendarTitleDirection); spinnerCalendarLocationDirection = (Spinner)findViewById(R.id.spinnerCalendarLocationDirection); 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 935ed8c..5e331d6 100644 --- a/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java +++ b/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java @@ -40,7 +40,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis static List calendarsCache = null; static List calendarEventsCache = null; - static List calendarEventsReoccuringCache = null; + static List calendarEventsReoccurringCache = null; static Timer timer = null; static TimerTask timerTask = null; @@ -90,6 +90,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis calendarsCache = null; calendarEventsCache = null; + calendarEventsReoccurringCache = null; checkForRules(context); armOrRearmTimer(); @@ -128,6 +129,10 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis calendarReceiverInstance = null; } + calendarsCache = null; + calendarEventsCache = null; + calendarEventsReoccurringCache = null; + calendarReceiverActive = false; } } @@ -327,9 +332,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis } - if(includeReoccurring && calendarEventsReoccuringCache == null) + if(includeReoccurring && calendarEventsReoccurringCache == null) { - calendarEventsReoccuringCache = new ArrayList<>(); + calendarEventsReoccurringCache = new ArrayList<>(); Cursor cursor; @@ -394,7 +399,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis if(includePastEvents || event.end.getTimeInMillis() > now.getTimeInMillis()) { // For the moment keeping separate records to some extent - calendarEventsReoccuringCache.add(event); + calendarEventsReoccurringCache.add(event); calendarEventsCache.add(event); } } @@ -574,6 +579,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis public static boolean mayRuleStillBeActivatedForPendingCalendarEvents(Rule rule) { + for(RuleEventPair pair : calendarEventsUsed) + Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingCalendarEvents()", "Existing pair of " + pair.rule.getName() + " and " + pair.event, 5); + for(CalendarEvent event : readCalendarEvents(Miscellaneous.getAnyContext(), true,false)) { for(Trigger t : rule.getTriggerSet()) @@ -581,7 +589,10 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis if(t.getTriggerType().equals(Trigger.Trigger_Enum.calendarEvent) && t.checkCalendarEvent(event, false)) { if (!hasEventBeenUsedInRule(rule, event)) + { + Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingCalendarEvents()", "Rule " + rule.getName() + " has not been used in conjunction with event " + event, 4); return true; + } } } } diff --git a/app/src/main/res/layout/activity_manage_trigger_calendar.xml b/app/src/main/res/layout/activity_manage_trigger_calendar.xml index 2b7891d..f73f587 100644 --- a/app/src/main/res/layout/activity_manage_trigger_calendar.xml +++ b/app/src/main/res/layout/activity_manage_trigger_calendar.xml @@ -16,6 +16,11 @@ android:textSize="25dp" android:layout_marginBottom="@dimen/default_margin" /> + + event is not reoccurring event is reoccurring reoccurring + If your calendar holds multiple events in parallel, a rule would get executed as many time as there are events. The same goes for eventsthat directly follow each other. \ No newline at end of file