Skip to content

Commit

Permalink
fix: image occlusion cards couldn't be previewed in the note editor
Browse files Browse the repository at this point in the history
the fields need to be passed for the card to be previewed, but they weren't built in IO so they couldn't have their values taken
  • Loading branch information
BrayanDSO authored and mikehardy committed Feb 28, 2024
1 parent 85f0c4a commit 722ccc2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,26 @@ class NoteEditor : AnkiActivity(), DeckSelectionListener, SubtitleListener, Tags
// Send the previewer all our current editing information
val noteEditorBundle = Bundle()
addInstanceStateToBundle(noteEditorBundle)
noteEditorBundle.putBundle("editFields", fieldsAsBundleForPreview)
addFieldsToBundle(noteEditorBundle)
previewer.putExtra("noteEditorBundle", noteEditorBundle)
startActivity(previewer)
}

@NeedsTest("IO fields are passed to the template previewer and the card can be previewed")
private fun addFieldsToBundle(bundle: Bundle) {
val fieldsBundle = if (currentNotetypeIsImageOcclusion()) {
val ioFieldsBundle = Bundle()
fieldsFromSelectedNote.forEachIndexed { index, field ->
val fieldValue = NoteService.convertToHtmlNewline(field[1], shouldReplaceNewlines())
ioFieldsBundle.putString(index.toString(), fieldValue)
}
ioFieldsBundle
} else {
fieldsAsBundleForPreview
}
bundle.putBundle("editFields", fieldsBundle)
}

/**
* finish when sd card is ejected
*/
Expand Down

0 comments on commit 722ccc2

Please sign in to comment.