New version prep, fix attempt in notification listener
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user