diff --git a/app/src/main/java/com/jens/automation2/Action.java b/app/src/main/java/com/jens/automation2/Action.java index def6b93..9c9640e 100644 --- a/app/src/main/java/com/jens/automation2/Action.java +++ b/app/src/main/java/com/jens/automation2/Action.java @@ -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(); diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index b9fa566..1e6a294 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -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. */ diff --git a/app/src/main/java/com/jens/automation2/ActivityManageActionTriggerUrl.java b/app/src/main/java/com/jens/automation2/ActivityManageActionTriggerUrl.java index 9cb537f..5ed0b13 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageActionTriggerUrl.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageActionTriggerUrl.java @@ -257,7 +257,7 @@ public class ActivityManageActionTriggerUrl extends Activity { if(lvTriggerUrlPostParameters.getAdapter() == null) lvTriggerUrlPostParameters.setAdapter(lvTriggerUrlPostParametersAdapter); - + lvTriggerUrlPostParametersAdapter.notifyDataSetChanged(); } catch(NullPointerException e) diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index 078d550..584fde8 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -621,52 +621,31 @@ public class Trigger { try { - String[] conditions = this.getTriggerParameter2().split(Trigger.triggerParameter2Split); List 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; 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 ef0064e..c0ef73a 100644 --- a/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java +++ b/app/src/main/java/com/jens/automation2/receivers/CalendarReceiver.java @@ -42,6 +42,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis static List calendarEventsCache = null; static List calendarEventsReoccurringCache = null; + // To determine for which events which rules have been executed + static List 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 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 calendarlist = new ArrayList<>(); - for (int i = 0; i < CNames.length; i++) { try