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

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

Merge "Notification: Allow manual override of the count" into main

parents 11d6464f 96692e0c
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -160,16 +160,19 @@ public class NotificationHelperService extends Service {
    }

    private boolean shouldDisplayNotification(String countKey) {
        final LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
        final String dateKey = countKey + "_date";
        final String date = Settings.Secure.getString(getContentResolver(), dateKey);
        final int countShown = Settings.Secure.getInt(getContentResolver(), countKey, 0);
        final LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
        LocalDateTime savedDate = null;
        if (countShown != 0) {
            // Check the saved date only if there is a count of notification.
            // This will detect manual override of the count setting.
            final String date = Settings.Secure.getString(getContentResolver(), dateKey);

            // 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)

        LocalDateTime savedDate = null;
            if (date != null) {
                savedDate = LocalDateTime.parse(date);
                if ((countShown == 1 && now.isBefore(savedDate.plusWeeks(1)))
@@ -183,6 +186,8 @@ public class NotificationHelperService extends Service {
                }
            }

        }

        Settings.Secure.putInt(getContentResolver(), countKey, Math.min(3, countShown + 1));
        Settings.Secure.putString(getContentResolver(), dateKey, now.toString());
        Log.i(