Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6958fac8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Notification: Allow 1 hour window + fix time delta" into main

parents 28004d7c 3b3d2ceb
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -172,15 +172,18 @@ public class NotificationHelperService extends Service {
            // The notification is always displayed the first time and if it has been at least…:
            //  * … 1 week since the first display (aka recurring only once)
            //  * … 6 months since the last display (aka recurring forever)
            //
            // Comparison is +/- 1 hour, allowing for both battery optimisation and consistency

            if (date != null) {
                savedDate = LocalDateTime.parse(date);
                if ((countShown == 1 && now.isBefore(savedDate.plusWeeks(1)))
                        || now.isBefore(savedDate.plusMonths(6))) {
                if ((countShown != 1 && now.isBefore(savedDate.plusMonths(6).minusHours(1)))
                        || now.isBefore(savedDate.plusWeeks(1).minusHours(1))) {
                    Log.i(
                            TAG,
                            ("shouldDisplayNotification(" + countKey + "): Notification discarded.")
                                    + (" countShown=" + countShown)
                                    + (" now=" + now)
                                    + (" savedDate=" + savedDate));
                    return false;
                }
@@ -193,6 +196,7 @@ public class NotificationHelperService extends Service {
                TAG,
                ("shouldDisplayNotification(" + countKey + "): Notification is being shown.")
                        + (" countShown=" + countShown)
                        + (" now=" + now)
                        + (" savedDate=" + savedDate));
        return true;
    }