Calendar trigger
This commit is contained in:
parent
553d14b05f
commit
dfe8594f06
@ -734,7 +734,8 @@ public class Action
|
||||
try
|
||||
{
|
||||
url = Miscellaneous.replaceVariablesInText(url, context);
|
||||
params = Miscellaneous.replaceVariablesInText(params, context);
|
||||
if(!StringUtils.isEmpty(params))
|
||||
params = Miscellaneous.replaceVariablesInText(params, context);
|
||||
|
||||
Actions myAction = new Actions();
|
||||
|
||||
|
@ -735,7 +735,6 @@ public class Actions
|
||||
if (method == null)
|
||||
throw new NoSuchMethodException();
|
||||
|
||||
|
||||
/*
|
||||
* For some reason this doesn't work, throws NoSuchMethodExpection even if the method is present.
|
||||
*/
|
||||
|
@ -621,52 +621,31 @@ public class Trigger
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] conditions = this.getTriggerParameter2().split(Trigger.triggerParameter2Split);
|
||||
List<CalendarReceiver.CalendarEvent> calendarEvents = CalendarReceiver.readCalendarEvents(AutomationService.getInstance(), true,false);
|
||||
|
||||
/*
|
||||
0 = titleDirection
|
||||
1 = title;
|
||||
2 = descriptionDirection
|
||||
3 = description
|
||||
4 = eventLocationDirection
|
||||
5 = eventLocation
|
||||
6 = evaluate all day event
|
||||
7 = all day event
|
||||
8 = availabilityList
|
||||
9 = calendarList
|
||||
*/
|
||||
|
||||
for(CalendarReceiver.CalendarEvent event : calendarEvents)
|
||||
{
|
||||
if(!checkCalendarEvent(event, ignoreActive))
|
||||
continue;
|
||||
|
||||
// No contradictions found
|
||||
Miscellaneous.logEvent("i", "CalendarCheck", "Event " + event + " matches.", 4);
|
||||
|
||||
/*
|
||||
At this point the rule will either get executed for this event or it already has been executed for it.
|
||||
*/
|
||||
//TODO: This line alone does not suffice and might also not be correct in some cases
|
||||
CalendarReceiver.addUsedPair(new CalendarReceiver.RuleEventPair(getParentRule(), event));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// At this point none of the calendar items matches this trigger
|
||||
// At this point none of the calendar items match this trigger
|
||||
|
||||
// If trigger demands no calendar event and there is absolutely no future event, we'll need to check for that.
|
||||
if(calendarEvents.size() == 0)
|
||||
{
|
||||
if(getTriggerParameter() == false)
|
||||
return true;
|
||||
|
||||
// Further criteria don't matter if there are no events to check
|
||||
}
|
||||
/*
|
||||
If trigger demands no calendar event and there is absolutely no future event,
|
||||
further criteria don't matter if there are no events to check.
|
||||
*/
|
||||
if(calendarEvents.size() == 0 && getTriggerParameter() == false)
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "checkVariable()", Log.getStackTraceString(e), 1);
|
||||
Miscellaneous.logEvent("e", "checkCalendarEvent()", Log.getStackTraceString(e), 1);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -42,6 +42,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
static List<CalendarEvent> calendarEventsCache = null;
|
||||
static List<CalendarEvent> calendarEventsReoccurringCache = null;
|
||||
|
||||
// To determine for which events which rules have been executed
|
||||
static List<RuleEventPair> calendarEventsUsed = new ArrayList<>();
|
||||
|
||||
static Timer timer = null;
|
||||
static TimerTask timerTask = null;
|
||||
static Calendar nextWakeup = null;
|
||||
@ -59,8 +62,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
this.event = event;
|
||||
}
|
||||
}
|
||||
// To determine for which events which rules have been executed
|
||||
static List<RuleEventPair> calendarEventsUsed = new ArrayList<>();
|
||||
|
||||
public static void addUsedPair(RuleEventPair pair)
|
||||
{
|
||||
// Add pair only if it's not in the list already.
|
||||
@ -188,7 +190,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return title;
|
||||
return "Title: " + title + ", location: " + location + ", description: " + description + ", start: " + Miscellaneous.formatDate(start.getTime()) + ", end: " + Miscellaneous.formatDate(end.getTime()) + ", is currently active: " + String.valueOf(isCurrentlyActive()) + ", all day: " + String.valueOf(allDay) + ", availability: " + availability;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -241,8 +243,6 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
||||
// fetching calendars name
|
||||
String CNames[] = new String[cursor.getCount()];
|
||||
|
||||
List<AndroidCalendar> calendarlist = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < CNames.length; i++)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user