Skip to content

feat(reminders): threshold filters - #19156

Merged
david-allison merged 8 commits into
ankidroid:mainfrom
ericli3690:ericli3690-review-reminders-new-lrn-rev
Oct 26, 2026
Merged

david-allison merged 8 commits into
ankidroid:mainfrom
ericli3690:ericli3690-review-reminders-new-lrn-rev

Conversation

@ericli3690

@ericli3690 ericli3690 commented Aug 29, 2025 •

Copy link
Copy Markdown
Member

Note

Assisted-by: Claude Opus 5.5

Purpose / Description

Add a group of new advanced review reminder options: count new cards, count cards in learning, and count cards in review. When the review reminder is about to send a notification and checks to see if the amount of cards in the deck is greater than the card trigger threshold, it examines these options to check if it should count and consider new cards, cards in learning, and cards in review.

Adds three new checkboxes to the AddEditReminderDialog to toggle these booleans on or off. Edits some logic in NotificationService to add up cards only from selected card type when determining whether the card trigger threshold is met.

Adds three new boolean fields to store the states of these settings to ReviewReminder. Adds unit tests. Deletes some old useless unit tests.

Fixes some review reminder migration bugs (no unit tests for checking versioning pointers, not retaining review reminder ID upon migration, accidentally persisting scope cachedDeckName). Uses explicit backing fields in AddEditReminderDialogViewModel.

UI

Screenshot_20261012_001755_AnkiDroid Screenshot_20261012_001827_AnkiDroid Screenshot_20261012_001816_AnkiDroid Screenshot_20261012_001804_AnkiDroid

Fixes

How Has This Been Tested?

  • Unit tests pass.
  • Builds and runs on a physical Samsung S23, API 36.
  • Migrations succeed.
  • Threshold filters feature works.
  • Review reminder retain their old ID so alarms that survive over the migration gap still work.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@ericli3690 ericli3690 added Needs Review GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors Blocked by dependency Currently blocked by some other dependent / related change labels Aug 29, 2025
@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch from 1ca08cc to 0793e7a Compare September 5, 2025 21:46
@ericli3690
ericli3690 marked this pull request as draft September 5, 2025 22:56
@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch from 0793e7a to f2c9dde Compare September 6, 2025 05:01
@ericli3690
ericli3690 marked this pull request as ready for review September 6, 2025 05:21
@ericli3690

Copy link
Copy Markdown
Member Author
  • Rebased.

@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch 3 times, most recently from 5a3ddeb to a390cfb Compare September 7, 2025 17:20
@ericli3690

Copy link
Copy Markdown
Member Author
  • Rebased.

@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch from a390cfb to 9a53408 Compare September 9, 2025 04:49
@ericli3690

Copy link
Copy Markdown
Member Author
  • Rebased.

@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch from 9a53408 to ae683e5 Compare September 9, 2025 05:23
@ericli3690

Copy link
Copy Markdown
Member Author

Forgot to stage some code. Fixed.

@ericli3690
ericli3690 marked this pull request as draft September 26, 2025 04:11
@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch from ae683e5 to e128d8a Compare November 25, 2025 06:31
@ericli3690 ericli3690 removed Blocked by dependency Currently blocked by some other dependent / related change Has Conflicts labels Nov 25, 2025
@ericli3690
ericli3690 marked this pull request as ready for review November 25, 2025 06:58
@ericli3690

Copy link
Copy Markdown
Member Author

Rebased, fully unblocked, and ready for review!

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Snapshot diff report vs main. Open screenshot-diff for diffs.

  • AddEditReminderDialogScreenshotTest: 4 changes
All 4 changed screenshots

AddEditReminderDialogScreenshotTest

  • add_mode_advanced_open_compare.png
  • edit_mode_advanced_open_compare.png
  • landscape_card_threshold_entry_compare.png
  • portrait_card_threshold_entry_compare.png

@ericli3690
ericli3690 force-pushed the ericli3690-review-reminders-new-lrn-rev branch 2 times, most recently from e1f9525 to 2152821 Compare October 5, 2026 02:57
@ericli3690

ericli3690 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member Author

will revise soon, please give me a few days
~ naive me, half a year ago

Well, that certainly was a little longer than a few days 😆

@david-allison Ready for review! I found a few bugs / missing unit tests in the migration code and had to patch them up too. See the commit messages and PR description for more information. The PR description screenshot has ben updated, too.

Unit tests and emulator tests are failing due to an upstream codecov issue: codecov/codecov-action#1975

Comment on lines +341 to +352
"learn", // R.string.add_edit_reminder_threshold_filter_learning_review_state
// TR.cardStatsReviewLogTypeLearn()
// TR.decksLearnHeader()
"new", // R.string.add_edit_reminder_threshold_filter_new_review_state
// TR.actionsNew()
// TR.changeNotetypeNew()
// TR.statisticsCountsNewCards()
"review", // R.string.add_edit_reminder_threshold_filter_reviewing_review_state
// TR.browsingSidebarCardStateReview()
// TR.cardStatsReviewLogTypeReview()
// TR.preferencesReview()
// TR.schedulingReview()

@ericli3690 ericli3690 Oct 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like the easiest way to handle the strings overlapping with TR values... if reviewers want, I can just use the TR values instead, but I'll need guidance on which to use for each of the three, since they don't seem related...

Alternatively, I could use IGNORED_BACKEND_TRANSLATIONS.

@david-allison

Copy link
Copy Markdown
Member

If you pull out 94a98c7, we can land it immediately

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM still!

@ericli3690

Copy link
Copy Markdown
Member Author

If you pull out 94a98c7, we can land it immediately

Hm, I'll leave it here, it's not that big of a deal and I don't wanna have to shepherd another PR haha

Changes:

  1. Changed UI (see PR description for up-to-date UI)
  2. Addressed David's feedback

Ready for review!

@david-allison

Copy link
Copy Markdown
Member

I'm still a strong LGTM

@criticalAY criticalAY left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking on nits, looks good to me!! time to get this in

@david-allison

david-allison commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

@criticalAY Pending a strings sync: https://github.com/ankidroid/Anki-Android/actions/runs/39685726720

@mikehardy

Copy link
Copy Markdown
Member

This one keeps failing out of the queue, seems like it needs a real look. I'm not going to point the review loop at it again until it gets one. Wanted this one in too! Hopefully it's not a huge issue

Migrations should be in a strict chain from V1 -> V2 -> ... -> ReviewReminder. Only the latest outdated schema should have its `migrate` method point at ReviewReminder. In particular, if someone creates a new migration later, they should remember to re-point the version (current - 2) at version (current - 1). To ensure this happens, unit tests are added.

Assisted-by: Claude Opus 5.5
Previously, IDs were always regenerated upon migration, which theoretically could allow alarms attached to the old ID to still exist. They would die after one attempted firing and log an error, but this should not happen.

Ensuring the ID is copied over upon migration is tricky because ReviewReminder's ID field is supposed to be secure and private, but I think this `createViaMigration` method works well enough.

As an extra bonus, it allows some overly complicated test functions to be removed. However, it also breaks the hacky "mock" migration tests. Since we will soon (after the next migration) have enough migrations to fully exercise and demonstrate how the schema migration system works, I feel comfortable removing the old mocks. Any insight they provide has now been moved to docstrings.

The mock review reminders in ReviewRemindersDatabaseTest have to be lazily created to ensure they obey the TimeManager freeze. This TimeManager freeze obviates the previous `latestNotifTime` volatility flag.

Assisted-by: Claude Opus 5.5
`cachedDeckName` was not annotated with `@Transient`, which meant there was a possibility it could be persisted to SharedPreferences. I'm fairly sure current code paths make this impossible, but it really should be fixed.

A problem then arises in that if a `cachedDeckName` was somehow persisted on a user's device, deserializing it will cause an error. Hence, this requires a migration.

Because the migration involves a private member field of a data class, we need to modify the migration test helper to accommodate setting `cachedDeckName`. I think this new test helper is more extensible and powerful.

Assisted-by: Claude Opus 5.5
Schema migration for the review reminders threshold filters feature.
UI for editing review reminder threshold filters.
Implements the reading of threshold filters are notification sending time. Adds unit tests.
@criticalAY

Copy link
Copy Markdown
Contributor

@mikehardy its fixed lets get this in?

@david-allison

Copy link
Copy Markdown
Member

Running a strings sync. Let's go!

@david-allison

Copy link
Copy Markdown
Member

No strings sync needed! Reverted the only vandalism. Let's go!

@github-actions

Copy link
Copy Markdown
Contributor

Maintainers: Please Sync Translations to produce a commit with only the automated changes from this PR.

Read more about updating strings on the wiki,

@david-allison

Copy link
Copy Markdown
Member

GREAT JOB!!!!!!

@ericli3690

Copy link
Copy Markdown
Member Author

Sorry, I've been busy for a few days, haven't had time to look at AnkiDroid. Thanks @criticalAY for handling the rebase!! Yippee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Review reminders: threshold filters

5 participants