diff --git a/app/src/apkFlavor/java/com/jens/automation2/Rule.java b/app/src/apkFlavor/java/com/jens/automation2/Rule.java index 13a0008..3572a0d 100644 --- a/app/src/apkFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/apkFlavor/java/com/jens/automation2/Rule.java @@ -16,7 +16,6 @@ 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 com.jens.automation2.receivers.NotificationListener; import java.util.ArrayList; import java.util.Calendar; @@ -380,11 +379,6 @@ public class Rule implements Comparable Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies and has flipped since its last execution.", 4); return true; } -// else if(hasTriggerOfType(Trigger.Trigger_Enum.notification) && NotificationListener.mayRuleStillBeActivatedForPendingNotifications(this)) -// { -// Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies, has not flipped since its last execution, but may still be executed for other notifications.", 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); diff --git a/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java b/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java index ec94a6f..9745b36 100644 --- a/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java +++ b/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java @@ -276,7 +276,6 @@ public class NotificationListener extends NotificationListenerService// implemen cancelNotification(sbn.getPackageName(), sbn.getTag(), sbn.getId()); else cancelNotification(sbn.getKey()); - } @RequiresApi(api = Build.VERSION_CODES.KITKAT) @@ -309,46 +308,4 @@ public class NotificationListener extends NotificationListenerService// implemen if(!buttonFound) Miscellaneous.logEvent("w", "clickNotificationButton()", "Button with text \n" + buttonText + "\n could not found.", 2); } - - @RequiresApi(api = Build.VERSION_CODES.KITKAT) - public static boolean mayRuleStillBeActivatedForPendingNotifications(Rule rule) - { - for(RuleNotificationPair pair : notificationUsed) - Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingCalendarEvents()", "Existing pair of " + pair.rule.getName() + " and " + pair.notification, 5); - - for(StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications()) - { - for(Trigger t : rule.getTriggerSet()) - { - if(t.getTriggerType().equals(Trigger.Trigger_Enum.notification) && NotificationListener.getInstance().checkNotification(true, sbn)) - { - if (!hasNotificationBeenUsedInRule(rule, convertNotificationToSimpleNotification(true, sbn))) - { - /* - If there are multiple parallel calendar events and a rule has multiple - triggers of type calendar event, we don't want the rule to fire only once. - */ - if(rule.getAmountOfTriggersForType(Trigger.Trigger_Enum.notification) == 1) - { - Miscellaneous.logEvent("i", "mayRuleStillBeActivatedForPendingNotifications()", "Rule " + rule.getName() + " has not been used in conjunction with notification " + sbn, 4); - return true; - } - } - } - } - } - - return false; - } - - public static boolean hasNotificationBeenUsedInRule(Rule rule, SimpleNotification notification) - { - for (RuleNotificationPair executedPair : notificationUsed) - { - if (executedPair.rule.equals(rule) && executedPair.notification.equals(notification)) - return true; - } - - return false; - } } \ No newline at end of file