From 5a09962cc939d532ec10b35b2e598acdae02daec Mon Sep 17 00:00:00 2001 From: jens Date: Sat, 26 Mar 2022 20:00:19 +0100 Subject: [PATCH] TimeFrame repetition fix --- app/src/apkFlavor/java/com/jens/automation2/Rule.java | 9 +++++++++ app/src/main/java/com/jens/automation2/Trigger.java | 2 +- .../com/jens/automation2/receivers/DateTimeListener.java | 1 - build.gradle | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/apkFlavor/java/com/jens/automation2/Rule.java b/app/src/apkFlavor/java/com/jens/automation2/Rule.java index d34f7563..b67d5b64 100644 --- a/app/src/apkFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/apkFlavor/java/com/jens/automation2/Rule.java @@ -334,6 +334,15 @@ public class Rule implements Comparable { if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution()) return true; + + /* + Workaround for repetition in TimeFrame triggers + */ + if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame)) + { + if(oneTrigger.getTimeFrame().repetition > 0) + return true; + } } return false; diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index bb4e23d7..598786bb 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -894,7 +894,7 @@ public class Trigger Miscellaneous.compareTimes(tf.getTriggerTimeStart(), tf.getTriggerTimeStop()) < 0 && (Miscellaneous.compareTimes(tf.getTriggerTimeStart(), nowTime) >= 0 - | + || Miscellaneous.compareTimes(nowTime, tf.getTriggerTimeStop()) > 0) ) diff --git a/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java b/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java index 805d7988..cf2af333 100644 --- a/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java +++ b/app/src/main/java/com/jens/automation2/receivers/DateTimeListener.java @@ -266,7 +266,6 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis Intent alarmIntent = new Intent(automationServiceRef, DateTimeListener.class); PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); centralAlarmManagerInstance.set(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent); - SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm"); Calendar calendar = Calendar.getInstance(); diff --git a/build.gradle b/build.gradle index 3c1f6341..11c87784 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.1' + classpath 'com.android.tools.build:gradle:7.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files