Skip to content

feat(reminders): review reminders RecyclerView#18964

Merged
Arthur-Milchior merged 3 commits intoankidroid:mainfrom
ericli3690:ericli3690-review-reminders-recycler-view-extracted
Aug 24, 2025
Merged

feat(reminders): review reminders RecyclerView#18964
Arthur-Milchior merged 3 commits intoankidroid:mainfrom
ericli3690:ericli3690-review-reminders-recycler-view-extracted

Conversation

@ericli3690
Copy link
Member

@ericli3690 ericli3690 commented Jul 26, 2025

Purpose / Description

  • Added RecyclerView to ScheduleReminders fragment.
  • Created ScheduleRemindersAdapter, which holds the state of each individual row in the RecyclerView. The adapter has functionality in the form of functions passed to it via its constructor to keep most of the key functionality centralized within ScheduleReminders and to avoid injecting a Context into the adapter, which should optimally be context-free. I tried to keep the adapter as short as possible; it only governs the UI of each individual reminder in the RecyclerView.
  • Added setDeckNameFromScopeView method, which retrieves deck names from the collection for displaying in the UI. Deck names are cached to prevent repeated calls to the collection.
  • Added empty placeholder methods for adding reminders and editing reminders that will be filled in by a future PR.
  • Added logic for toggling whether reminders are enabled and saving that state.
  • Put a RecyclerView reminders content state controlling data structure into ScheduleReminders. Made it a HashMap for cleaner access operations without element-by-element search for deletion, etc.
  • Added onDeckSelected, a method that will allow the code to detect if the AddEditReminderDialog (coming soon) has had the deck selected in the deck selection dialog changed. We must catch this in ScheduleReminders because this onChange event has to be caught by a Fragment, whereas the AddEditReminderDialog is just a dialog that gets briefly removed when the deck selection dialog appears. The data is forwarded to the AddEditReminderDialog via a FragmentResult, a very simple way of passing information between fragments.
  • Added constants that will be used for pushing information to and from the AddEditReminderDialog to the ScheduleReminders companion object.
  • Fixed a small Timber call to use format arguments rather than interpolation.
  • Created a triggerUIUpdates method for ease of posting the reminders to the adapter.
  • Added a catchDatabaseExceptions wrapper method to ScheduleReminders. By wrapping calls to the database with this function, any database errors caught fail gracefully and show an error dialog to the user. If the database access takes too long, a progress bar shows up, too.
  • Previously, this was a method that also included schema migration logic etc., but that's now been moved to feat(reminders): ReviewReminder schema migration #18856, so it's now possible for me to move this small snippet here instead.

Fixes

  • For GSoC 2025: Review Reminders

Approach

  • I've tried to explain the motivation for implementation details in Purpose / Description. Let me know if anything is unclear.

How Has This Been Tested?

  • Launches using a physical Samsung S23, API 34.
  • The full review reminders CRUD works when this PR is integrated with my AddEditReminderDialog and TimePicker code. Full testing should be possible once those are also merged.

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

@ericli3690 ericli3690 added Needs Review GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors labels Jul 26, 2025
@ericli3690 ericli3690 requested a review from Copilot July 26, 2025 18:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds RecyclerView functionality to the ScheduleReminders fragment, enabling users to view, toggle, and interact with review reminders. The implementation includes adapter creation, database integration, and UI setup for reminder management.

  • Added RecyclerView with ScheduleRemindersAdapter to display review reminders in a list format
  • Implemented reminder state management including enable/disable toggling and database persistence
  • Added deck name caching and display logic with support for both global and deck-specific reminders

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
ScheduleRemindersAdapter.kt New adapter class for RecyclerView displaying reminder items with toggle functionality
ScheduleReminders.kt Enhanced fragment with RecyclerView setup, database integration, and reminder management logic

@ericli3690
Copy link
Member Author

Ready for review! Please also look through the above comments from Copilot if you have time. Thanks.

Copy link
Contributor

@criticalAY criticalAY left a comment

Choose a reason for hiding this comment

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

Small change rest is good

import com.google.android.material.materialswitch.MaterialSwitch
import com.ichi2.anki.R

class ScheduleRemindersAdapter(
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use Diff callback here

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I didn't know about this feature! Thanks for pointing it out, it streamlines a lot of my code. Implemented.

@criticalAY criticalAY added the Needs Author Reply Waiting for a reply from the original author label Jul 27, 2025
Copy link
Member

@Arthur-Milchior Arthur-Milchior left a comment

Choose a reason for hiding this comment

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

LGTM once @criticalAY request is considered

@ericli3690 ericli3690 force-pushed the ericli3690-review-reminders-recycler-view-extracted branch from 517c202 to 24397fe Compare July 28, 2025 05:14
@ericli3690
Copy link
Member Author

ericli3690 commented Jul 28, 2025

  • Modified the ScheduleRemindersAdapter to be a ListAdapter rather than a RecyclerView.Adapter. Gave it a diffCallback.
  • Moved RecyclerView reminders content state controlling data structure out of the adapter and into ScheduleReminders. Made it a HashMap for cleaner access operations without element-by-element search for deletion, etc.
  • Modified the toggle listener to no longer use the adapter's provided position as an argument, as it sometimes caused index-out-of-bound exceptions.
  • Created a triggerUIUpdates method for ease of posting the reminders to the adapter.

@ericli3690 ericli3690 removed the Needs Author Reply Waiting for a reply from the original author label Jul 28, 2025
Copy link
Contributor

@criticalAY criticalAY left a comment

Choose a reason for hiding this comment

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

Nice! thanks

@criticalAY criticalAY added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Aug 1, 2025
@ericli3690
Copy link
Member Author

Minor edit!

  • Added a catchDatabaseExceptions wrapper method to ScheduleReminders. By wrapping calls to the database with this function, any database errors caught fail gracefully and show an error dialog to the user. If the database access takes too long, a progress bar shows up, too.
  • Previously, this was a method that also included schema migration logic etc., but that's now been moved to feat(reminders): ReviewReminder schema migration #18856, so it's now possible for me to move this small snippet here instead.

GSoC 2025: Review Reminders

- Added RecyclerView to ScheduleReminders fragment.
- Created ScheduleRemindersAdapter, which holds the state of each individual row in the RecyclerView. The adapter has functionality in the form of functions passed to it via its constructor to keep most of the key functionality centralized within ScheduleReminders and to avoid injecting a Context into the adapter, which should optimally be context-free. I tried to keep the adapter as short as possible; it only governs the UI of each individual reminder in the RecyclerView.
- Added `setDeckNameFromScopeView` method, which retrieves deck names from the collection for displaying in the UI. Deck names are cached to prevent repeated calls to the collection.
- Added empty placeholder methods for adding reminders and editing reminders that will be filled in by a future PR.
- Added logic for toggling whether reminders are enabled and saving that state.
- Put a RecyclerView `reminders` content state controlling data structure into ScheduleReminders. Made it a HashMap for cleaner access operations without element-by-element search for deletion, etc.
- Added `onDeckSelected`, a method that will allow the code to detect if the AddEditReminderDialog (coming soon) has had the deck selected in the deck selection dialog changed. We must catch this in ScheduleReminders because this onChange event has to be caught by a Fragment, whereas the AddEditReminderDialog is just a dialog that gets briefly removed when the deck selection dialog appears. The data is forwarded to the AddEditReminderDialog via a FragmentResult, a very simple way of passing information between fragments.
- Added constants that will be used for pushing information to and from the AddEditReminderDialog to the ScheduleReminders companion object.
- Fixed a small Timber call to use format arguments rather than interpolation.
- Created a `triggerUIUpdates` method for ease of posting the reminders to the adapter.
GSoC 2025: Review Reminders

- Added a `catchDatabaseExceptions` wrapper method to ScheduleReminders. By wrapping calls to the database with this function, any database errors caught fail gracefully and show an error dialog to the user. If the database access takes too long, a progress bar shows up, too.
- Previously, this was a method that also included schema migration logic etc., but that's now been moved to ankidroid#18856, so it's now possible for me to move this small snippet here instead.
@ericli3690 ericli3690 force-pushed the ericli3690-review-reminders-recycler-view-extracted branch from 195315b to 025bf39 Compare August 19, 2025 05:03
@ericli3690
Copy link
Member Author

Minor edit!

  • Non-functional change. Made some code in toggleReminderEnabled more readable, removing unnecessary null handling.
  • Rebased.

GSoC 2025: Review Reminders

- Quick commit making toggleReminderEnabled a little more clear and readable, removing unnecessary null handling.
@ericli3690 ericli3690 force-pushed the ericli3690-review-reminders-recycler-view-extracted branch from 025bf39 to e153676 Compare August 19, 2025 05:18
@ericli3690
Copy link
Member Author

One test failed for some reason only on Windows, it looks like it's CI breaking and not my code. Rerunning tests.

@ericli3690
Copy link
Member Author

Ready for review!

@Arthur-Milchior Arthur-Milchior added this pull request to the merge queue Aug 24, 2025
Merged via the queue into ankidroid:main with commit 7c34951 Aug 24, 2025
10 checks passed
@github-actions github-actions bot removed the Needs Second Approval Has one approval, one more approval to merge label Aug 24, 2025
@github-actions github-actions bot added this to the 2.23 release milestone Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments