Skip to content

Commit

Permalink
For Reviewer actions, reuse Anki Desktop strings
Browse files Browse the repository at this point in the history
- For feedback-toast message to Reviewer actions, reuse strings of Anki Desktop
- Use new strings instead of ones of Anki Desktop, as needed
  • Loading branch information
snowtimeglass authored and mikehardy committed Mar 26, 2023
1 parent 629d878 commit 6555264
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.drakeet.drawer.FullDraggableContainer
import com.google.android.material.snackbar.Snackbar
import com.ichi2.anim.ActivityTransitionAnimation
import com.ichi2.anim.ActivityTransitionAnimation.getInverseTransition
import com.ichi2.anki.CollectionManager.TR
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.UIUtils.showThemedToast
import com.ichi2.anki.cardviewer.*
Expand Down Expand Up @@ -920,7 +921,7 @@ abstract class AbstractFlashcardViewer :
/** Consumers should use [.showDeleteNoteDialog] */
private fun deleteNoteWithoutConfirmation() {
dismiss(DeleteNote(currentCard!!)) {
showSnackbarWithUndoButton(R.string.deleted_note)
showSnackbarWithUndoButtonText(TR.browsingCardsDeleted(currentCard!!.note().numberOfCards()))
}
}

Expand All @@ -933,6 +934,15 @@ abstract class AbstractFlashcardViewer :
}
}

private fun showSnackbarWithUndoButtonText(
text: String,
duration: Int = Snackbar.LENGTH_SHORT
) {
showSnackbarAboveAnswerButtons(text, duration) {
setAction(R.string.undo) { undo() }
}
}

private fun getRecommendedEase(easy: Boolean): Int {
return try {
when (answerButtonCount) {
Expand Down Expand Up @@ -1685,25 +1695,26 @@ abstract class AbstractFlashcardViewer :

internal fun buryCard(): Boolean {
return dismiss(BuryCard(currentCard!!)) {
showSnackbarWithUndoButton(R.string.buried_card)
showSnackbarWithUndoButton(R.string.card_buried)
}
}

internal fun suspendCard(): Boolean {
return dismiss(SuspendCard(currentCard!!)) {
showSnackbarWithUndoButton(R.string.suspended_card)
showSnackbarWithUndoButtonText(TR.studyingCardSuspended())
}
}

internal fun suspendNote(): Boolean {
return dismiss(SuspendNote(currentCard!!)) {
showSnackbarWithUndoButton(R.string.suspended_note)
val noteSuspended = resources.getQuantityString(R.plurals.note_suspended, currentCard!!.note().numberOfCards(), currentCard!!.note().numberOfCards())
showSnackbarWithUndoButtonText(noteSuspended)
}
}

internal fun buryNote(): Boolean {
return dismiss(BuryNote(currentCard!!)) {
showSnackbarWithUndoButton(R.string.buried_note)
showSnackbarWithUndoButtonText(TR.studyingCardsBuried(currentCard!!.note().numberOfCards()))
}
}

Expand Down

0 comments on commit 6555264

Please sign in to comment.