Battery charging type differentiation and other fixes

This commit is contained in:
2024-01-25 16:53:43 +01:00
parent 04fe674cf6
commit 6c31b67b14
17 changed files with 129 additions and 34 deletions

View File

@ -526,15 +526,23 @@ public class ActivityMainScreen extends ActivityGeneric
{
if (Rule.getRuleCollection().size() > 0)
{
if(Rule.getAmountOfActivatedRules() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStartNoActivatedRules), Toast.LENGTH_LONG).show();
activityMainScreenInstance.toggleService.setChecked(false);
return;
}
if (!AutomationService.isMyServiceRunning(context))
{
// if(myServiceIntent == null) //do we need that line?????
myServiceIntent = new Intent(context, AutomationService.class);
myServiceIntent.putExtra("startAtBoot", startAtBoot);
context.startService(myServiceIntent);
} else
}
else
Miscellaneous.logEvent("w", "Service", context.getResources().getString(R.string.logServiceAlreadyRunning), 3);
} else
}
else
{
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStart), Toast.LENGTH_LONG).show();
activityMainScreenInstance.toggleService.setChecked(false);

View File

@ -469,6 +469,19 @@ public class ReceiverCoordinator
}
}
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent))
{
if(!CalendarReceiver.getInstance().isListenerRunning())
CalendarReceiver.getInstance().startListener(AutomationService.getInstance());
else
CalendarReceiver.armOrRearmTimer();
}
else
{
if(CalendarReceiver.getInstance().isListenerRunning())
CalendarReceiver.getInstance().stopListener(AutomationService.getInstance());
}
AutomationService.updateNotification();
}
}

View File

@ -66,18 +66,6 @@ public class NotificationListener extends NotificationListenerService// implemen
}
}
public static void addUsedPair(RuleNotificationPair pair)
{
// Add pair only if it's not in the list already.
for(RuleNotificationPair usedPair : notificationUsed)
{
if(usedPair.rule.equals(pair.rule) && usedPair.notification.equals(pair.notification))
return;
}
notificationUsed.add(pair);
}
@Override
public void onCreate()
{
@ -112,6 +100,7 @@ public class NotificationListener extends NotificationListenerService// implemen
synchronized boolean checkNotification(boolean created, StatusBarNotification sbn)
{
//TODO: Merge with functino in Trigger class
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
{
lastNotification = convertNotificationToSimpleNotification(created, sbn);