-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(reminders): only notify if no reviews #19157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ericli3690
wants to merge
11
commits into
ankidroid:main
Choose a base branch
from
ericli3690:ericli3690-review-reminders-only-notify-if-no-reviews
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat(reminders): only notify if no reviews #19157
ericli3690
wants to merge
11
commits into
ankidroid:main
from
ericli3690:ericli3690-review-reminders-only-notify-if-no-reviews
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9f44e2d to
787f50a
Compare
|
787f50a to
f8c1584
Compare
|
GSoC 2025: Review Reminders - `initializeScheduleRemindersDeckSpinner` doesn't properly handle what happens if showAllDecks is true. This makes pressing on a deck select the wrong deck. This commit fixes this.
GSoC 2025: Review Reminders - Added TimePicker styling, used when users edit the time of a review reminder.
GSoC 2025: Review Reminders - The AddEditReminderDialog displays the current time in the TimePicker when a review reminder is being created. This change adds a utility function to ReviewReminderTime's companion object to calculate this time. I decided to put this function within ReviewReminderTime so it can be accessed by both AddEditReminderDialog and AddEditReminderDialogViewModel.
GSoC 2025: Review Reminders - XML file for AddEditReminderDialog. Allows time and deck modification. Also has a dropdown for advanced settings, including minimum card trigger threshold (with more advanced settings hopefully coming soon). The advanced settings will be grouped under a dropdown to prevent them from overwhelming users when the dialog initially opens.
GSoC 2025: Review Reminders - Creates AddEditReminderDialog. - Adds DialogMode, which represents whether the dialog is in adding or editing mode. - Created a ViewModel for the AddEditReminderDialog. A specific view model is created because this allows the dialog's state to persist across redraws, ex. if the theme changes, if the device rotates, etc. It also centralizes the data of the review reminder being edited in a single source of truth. - Sets submit, cancel, and delete actions for the dialog; this is the main way users can delete review reminders. Deletion is locked behind a confirmation box just in case the user accidentally clicks the button. - Results for the deck picker dropdown in the dialog are received in ScheduleReminders and sent to the AddEditReminderDialog via a FragmentResult. See the docstring of `onDeckSelected` in ScheduleReminders to see why this is done. - Filling in the values in the dialog fields and setting listeners for when the values change is pulled out into a separate methods for readability. - Adds `showTimePickerDialog`. Shows a TimePicker dialog for picking review reminder time via modern Material3 guidelines. Overrides `onConfigurationChanged` to properly handle device rotation, which for some reason is not handled by default by MaterialTimePicker. - An edited review reminder is passed back to ReviewRemindersDatabase as a FragmentResult, which is a simple way of passing information between fragments.
GSoC 2025: Review Reminders - Adds a fragment result listener to ScheduleReminders to detect when an AddEditReminderDialog has completed, and if so, edits the database and UI accordingly. - Filled out the `addReminder` and `editReminder` methods to show the AddEditReminderDialog.
GSoC 2025: Review Reminders - Added logic for checking if a deck exists before returning deck-specific reminders to ReviewRemindersDatabase. This code uses the `decks.have` method, since it seemed like the most straightforward way to accomplish deck-existence-checking. - `decks.have` was previously marked as "unused". I've removed this annotation. - Added a deleteAllRemindersForDeck helper method. It's public because it will also be used in NotificationService. - Had to mark a few database methods as suspending since they use the collection to check if a deck exists. This in turn meant wrapping some of the tests in the test file with `runTest` and marking the database access wrapper in ScheduleReminders with `suspend`. Also had to explicitly create decks using `addDeck` in the test file. Moved the dummy review reminder declarations to setUp to accommodate this. - Added new tests for deck deletion functionality.
GSoC 2025: Review Reminders - Added logic for review reminder notifications being sent to the user. Alarms for sending notifications are created by AlarmManagerService, and the actual notifications themselves are fired by NotificationService. - Moved catchAlarmManagerExceptions method that was previously in BootService to AlarmManagerService to ensure no regressions occur and old bugs are still solved. - `scheduleReviewReminderNotification` is the primary part of AlarmManagerService, setting the recurring notifications for a review reminder. `unschedule` and `scheduleAll` methods are also provided. - Snoozing is handled by AlarmManagerService via `scheduleSnoozedNotification`. AlarmManagerService must be a BroadcastReceiver so that it can receive snoozing requests via onReceive from PendingIntents created by NotificationService. - `sendReviewReminderNotification` in NotificationService does the bulk of the work for sending notifications, filling out content, etc. - `fireReviewReminderNotification` is a separate method that handles the actual OS call to fire the notification itself. - Marked old functionality in NotificationService as legacy notification code. - Had to create a NotificationServiceAction sealed class to mark the kinds of notification requests the NotificationService gets. These different requests must have different actions set, otherwise they collide with each other and interfere. This can cause snoozes to cancel normal notifications, normal notifications to cancel snoozes, etc., hence why we add this sealed class. - NotificationService must be a BroadcastReceiver because it needs to listen to PendingIntents triggered by AlarmManager alarms, which trigger the onReceive method. - Added unit tests for AlarmManagerService and NotificationService. - Added AlarmManagerService as a BroadcastReceiver to the AndroidManifest.xml file. - Added calls to set review reminder notifications on device boot-up and app start-up to AnkiDroidApp and BootService. - Renamed the inner field of ReviewReminderId to avoid confusing calls to `reviewReminder.id.id`.
…rs-dialog-august' into ericli3690-review-reminders-integrated-firing
GSoC 2025: Review Reminders - Modifies ScheduleReminders so that it sets alarms for review reminders via AlarmManagerService.
GSoC 2025: Review Reminders Adds an advanced review reminder option. When this setting is enabled, the review reminder only triggers notifications if the deck the review reminder is for has not been reviewed yet today. Adds a checkbox to the AddEditReminderDialog to toggle this setting on or off. Adds a method to NotificationService to check if a deck (or all decks) have been reviewed yet today. The check is accomplished via a database query of the `revlog` and `cards` tables. In my experience there is no noticeable latency, the query I've written should be fairly efficient. Adds a boolean field to store the state of this setting to ReviewReminder. Adds unit tests.
f8c1584 to
5b3ac81
Compare
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Blocked by dependency
Currently blocked by some other dependent / related change
GSoC
Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors
Has Conflicts
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Blocked by dependencyCurrently blocked by some other dependent / related change
:
Purpose / Description
Adds an advanced review reminder option. When this setting is enabled, the review reminder only triggers notifications if the deck the review reminder is for has not been reviewed yet today.
Adds a checkbox to the AddEditReminderDialog to toggle this setting on or off. Adds a method to NotificationService to check if a deck (or all decks) have been reviewed yet today. The check is accomplished via a database query of the
revlogandcardstables. In my experience there is no noticeable latency, the query I've written should be fairly efficient.UI
Fixes
Approach
The SQL query is:
Where
startOfTodayis calculated viasched.dayCutoff - 1.days.inWholeSeconds.How Has This Been Tested?
Learning (optional, can help others)
I found the database schema wiki page useful: https://github.com/ankidroid/Anki-Android/wiki/Database-Structure
Checklist