@@ -479,16 +479,17 @@ class MainActivity : SimpleActivity() {
479479
480480 RadioGroupDialog (this , items) {
481481 val syncFile = it as Int == EXPORT_FILE_SYNC
482+ val storedValue = mCurrentNote.getNoteStoredValue() ? : " "
482483 tryExportNoteValueToFile(exportPath, textToExport, true ) {
483484 if (syncFile) {
484485 mCurrentNote.path = exportPath
485-
486- if (mCurrentNote.getNoteStoredValue() == textToExport) {
487- mCurrentNote.value = " "
488- }
489-
490- NotesHelper (this ).insertOrUpdateNote(mCurrentNote)
486+ mCurrentNote.value = " "
487+ } else {
488+ mCurrentNote.path = " "
489+ mCurrentNote.value = storedValue
491490 }
491+
492+ NotesHelper (this ).insertOrUpdateNote(mCurrentNote)
492493 }
493494 }
494495 }
@@ -503,22 +504,44 @@ class MainActivity : SimpleActivity() {
503504
504505 private fun exportAllNotes () {
505506 ExportFilesDialog (this , mNotes) { parent, extension ->
506- var failCount = 0
507- NotesHelper (this ).getNotes {
508- mNotes = it
509- mNotes.forEachIndexed { index, note ->
510- val filename = if (extension.isEmpty()) note.title else " ${note.title} .$extension "
511- val file = File (parent, filename)
512- if (! filename.isAValidFilename()) {
513- toast(String .format(getString(R .string.filename_invalid_characters_placeholder, filename)))
514- } else {
515- tryExportNoteValueToFile(file.absolutePath, note.value, false ) {
516- if (! it) {
517- failCount++
518- }
519-
520- if (index == mNotes.size - 1 ) {
521- toast(if (failCount == 0 ) R .string.exporting_successful else R .string.exporting_some_entries_failed)
507+ val items = arrayListOf (
508+ RadioItem (EXPORT_FILE_SYNC , getString(R .string.update_file_at_note)),
509+ RadioItem (EXPORT_FILE_NO_SYNC , getString(R .string.only_export_file_content)))
510+
511+ RadioGroupDialog (this , items) {
512+ val syncFile = it as Int == EXPORT_FILE_SYNC
513+ var failCount = 0
514+ NotesHelper (this ).getNotes {
515+ mNotes = it
516+ mNotes.forEachIndexed { index, note ->
517+ val filename = if (extension.isEmpty()) note.title else " ${note.title} .$extension "
518+ val file = File (parent, filename)
519+ if (! filename.isAValidFilename()) {
520+ toast(String .format(getString(R .string.filename_invalid_characters_placeholder, filename)))
521+ } else {
522+ val noteStoredValue = note.getNoteStoredValue() ? : " "
523+ tryExportNoteValueToFile(file.absolutePath, note.value, false ) {
524+ if (syncFile) {
525+ note.path = file.absolutePath
526+ note.value = " "
527+ } else {
528+ note.path = " "
529+ note.value = noteStoredValue
530+ }
531+
532+ NotesHelper (this ).insertOrUpdateNote(note)
533+ if (mCurrentNote.id == note.id) {
534+ mCurrentNote.value = note.value
535+ mCurrentNote.path = note.path
536+ }
537+
538+ if (! it) {
539+ failCount++
540+ }
541+
542+ if (index == mNotes.size - 1 ) {
543+ toast(if (failCount == 0 ) R .string.exporting_successful else R .string.exporting_some_entries_failed)
544+ }
522545 }
523546 }
524547 }
0 commit comments