Skip to content

Commit 465d784

Browse files
ericli3690lukstbit
authored andcommitted
refactor: delete ReminderService
GSoC 2025: Review Reminders - ReminderService was an old attempt at implementing review reminders, but the main methods inside are never actually called anymore. The only code that was still referencing the class was only accessing a constant in its companion object. Here, I've moved that constant out into IntentHandler (where it was previously used) and deleted ReminderService and its test. - I've decided to fully delete the class instead of only marking it as ready for deprecation because the code is never actually run. - Deleted unused strings, too.
1 parent 2b44971 commit 465d784

File tree

7 files changed

+17
-290
lines changed

7 files changed

+17
-290
lines changed

AnkiDroid/src/main/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,6 @@
624624
android:enabled="true"
625625
android:exported="false"
626626
/>
627-
<receiver
628-
android:name=".services.ReminderService"
629-
android:enabled="true"
630-
android:exported="false"
631-
/>
632627
<receiver
633628
android:name=".services.BootService"
634629
android:enabled="true"

AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import com.ichi2.anki.dialogs.requireDeckPickerOrShowError
3535
import com.ichi2.anki.libanki.DeckId
3636
import com.ichi2.anki.noteeditor.NoteEditorLauncher
3737
import com.ichi2.anki.servicelayer.ScopedStorageService
38-
import com.ichi2.anki.services.ReminderService
3938
import com.ichi2.anki.settings.Prefs
4039
import com.ichi2.anki.ui.windows.reviewer.ReviewerFragment
4140
import com.ichi2.anki.utils.MimeTypeUtils
@@ -162,7 +161,7 @@ class IntentHandler : AbstractIntentHandler() {
162161
reloadIntent: Intent,
163162
reviewerIntent: Intent,
164163
) {
165-
val deckId = intent.getLongExtra(ReminderService.EXTRA_DECK_ID, 0)
164+
val deckId = intent.getLongExtra(REVIEW_DECK_INTENT_EXTRA_DECK_ID, 0)
166165
Timber.i("Handling intent to review deck '%d'", deckId)
167166

168167
val reviewIntent =
@@ -336,6 +335,7 @@ class IntentHandler : AbstractIntentHandler() {
336335
}
337336

338337
companion object {
338+
const val REVIEW_DECK_INTENT_EXTRA_DECK_ID = "EXTRA_DECK_ID"
339339
private const val CLIPBOARD_INTENT = "com.ichi2.anki.COPY_DEBUG_INFO"
340340
private const val CLIPBOARD_INTENT_EXTRA_DATA = "clip_data"
341341

@@ -383,7 +383,7 @@ class IntentHandler : AbstractIntentHandler() {
383383
}
384384
} else if ("com.ichi2.anki.DO_SYNC" == action) {
385385
LaunchType.SYNC
386-
} else if (intent.hasExtra(ReminderService.EXTRA_DECK_ID)) {
386+
} else if (intent.hasExtra(REVIEW_DECK_INTENT_EXTRA_DECK_ID)) {
387387
LaunchType.REVIEW
388388
} else if (action == CLIPBOARD_INTENT) {
389389
LaunchType.COPY_DEBUG_INFO
@@ -472,6 +472,17 @@ class IntentHandler : AbstractIntentHandler() {
472472
}
473473
}
474474

475+
/**
476+
* Returns an intent to review a specific deck.
477+
*
478+
* @param context
479+
* @param deckId the deck ID of the deck to review
480+
*/
481+
fun getReviewDeckIntent(
482+
context: Context,
483+
deckId: DeckId,
484+
): Intent = Intent(context, IntentHandler::class.java).putExtra(REVIEW_DECK_INTENT_EXTRA_DECK_ID, deckId)
485+
475486
/**
476487
* Returns an intent to review a specific deck.
477488
* This does not states which reviewer to use, instead IntentHandler will choose whether to use the
@@ -483,7 +494,7 @@ class IntentHandler : AbstractIntentHandler() {
483494
deckId: DeckId,
484495
) = Intent(context, IntentHandler::class.java).apply {
485496
setAction(Intent.ACTION_VIEW)
486-
putExtra(ReminderService.EXTRA_DECK_ID, deckId)
497+
putExtra(REVIEW_DECK_INTENT_EXTRA_DECK_ID, deckId)
487498
}
488499
}
489500
}

AnkiDroid/src/main/java/com/ichi2/anki/services/ReminderService.kt

Lines changed: 0 additions & 183 deletions
This file was deleted.

AnkiDroid/src/main/res/values/02-strings.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@
169169
<string name="tag_editor_add_feedback_existing">Existing tag “%1$s” selected</string>
170170
<!-- Time spans -->
171171

172-
<string name="reminder_title">Do not forget to study today!</string>
173-
<plurals name="reminder_text">
174-
<item quantity="one">%2$d card to review in %1$s</item>
175-
<item quantity="other">%2$d cards to review in %1$s</item>
176-
</plurals>
177172
<!-- Currently only used if exporting APKG fails -->
178173
<string name="apk_share_error">Error sharing apkg file</string>
179174
<!-- Import and export v2 feedback -->

AnkiDroid/src/test/java/com/ichi2/anki/IntentHandlerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import android.content.Intent
2020
import androidx.core.net.toUri
2121
import androidx.test.ext.junit.runners.AndroidJUnit4
2222
import com.ichi2.anki.IntentHandler.Companion.getLaunchType
23+
import com.ichi2.anki.IntentHandler.Companion.getReviewDeckIntent
2324
import com.ichi2.anki.IntentHandler.LaunchType
24-
import com.ichi2.anki.services.ReminderService.Companion.getReviewDeckIntent
2525
import org.hamcrest.MatcherAssert.assertThat
2626
import org.hamcrest.Matchers.equalTo
2727
import org.junit.Test

AnkiDroid/src/test/java/com/ichi2/anki/services/ReminderServiceTest.kt

Lines changed: 0 additions & 91 deletions
This file was deleted.

AnkiDroid/src/test/java/com/ichi2/testutils/ActivityList.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.ichi2.anki.DrawingActivity
2929
import com.ichi2.anki.FilteredDeckOptions
3030
import com.ichi2.anki.Info
3131
import com.ichi2.anki.IntentHandler
32+
import com.ichi2.anki.IntentHandler.Companion.getReviewDeckIntent
3233
import com.ichi2.anki.IntentHandler2
3334
import com.ichi2.anki.IntroductionActivity
3435
import com.ichi2.anki.LoginActivity
@@ -44,7 +45,6 @@ import com.ichi2.anki.multimedia.MultimediaActivity
4445
import com.ichi2.anki.notetype.ManageNotetypes
4546
import com.ichi2.anki.preferences.PreferencesActivity
4647
import com.ichi2.anki.previewer.CardViewerActivity
47-
import com.ichi2.anki.services.ReminderService.Companion.getReviewDeckIntent
4848
import com.ichi2.anki.ui.windows.managespace.ManageSpaceActivity
4949
import com.ichi2.anki.ui.windows.permissions.PermissionsActivity
5050
import com.ichi2.testutils.ActivityList.ActivityLaunchParam.Companion.get

0 commit comments

Comments
 (0)