forked from jens/Automation
Calendar trigger
This commit is contained in:
parent
4521bc7d4e
commit
8c4b75232e
@ -53,8 +53,6 @@ public class ActivityManageTriggerCalendar extends Activity
|
|||||||
Miscellaneous.setDisplayLanguage(this);
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_calendar);
|
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);
|
chkCalendarEventActive = (CheckBox) findViewById(R.id.chkCalendarEventActive);
|
||||||
spinnerCalendarTitleDirection = (Spinner)findViewById(R.id.spinnerCalendarTitleDirection);
|
spinnerCalendarTitleDirection = (Spinner)findViewById(R.id.spinnerCalendarTitleDirection);
|
||||||
spinnerCalendarLocationDirection = (Spinner)findViewById(R.id.spinnerCalendarLocationDirection);
|
spinnerCalendarLocationDirection = (Spinner)findViewById(R.id.spinnerCalendarLocationDirection);
|
||||||
|
@ -40,7 +40,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
|
|
||||||
static List<AndroidCalendar> calendarsCache = null;
|
static List<AndroidCalendar> calendarsCache = null;
|
||||||
static List<CalendarEvent> calendarEventsCache = null;
|
static List<CalendarEvent> calendarEventsCache = null;
|
||||||
static List<CalendarEvent> calendarEventsReoccuringCache = null;
|
static List<CalendarEvent> calendarEventsReoccurringCache = null;
|
||||||
|
|
||||||
static Timer timer = null;
|
static Timer timer = null;
|
||||||
static TimerTask timerTask = null;
|
static TimerTask timerTask = null;
|
||||||
@ -90,6 +90,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
|
|
||||||
calendarsCache = null;
|
calendarsCache = null;
|
||||||
calendarEventsCache = null;
|
calendarEventsCache = null;
|
||||||
|
calendarEventsReoccurringCache = null;
|
||||||
|
|
||||||
checkForRules(context);
|
checkForRules(context);
|
||||||
armOrRearmTimer();
|
armOrRearmTimer();
|
||||||
@ -128,6 +129,10 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
calendarReceiverInstance = null;
|
calendarReceiverInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calendarsCache = null;
|
||||||
|
calendarEventsCache = null;
|
||||||
|
calendarEventsReoccurringCache = null;
|
||||||
|
|
||||||
calendarReceiverActive = false;
|
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;
|
Cursor cursor;
|
||||||
|
|
||||||
@ -394,7 +399,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
if(includePastEvents || event.end.getTimeInMillis() > now.getTimeInMillis())
|
if(includePastEvents || event.end.getTimeInMillis() > now.getTimeInMillis())
|
||||||
{
|
{
|
||||||
// For the moment keeping separate records to some extent
|
// For the moment keeping separate records to some extent
|
||||||
calendarEventsReoccuringCache.add(event);
|
calendarEventsReoccurringCache.add(event);
|
||||||
calendarEventsCache.add(event);
|
calendarEventsCache.add(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -574,6 +579,9 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
|
|
||||||
public static boolean mayRuleStillBeActivatedForPendingCalendarEvents(Rule rule)
|
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(CalendarEvent event : readCalendarEvents(Miscellaneous.getAnyContext(), true,false))
|
||||||
{
|
{
|
||||||
for(Trigger t : rule.getTriggerSet())
|
for(Trigger t : rule.getTriggerSet())
|
||||||
@ -581,10 +589,13 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
|
|||||||
if(t.getTriggerType().equals(Trigger.Trigger_Enum.calendarEvent) && t.checkCalendarEvent(event, false))
|
if(t.getTriggerType().equals(Trigger.Trigger_Enum.calendarEvent) && t.checkCalendarEvent(event, false))
|
||||||
{
|
{
|
||||||
if (!hasEventBeenUsedInRule(rule, event))
|
if (!hasEventBeenUsedInRule(rule, event))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingCalendarEvents()", "Rule " + rule.getName() + " has not been used in conjunction with event " + event, 4);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
android:textSize="25dp"
|
android:textSize="25dp"
|
||||||
android:layout_marginBottom="@dimen/default_margin" />
|
android:layout_marginBottom="@dimen/default_margin" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/calendarTriggerExecutionHints"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -939,4 +939,5 @@
|
|||||||
<string name="reoccurringFalse">event is not reoccurring</string>
|
<string name="reoccurringFalse">event is not reoccurring</string>
|
||||||
<string name="reoccurringTrue">event is reoccurring</string>
|
<string name="reoccurringTrue">event is reoccurring</string>
|
||||||
<string name="reoccurring">reoccurring</string>
|
<string name="reoccurring">reoccurring</string>
|
||||||
|
<string name="calendarTriggerExecutionHints">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.</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user