diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/NoteService.kt b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/NoteService.kt
index 2ddcf2665a1b..ee5fa223e9ff 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/NoteService.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/NoteService.kt
@@ -252,3 +252,13 @@ suspend fun isBuryNoteAvailable(card: Card): Boolean {
) == 1
}
}
+
+suspend fun isSuspendNoteAvailable(card: Card): Boolean {
+ return withCol {
+ db.queryScalar(
+ "select 1 from cards where nid = ? and id != ? and queue != " + Consts.QUEUE_TYPE_SUSPENDED + " limit 1",
+ card.nid,
+ card.id
+ ) == 1
+ }
+}
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt
index 671d17758089..84fadc078ae4 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerFragment.kt
@@ -119,6 +119,8 @@ class ReviewerFragment :
R.id.action_edit -> launchEditNote()
R.id.action_mark -> viewModel.toggleMark()
R.id.action_open_deck_options -> launchDeckOptions()
+ R.id.action_suspend_card -> viewModel.suspendCard()
+ R.id.action_suspend_note -> viewModel.suspendNote()
}
return true
}
@@ -182,6 +184,19 @@ class ReviewerFragment :
buryCardItem.isVisible = true
}
}
+
+ val suspendItem = menu.findItem(R.id.action_suspend)
+ val suspendCardItem = menu.findItem(R.id.action_suspend_card)
+ viewModel.canSuspendNoteFlow.flowWithLifecycle(lifecycle)
+ .collectLatestIn(lifecycleScope) { canSuspendNote ->
+ if (canSuspendNote) {
+ suspendItem.isVisible = true
+ suspendCardItem.isVisible = false
+ } else {
+ suspendItem.isVisible = false
+ suspendItem.isVisible = true
+ }
+ }
}
private val noteEditorLauncher =
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerViewModel.kt b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerViewModel.kt
index d8cf256edbc4..632324b7f79b 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerViewModel.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/ReviewerViewModel.kt
@@ -195,6 +195,28 @@ class ReviewerViewModel(cardMediaPlayer: CardMediaPlayer) :
}
}
+ fun suspendCard() {
+ launchCatchingIO {
+ val cardId = currentCard.await().id
+ undoableOp {
+ sched.suspendCards(ids = listOf(cardId))
+ }.count
+ actionFeedbackFlow.emit(CollectionManager.TR.studyingCardSuspended())
+ updateCurrentCard()
+ }
+ }
+
+ fun suspendNote() {
+ launchCatchingIO {
+ val noteId = currentCard.await().nid
+ undoableOp {
+ sched.suspendNotes(ids = listOf(noteId))
+ }
+ actionFeedbackFlow.emit(CollectionManager.TR.studyingNoteSuspended())
+ updateCurrentCard()
+ }
+ }
+
/* *********************************************************************************************
*************************************** Internal methods ***************************************
********************************************************************************************* */
diff --git a/AnkiDroid/src/main/res/menu/reviewer2.xml b/AnkiDroid/src/main/res/menu/reviewer2.xml
index 98dc03467555..7b64ccc43606 100644
--- a/AnkiDroid/src/main/res/menu/reviewer2.xml
+++ b/AnkiDroid/src/main/res/menu/reviewer2.xml
@@ -65,4 +65,21 @@
android:title="@string/menu_bury_note" />
+
+ -
+
+
\ No newline at end of file