From 7d644306f8959aea770e532456a96cb6c1aa23d6 Mon Sep 17 00:00:00 2001 From: Song Eric Yu Li Date: Mon, 15 Sep 2025 13:24:58 -0400 Subject: [PATCH] feat(reminders): add multiprofile ID to ReviewReminder GSoC 2025: Review Reminders As discussed on Discord, once the upcoming multiprofile system is implemented, we will need to fire review reminder notifications for all profiles, not just the active one. Currently however, once a notification is scheduled by AlarmManagerService and passed to the OS, there is no indication of which profile it is attached to as ReviewReminder does not include profile information. This is a problem because once the notification fires, it will need to open the corresponding collection to check if there are cards due. Without storing some sort of profile ID in ReviewReminder, the notification code will need to open each profile's collection one after the other to find the deck it is looking for. This small change rectifies this issue by adding a profileID string field to ReviewReminder. The field is a string because most discussion around the profile ID in Discord and in candidate GSoC proposals revolves around using either a UUID or a string name. In the case of a UUID, we cannot use the built-in Java UUID type because it is not Serializable. Hence, it will need to be converted to a string before it is stored in ReviewReminder. In both cases, a string is sufficient. --- .../java/com/ichi2/anki/reviewreminders/ReviewReminder.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/reviewreminders/ReviewReminder.kt b/AnkiDroid/src/main/java/com/ichi2/anki/reviewreminders/ReviewReminder.kt index a358ed462ba4..76a7e793bf43 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/reviewreminders/ReviewReminder.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/reviewreminders/ReviewReminder.kt @@ -169,6 +169,8 @@ sealed class ReviewReminderScope : Parcelable { * @param cardTriggerThreshold See [ReviewReminderCardTriggerThreshold]. * @param scope See [ReviewReminderScope]. * @param enabled Whether the review reminder's notifications are active or disabled. + * @param profileID ID representing the profile which created this review reminder, as review reminders for + * multiple profiles might be active simultaneously. */ @Serializable @Parcelize @@ -179,6 +181,7 @@ data class ReviewReminder private constructor( val cardTriggerThreshold: ReviewReminderCardTriggerThreshold, val scope: ReviewReminderScope, var enabled: Boolean, + val profileID: String, ) : Parcelable, ReviewReminderSchema { companion object { @@ -192,12 +195,14 @@ data class ReviewReminder private constructor( cardTriggerThreshold: ReviewReminderCardTriggerThreshold, scope: ReviewReminderScope = ReviewReminderScope.Global, enabled: Boolean = true, + profileID: String = "", ) = ReviewReminder( id = ReviewReminderId.getAndIncrementNextFreeReminderId(), time, cardTriggerThreshold, scope, enabled, + profileID, ) }