forked from jens/Automation
Calendar trigger
This commit is contained in:
@ -10,9 +10,12 @@ import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.gms.location.DetectedActivity;
|
||||
import com.jens.automation2.receivers.ActivityDetectionReceiver;
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
import com.jens.automation2.receivers.CalendarReceiver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -376,6 +379,11 @@ public class Rule implements Comparable<Rule>
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
|
||||
return true;
|
||||
}
|
||||
else if(hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent) && CalendarReceiver.mayRuleStillBeActivatedForPendingCalendarEvents(this))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies, has not flipped since its last execution, but may still be executed for other calendar events.", 4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
|
||||
}
|
||||
@ -384,7 +392,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean applies(Context context)
|
||||
{
|
||||
if(AutomationService.getInstance() == null)
|
||||
@ -780,4 +788,32 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj)
|
||||
{
|
||||
return this.getName().equals(((Rule)obj).getName());
|
||||
}
|
||||
|
||||
public boolean hasTriggerOfType(Trigger.Trigger_Enum queryType)
|
||||
{
|
||||
for(Trigger t : getTriggerSet())
|
||||
{
|
||||
if(t.getTriggerType().equals(queryType))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasActionOfType(Action.Action_Enum queryType)
|
||||
{
|
||||
for(Action a : getActionSet())
|
||||
{
|
||||
if(a.getAction().equals(queryType))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user