Skip to content

Commit ad61b3a

Browse files
Alex7D3lukstbit
authored andcommitted
Change messages for discardChangesDialog
This changes the default dialog message in discardChangesDialog and the dialog messages on specific pages to be more intuitive and closer to the desktop experience.
1 parent 2d01603 commit ad61b3a

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,10 @@ class NoteEditorFragment :
16301630
}
16311631

16321632
private fun showDiscardChangesDialog() {
1633-
DiscardChangesDialog.showDialog(requireContext()) {
1633+
DiscardChangesDialog.showDialog(
1634+
requireContext(),
1635+
message = if (addNote) TR.addingDiscardCurrentInput() else TR.cardTemplatesDiscardChanges(),
1636+
) {
16341637
Timber.i("NoteEditor:: OK button pressed to confirm discard changes")
16351638
closeNoteEditor()
16361639
}

AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DiscardChangesDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object DiscardChangesDialog {
3333
positiveButtonText: String = context.getString(R.string.discard),
3434
negativeButtonText: String = CollectionManager.TR.addingKeepEditing(),
3535
neutralButtonText: String? = null,
36-
message: String = CollectionManager.TR.addingDiscardCurrentInput(),
36+
message: String = CollectionManager.TR.cardTemplatesDiscardChanges(),
3737
negativeMethod: () -> Unit = {},
3838
neutralMethod: (() -> Unit)? = null,
3939
positiveMethod: () -> Unit,

AnkiDroid/src/main/java/com/ichi2/anki/instantnoteeditor/InstantNoteEditorActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class InstantNoteEditorActivity :
614614
}
615615

616616
private fun showDiscardChangesDialog() {
617-
DiscardChangesDialog.showDialog(this) {
617+
DiscardChangesDialog.showDialog(this, message = TR.addingDiscardCurrentInput()) {
618618
Timber.i("InstantNoteEditorActivity:: OK button pressed to confirm discard changes")
619619
finish()
620620
}

AnkiDroid/src/main/java/com/ichi2/anki/multimedia/MultimediaFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import androidx.core.view.MenuProvider
3434
import androidx.fragment.app.Fragment
3535
import androidx.fragment.app.viewModels
3636
import androidx.lifecycle.lifecycleScope
37+
import com.ichi2.anki.CollectionManager.TR
3738
import com.ichi2.anki.CrashReportService
3839
import com.ichi2.anki.R
3940
import com.ichi2.anki.common.annotations.NeedsTest
@@ -104,7 +105,7 @@ abstract class MultimediaFragment(
104105
enabled = viewModel.currentMultimediaPath.value != null,
105106
) {
106107
override fun handleOnBackPressed() {
107-
DiscardChangesDialog.showDialog(requireContext()) {
108+
DiscardChangesDialog.showDialog(requireContext(), message = TR.addingDiscardCurrentInput()) {
108109
Timber.i("MultimediaFragment:: OK button pressed to confirm discard changes")
109110
isEnabled = false
110111
requireActivity().onBackPressedDispatcher.onBackPressed()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ class CardTemplateEditorTest : RobolectricTest() {
103103
// Make sure we get a confirmation dialog if we hit the back button
104104
assertTrue("Unable to click?", shadowTestEditor.clickMenuItem(android.R.id.home))
105105
advanceRobolectricLooper()
106-
assertEquals("Wrong dialog shown?", getAlertDialogText(true), "Discard current input?")
106+
assertEquals("Wrong dialog shown?", getAlertDialogText(true), "Discard changes?")
107107
clickAlertDialogButton(DialogInterface.BUTTON_NEGATIVE, false)
108108
advanceRobolectricLooper()
109109
assertTrue("note type change not preserved despite canceling back button?", testEditor.noteTypeHasChanged())
110110

111111
// Make sure we things are cleared out after a cancel
112112
assertTrue("Unable to click?", shadowTestEditor.clickMenuItem(android.R.id.home))
113-
assertEquals("Wrong dialog shown?", getAlertDialogText(true), "Discard current input?")
113+
assertEquals("Wrong dialog shown?", getAlertDialogText(true), "Discard changes?")
114114
clickAlertDialogButton(DialogInterface.BUTTON_POSITIVE, false)
115115
advanceRobolectricLooper()
116116
assertFalse("note type change not cleared despite discarding changes?", testEditor.noteTypeHasChanged())

0 commit comments

Comments
 (0)