Reoccuring time trigger

This commit is contained in:
jens 2021-11-13 02:17:36 +01:00
parent 9cea3f4285
commit 06a6651fae
9 changed files with 268 additions and 56 deletions

View File

@ -988,6 +988,32 @@ public class Rule implements Comparable<Rule>
} }
} }
public boolean haveTriggersReallyChanged(Object triggeringObject)
{
boolean returnValue = false;
try
{
for(int i=0; i < triggerSet.size(); i++)
{
Trigger t = (Trigger) triggerSet.get(i);
if(t.hasStateRecentlyNotApplied(triggeringObject))
{
Miscellaneous.logEvent("i", "Rule", "Rule \"" + getName() + "\" has trigger that flipped: " + t.toString(), 4);
returnValue = true; // only 1 trigger needs to have flipped recently
}
}
return returnValue;
}
catch(Exception e)
{
Miscellaneous.logEvent("e", "Rule", "Error while checking if rule \"" + getName() + "\" haveTriggersReallyChanged(): " + Log.getStackTraceString(e), 1);
return false;
}
}
/** /**
* Will activate the rule. Should be called by a separate execution thread * Will activate the rule. Should be called by a separate execution thread
* @param automationService * @param automationService
@ -998,8 +1024,9 @@ public class Rule implements Comparable<Rule>
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this); boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
boolean doToggle = ruleToggle && isActuallyToggable; boolean doToggle = ruleToggle && isActuallyToggable;
boolean triggersApplyAnew = haveTriggersReallyChanged(new Date());
if(notLastActive || force || doToggle) if(notLastActive || force || doToggle || triggersApplyAnew)
{ {
String message; String message;
if(!doToggle) if(!doToggle)

View File

@ -1,11 +1,14 @@
package com.jens.automation2; package com.jens.automation2;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Notification;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.os.Looper; import android.os.Looper;
import android.os.Parcelable;
import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
@ -32,6 +35,11 @@ import static com.jens.automation2.Trigger.triggerParameter2Split;
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT; import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT;
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE; import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE;
import androidx.core.app.NotificationCompat;
import org.apache.commons.lang3.StringUtils;
public class Rule implements Comparable<Rule> public class Rule implements Comparable<Rule>
{ {
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>(); private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
@ -762,13 +770,13 @@ public class Rule implements Comparable<Rule>
String myApp = params[0]; String myApp = params[0];
String myTitleDir = params[1]; String myTitleDir = params[1];
String myTitle = params[2]; String requiredTitle = params[2];
String myTextDir = params[3]; String myTextDir = params[3];
String myText; String requiredText;
if (params.length >= 5) if (params.length >= 5)
myText = params[4]; requiredText = params[4];
else else
myText = ""; requiredText = "";
if(oneTrigger.getTriggerParameter()) if(oneTrigger.getTriggerParameter())
{ {
@ -780,38 +788,65 @@ public class Rule implements Comparable<Rule>
{ {
if(getLastExecution() == null || sbn.getPostTime() > this.lastExecution.getTimeInMillis()) if(getLastExecution() == null || sbn.getPostTime() > this.lastExecution.getTimeInMillis())
{ {
String app = sbn.getPackageName(); String notificationApp = sbn.getPackageName();
String title = sbn.getNotification().extras.getString(EXTRA_TITLE); String notificationTitle = null;
String text = sbn.getNotification().extras.getString(EXTRA_TEXT); String notificationText = null;
Miscellaneous.logEvent("i", "NotificationCheck", "Checking if this notification matches our rule " + this.getName() + ". App: " + app + ", title: " + title + ", text: " + text, 5); Miscellaneous.logEvent("i", "NotificationCheck", "Checking if this notification matches our rule " + this.getName() + ". App: " + notificationApp + ", title: " + notificationTitle + ", text: " + notificationText, 5);
if (!myApp.equals("-1")) if (!myApp.equals("-1"))
{ {
if (!app.equalsIgnoreCase(myApp)) if (!notificationApp.equalsIgnoreCase(myApp))
{ {
Miscellaneous.logEvent("i", "NotificationCheck", "Notification app name does not match rule.", 5); Miscellaneous.logEvent("i", "NotificationCheck", "Notification app name does not match rule.", 5);
continue; continue;
} }
} }
else
if (myTitle.length() > 0)
{ {
if (!Miscellaneous.compare(myTitleDir, myTitle, title)) if(myApp.equals(BuildConfig.APPLICATION_ID))
{
return false;
}
}
/*
If there are multiple notifications ("stacked") title or text might be null:
https://stackoverflow.com/questions/28047767/notificationlistenerservice-not-reading-text-of-stacked-notifications
*/
Bundle extras = sbn.getNotification().extras;
// T I T L E
if (extras.containsKey(EXTRA_TITLE))
notificationTitle = sbn.getNotification().extras.getString(EXTRA_TITLE);
if (!StringUtils.isEmpty(requiredTitle))
{
if (!Miscellaneous.compare(myTitleDir, requiredTitle, notificationTitle))
{ {
Miscellaneous.logEvent("i", "NotificationCheck", "Notification title does not match rule.", 5); Miscellaneous.logEvent("i", "NotificationCheck", "Notification title does not match rule.", 5);
continue; continue;
} }
} }
else
Miscellaneous.logEvent("i", "NotificationCheck", "A required title for a notification trigger was not specified.", 5);
if (myText.length() > 0) // T E X T
if (extras.containsKey(EXTRA_TEXT))
notificationText = sbn.getNotification().extras.getString(EXTRA_TEXT);
if (!StringUtils.isEmpty(requiredText))
{ {
if (!Miscellaneous.compare(myTextDir, myText, text)) if (!Miscellaneous.compare(myTextDir, requiredText, notificationText))
{ {
Miscellaneous.logEvent("i", "NotificationCheck", "Notification text does not match rule.", 5); Miscellaneous.logEvent("i", "NotificationCheck", "Notification text does not match rule.", 5);
continue; continue;
} }
} }
else
Miscellaneous.logEvent("i", "NotificationCheck", "A required text for a notification trigger was not specified.", 5);
foundMatch = true; foundMatch = true;
break; break;
@ -838,16 +873,23 @@ public class Rule implements Comparable<Rule>
if (!app.equalsIgnoreCase(myApp)) if (!app.equalsIgnoreCase(myApp))
return false; return false;
} }
else
if (myTitle.length() > 0)
{ {
if (!Miscellaneous.compare(myTitleDir, title, myTitle)) if(myApp.equals(BuildConfig.APPLICATION_ID))
{
return false;
}
}
if (requiredTitle.length() > 0)
{
if (!Miscellaneous.compare(myTitleDir, title, requiredTitle))
return false; return false;
} }
if (myText.length() > 0) if (requiredText.length() > 0)
{ {
if (!Miscellaneous.compare(myTextDir, text, myText)) if (!Miscellaneous.compare(myTextDir, text, requiredText))
return false; return false;
} }
} }
@ -915,6 +957,32 @@ public class Rule implements Comparable<Rule>
} }
} }
public boolean haveTriggersReallyChanged(Object triggeringObject)
{
boolean returnValue = false;
try
{
for(int i=0; i < triggerSet.size(); i++)
{
Trigger t = (Trigger) triggerSet.get(i);
if(t.hasStateRecentlyNotApplied(triggeringObject))
{
Miscellaneous.logEvent("i", "Rule", "Rule \"" + getName() + "\" has trigger that flipped: " + t.toString(), 4);
returnValue = true; // only 1 trigger needs to have flipped recently
}
}
return returnValue;
}
catch(Exception e)
{
Miscellaneous.logEvent("e", "Rule", "Error while checking if rule \"" + getName() + "\" haveTriggersReallyChanged(): " + Log.getStackTraceString(e), 1);
return false;
}
}
/** /**
* Will activate the rule. Should be called by a separate execution thread * Will activate the rule. Should be called by a separate execution thread
* @param automationService * @param automationService
@ -925,8 +993,9 @@ public class Rule implements Comparable<Rule>
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this); boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
boolean doToggle = ruleToggle && isActuallyToggable; boolean doToggle = ruleToggle && isActuallyToggable;
boolean triggersApplyAnew = haveTriggersReallyChanged(new Date());
if(notLastActive || force || doToggle) if(notLastActive || force || doToggle || triggersApplyAnew)
{ {
String message; String message;
if(!doToggle) if(!doToggle)

View File

@ -1,11 +1,14 @@
package com.jens.automation2; package com.jens.automation2;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Notification;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.os.Looper; import android.os.Looper;
import android.os.Parcelable;
import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
@ -34,6 +37,11 @@ import static com.jens.automation2.Trigger.triggerParameter2Split;
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT; import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT;
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE; import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE;
import androidx.core.app.NotificationCompat;
import org.apache.commons.lang3.StringUtils;
public class Rule implements Comparable<Rule> public class Rule implements Comparable<Rule>
{ {
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>(); private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
@ -793,13 +801,13 @@ public class Rule implements Comparable<Rule>
String myApp = params[0]; String myApp = params[0];
String myTitleDir = params[1]; String myTitleDir = params[1];
String myTitle = params[2]; String requiredTitle = params[2];
String myTextDir = params[3]; String myTextDir = params[3];
String myText; String requiredText;
if (params.length >= 5) if (params.length >= 5)
myText = params[4]; requiredText = params[4];
else else
myText = ""; requiredText = "";
if(oneTrigger.getTriggerParameter()) if(oneTrigger.getTriggerParameter())
{ {
@ -811,38 +819,65 @@ public class Rule implements Comparable<Rule>
{ {
if(getLastExecution() == null || sbn.getPostTime() > this.lastExecution.getTimeInMillis()) if(getLastExecution() == null || sbn.getPostTime() > this.lastExecution.getTimeInMillis())
{ {
String app = sbn.getPackageName(); String notificationApp = sbn.getPackageName();
String title = sbn.getNotification().extras.getString(EXTRA_TITLE); String notificationTitle = null;
String text = sbn.getNotification().extras.getString(EXTRA_TEXT); String notificationText = null;
Miscellaneous.logEvent("i", "NotificationCheck", "Checking if this notification matches our rule " + this.getName() + ". App: " + app + ", title: " + title + ", text: " + text, 5); Miscellaneous.logEvent("i", "NotificationCheck", "Checking if this notification matches our rule " + this.getName() + ". App: " + notificationApp + ", title: " + notificationTitle + ", text: " + notificationText, 5);
if (!myApp.equals("-1")) if (!myApp.equals("-1"))
{ {
if (!app.equalsIgnoreCase(myApp)) if (!notificationApp.equalsIgnoreCase(myApp))
{ {
Miscellaneous.logEvent("i", "NotificationCheck", "Notification app name does not match rule.", 5); Miscellaneous.logEvent("i", "NotificationCheck", "Notification app name does not match rule.", 5);
continue; continue;
} }
} }
else
if (myTitle.length() > 0)
{ {
if (!Miscellaneous.compare(myTitleDir, myTitle, title)) if(myApp.equals(BuildConfig.APPLICATION_ID))
{
return false;
}
}
/*
If there are multiple notifications ("stacked") title or text might be null:
https://stackoverflow.com/questions/28047767/notificationlistenerservice-not-reading-text-of-stacked-notifications
*/
Bundle extras = sbn.getNotification().extras;
// T I T L E
if (extras.containsKey(EXTRA_TITLE))
notificationTitle = sbn.getNotification().extras.getString(EXTRA_TITLE);
if (!StringUtils.isEmpty(requiredTitle))
{
if (!Miscellaneous.compare(myTitleDir, requiredTitle, notificationTitle))
{ {
Miscellaneous.logEvent("i", "NotificationCheck", "Notification title does not match rule.", 5); Miscellaneous.logEvent("i", "NotificationCheck", "Notification title does not match rule.", 5);
continue; continue;
} }
} }
else
Miscellaneous.logEvent("i", "NotificationCheck", "A required title for a notification trigger was not specified.", 5);
if (myText.length() > 0) // T E X T
if (extras.containsKey(EXTRA_TEXT))
notificationText = sbn.getNotification().extras.getString(EXTRA_TEXT);
if (!StringUtils.isEmpty(requiredText))
{ {
if (!Miscellaneous.compare(myTextDir, myText, text)) if (!Miscellaneous.compare(myTextDir, requiredText, notificationText))
{ {
Miscellaneous.logEvent("i", "NotificationCheck", "Notification text does not match rule.", 5); Miscellaneous.logEvent("i", "NotificationCheck", "Notification text does not match rule.", 5);
continue; continue;
} }
} }
else
Miscellaneous.logEvent("i", "NotificationCheck", "A required text for a notification trigger was not specified.", 5);
foundMatch = true; foundMatch = true;
break; break;
@ -869,16 +904,23 @@ public class Rule implements Comparable<Rule>
if (!app.equalsIgnoreCase(myApp)) if (!app.equalsIgnoreCase(myApp))
return false; return false;
} }
else
if (myTitle.length() > 0)
{ {
if (!Miscellaneous.compare(myTitleDir, title, myTitle)) if(myApp.equals(BuildConfig.APPLICATION_ID))
{
return false;
}
}
if (requiredTitle.length() > 0)
{
if (!Miscellaneous.compare(myTitleDir, title, requiredTitle))
return false; return false;
} }
if (myText.length() > 0) if (requiredText.length() > 0)
{ {
if (!Miscellaneous.compare(myTextDir, text, myText)) if (!Miscellaneous.compare(myTextDir, text, requiredText))
return false; return false;
} }
} }
@ -946,6 +988,32 @@ public class Rule implements Comparable<Rule>
} }
} }
public boolean haveTriggersReallyChanged(Object triggeringObject)
{
boolean returnValue = false;
try
{
for(int i=0; i < triggerSet.size(); i++)
{
Trigger t = (Trigger) triggerSet.get(i);
if(t.hasStateRecentlyNotApplied(triggeringObject))
{
Miscellaneous.logEvent("i", "Rule", "Rule \"" + getName() + "\" has trigger that flipped: " + t.toString(), 4);
returnValue = true; // only 1 trigger needs to have flipped recently
}
}
return returnValue;
}
catch(Exception e)
{
Miscellaneous.logEvent("e", "Rule", "Error while checking if rule \"" + getName() + "\" haveTriggersReallyChanged(): " + Log.getStackTraceString(e), 1);
return false;
}
}
/** /**
* Will activate the rule. Should be called by a separate execution thread * Will activate the rule. Should be called by a separate execution thread
* @param automationService * @param automationService
@ -956,8 +1024,9 @@ public class Rule implements Comparable<Rule>
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this); boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
boolean doToggle = ruleToggle && isActuallyToggable; boolean doToggle = ruleToggle && isActuallyToggable;
boolean triggersApplyAnew = haveTriggersReallyChanged(new Date());
if(notLastActive || force || doToggle) if(notLastActive || force || doToggle || triggersApplyAnew)
{ {
String message; String message;
if(!doToggle) if(!doToggle)

View File

@ -13,6 +13,8 @@ import java.util.Locale;
public class Action public class Action
{ {
Rule parentRule = null;
public static final String actionParameter2Split = "ap2split"; public static final String actionParameter2Split = "ap2split";
public static final String intentPairSeperator = "intPairSplit"; public static final String intentPairSeperator = "intPairSplit";
public static final String vibrateSeparator = ","; public static final String vibrateSeparator = ",";
@ -273,6 +275,16 @@ public class Action
return returnString.toString(); return returnString.toString();
} }
public Rule getParentRule()
{
return parentRule;
}
public void setParentRule(Rule parentRule)
{
this.parentRule = parentRule;
}
public static CharSequence[] getActionTypesAsArray() public static CharSequence[] getActionTypesAsArray()
{ {
ArrayList<String> actionTypesList = new ArrayList<String>(); ArrayList<String> actionTypesList = new ArrayList<String>();

View File

@ -403,6 +403,11 @@ public class ActivityManageRule extends Activity
ruleToEdit.setName(etRuleName.getText().toString()); ruleToEdit.setName(etRuleName.getText().toString());
ruleToEdit.setRuleActive(chkRuleActive.isChecked()); ruleToEdit.setRuleActive(chkRuleActive.isChecked());
ruleToEdit.setRuleToggle(chkRuleToggle.isChecked()); ruleToEdit.setRuleToggle(chkRuleToggle.isChecked());
for(Trigger t : ruleToEdit.getTriggerSet())
t.setParentRule(ruleToEdit);
for(Action a : ruleToEdit.getActionSet())
a.setParentRule(ruleToEdit);
} }
private void loadVariablesIntoGui() private void loadVariablesIntoGui()

View File

@ -37,11 +37,38 @@ public class Trigger
} }
catch(Exception e) catch(Exception e)
{ {
Miscellaneous.logEvent("Error while checking if rule " + getParentRule().getName() + " applies. Error occured in trigger " + this.toString() + "." + Diverse.lineSeparator + Diverse.getStackTraceAsString(e), 1); Miscellaneous.logEvent("e", "Trigger", "Error while checking if rule " + getParentRule().getName() + " applies. Error occured in trigger " + this.toString() + "." + Miscellaneous.lineSeparator + Log.getStackTraceString(e), 1);
return false; return false;
} }
} }
public boolean hasStateRecentlyNotApplied(Object triggeringObject)
{
// nur mit einem Trigger?
// door -> was state different in previous step
try
{
switch(getTriggerType())
{
case timeFrame:
if(!checkDateTime(triggeringObject, true))
return false;
break;
default:
break;
}
return true;
}
catch(Exception e)
{
Miscellaneous.logEvent("e", "Trigger", "Error while checking if rule " + getParentRule().getName() + " applies. Error occured in trigger " + this.toString() + "." + Miscellaneous.lineSeparator + Log.getStackTraceString(e), 1);
return false;
}
}
public boolean checkDateTime(Object triggeringObject, boolean checkifStateChangedSinceLastRuleExecution) public boolean checkDateTime(Object triggeringObject, boolean checkifStateChangedSinceLastRuleExecution)
{ {
/* /*
@ -101,7 +128,7 @@ public class Trigger
{ {
if(!isSupposedToRepeatSinceLastExecution(compareCal)) if(!isSupposedToRepeatSinceLastExecution(compareCal))
{ {
Miscellaneous.logEvent("TimeFrame: Trigger of rule " + this.getParentRule().getName() + " applies, but repeated execution is not due, yet.", 4); Miscellaneous.logEvent("i", "TimeFrame", "TimeFrame: Trigger of rule " + this.getParentRule().getName() + " applies, but repeated execution is not due, yet.", 4);
return false; return false;
} }
} }
@ -116,14 +143,14 @@ public class Trigger
*/ */
if( if(
getParentRule().getLastExecutionTimestamp().get(Calendar.YEAR) == calNow.get(Calendar.YEAR) getParentRule().getLastExecution().get(Calendar.YEAR) == calNow.get(Calendar.YEAR)
&& &&
getParentRule().getLastExecutionTimestamp().get(Calendar.MONTH) == calNow.get(Calendar.MONTH) getParentRule().getLastExecution().get(Calendar.MONTH) == calNow.get(Calendar.MONTH)
&& &&
getParentRule().getLastExecutionTimestamp().get(Calendar.DAY_OF_MONTH) == calNow.get(Calendar.DAY_OF_MONTH) getParentRule().getLastExecution().get(Calendar.DAY_OF_MONTH) == calNow.get(Calendar.DAY_OF_MONTH)
) )
{ {
Miscellaneous.logEvent("TimeFrame: Trigger of rule " + this.getParentRule().getName() + " applies, but it was already executed today.", 4); Miscellaneous.logEvent("i", "TimeFrame", "TimeFrame: Trigger of rule " + this.getParentRule().getName() + " applies, but it was already executed today.", 4);
return false; return false;
} }
} }
@ -170,11 +197,11 @@ public class Trigger
*/ */
if( if(
getParentRule().getLastExecutionTimestamp().get(Calendar.YEAR) == calNow.get(Calendar.YEAR) getParentRule().getLastExecution().get(Calendar.YEAR) == calNow.get(Calendar.YEAR)
&& &&
getParentRule().getLastExecutionTimestamp().get(Calendar.MONTH) == calNow.get(Calendar.MONTH) getParentRule().getLastExecution().get(Calendar.MONTH) == calNow.get(Calendar.MONTH)
&& &&
getParentRule().getLastExecutionTimestamp().get(Calendar.DAY_OF_MONTH) == calNow.get(Calendar.DAY_OF_MONTH) getParentRule().getLastExecution().get(Calendar.DAY_OF_MONTH) == calNow.get(Calendar.DAY_OF_MONTH)
) )
{ {
Miscellaneous.logEvent("i", "Trigger", "TimeFrame: Trigger of rule " + this.getParentRule().getName() + " applies, but it was already executed today.", 4); Miscellaneous.logEvent("i", "Trigger", "TimeFrame: Trigger of rule " + this.getParentRule().getName() + " applies, but it was already executed today.", 4);
@ -255,7 +282,7 @@ public class Trigger
boolean isSupposedToRepeatSinceLastExecution(Calendar now) boolean isSupposedToRepeatSinceLastExecution(Calendar now)
{ {
TimeFrame tf = new TimeFrame(getTriggerParameter2()); TimeFrame tf = new TimeFrame(getTriggerParameter2());
Calendar lastExec = getParentRule().getLastExecutionTimestamp(); Calendar lastExec = getParentRule().getLastExecution();
// the simple stuff: // the simple stuff:
@ -560,7 +587,7 @@ public class Trigger
String repeat = ", no repetition"; String repeat = ", no repetition";
if(this.getTimeFrame().getRepetition() > 0) if(this.getTimeFrame().getRepetition() > 0)
repeat = ", " + String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.repeatEveryXsecondsWithVariable), this.getTimeFrame().getRepetition()); repeat = ", " + String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.repeatEveryXsecondsWithVariable), String.valueOf(this.getTimeFrame().getRepetition()));
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.triggerTimeFrame) + ": " + this.getTimeFrame().getTriggerTimeStart().toString() + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.until) + " " + this.getTimeFrame().getTriggerTimeStop().toString() + " on days " + this.getTimeFrame().getDayList().toString() + repeat); returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.triggerTimeFrame) + ": " + this.getTimeFrame().getTriggerTimeStart().toString() + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.until) + " " + this.getTimeFrame().getTriggerTimeStop().toString() + " on days " + this.getTimeFrame().getDayList().toString() + repeat);
break; break;

View File

@ -764,6 +764,8 @@ public class XmlFileInterface
try try
{ {
newRule.setTriggerSet(readTriggerCollection(parser)); newRule.setTriggerSet(readTriggerCollection(parser));
for(Trigger t : newRule.getTriggerSet())
t.setParentRule(newRule);
} }
catch (XmlPullParserException e) catch (XmlPullParserException e)
{ {
@ -779,6 +781,8 @@ public class XmlFileInterface
try try
{ {
newRule.setActionSet(readActionCollection(parser)); newRule.setActionSet(readActionCollection(parser));
for(Action a : newRule.getActionSet())
a.setParentRule(newRule);
} }
catch (XmlPullParserException e) catch (XmlPullParserException e)
{ {

View File

@ -227,7 +227,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
} }
catch(Exception e) catch(Exception e)
{ {
Miscellaneous.logEvent("e", "DateTimeListener","Error checking anything for rule " + oneRule.toString() + " needs to be added to candicates list: " + Diverse.getStackTraceAsString(e), 1); Miscellaneous.logEvent("e", "DateTimeListener","Error checking anything for rule " + oneRule.toString() + " needs to be added to candicates list: " + Log.getStackTraceString(e), 1);
} }
} }
} }
@ -268,9 +268,8 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm"); SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(scheduleCandidate); calendar.setTimeInMillis(scheduleCandidate.time.getTimeInMillis());
Miscellaneous.logEvent("i", "AlarmManager", "Chose " + sdf.format(calendar.getTime()) + " as next scheduled alarm.", 4); Miscellaneous.logEvent("i", "AlarmManager", "Chose " + sdf.format(calendar.getTime()) + " as next scheduled alarm.", 4);
} }
public static void clearAlarms() public static void clearAlarms()

View File

@ -704,6 +704,6 @@
<string name="permissionsRequiredNotAvailable">Your rules required permissions which cannot be requested from this installed flavor of Automation.</string> <string name="permissionsRequiredNotAvailable">Your rules required permissions which cannot be requested from this installed flavor of Automation.</string>
<string name="automationNotificationsIgnored">If you do not choose a specific app, but choose \"Any app\" notifications from Automation will be ignored to avoid loops.</string> <string name="automationNotificationsIgnored">If you do not choose a specific app, but choose \"Any app\" notifications from Automation will be ignored to avoid loops.</string>
<string name="repeatEveryXseconds">Repeat every x seconds</string> <string name="repeatEveryXseconds">Repeat every x seconds</string>
<string name="repeatEveryXsecondsWithVariable">repeat every %1$o seconds</string> <string name="repeatEveryXsecondsWithVariable">repeat every %1$s seconds</string>
<string name="enterRepetitionTime">You need to enter a positive non-decimal value for reptition time.</string> <string name="enterRepetitionTime">You need to enter a positive non-decimal value for reptition time.</string>
</resources> </resources>