mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-01 01:10:12 +02:00
fix #87, add an option at file exporting to keep the note synced with file
This commit is contained in:
parent
0d6de330f9
commit
894d9dadb8
@ -37,6 +37,9 @@ import java.io.File
|
|||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
class MainActivity : SimpleActivity() {
|
class MainActivity : SimpleActivity() {
|
||||||
|
private val EXPORT_FILE_SYNC = 1
|
||||||
|
private val EXPORT_FILE_NO_SYNC = 2
|
||||||
|
|
||||||
private lateinit var mCurrentNote: Note
|
private lateinit var mCurrentNote: Note
|
||||||
private var mNotes = ArrayList<Note>()
|
private var mNotes = ArrayList<Note>()
|
||||||
private var mAdapter: NotesPagerAdapter? = null
|
private var mAdapter: NotesPagerAdapter? = null
|
||||||
@ -411,7 +414,34 @@ class MainActivity : SimpleActivity() {
|
|||||||
private fun exportAsFile() {
|
private fun exportAsFile() {
|
||||||
ExportFileDialog(this, mCurrentNote) {
|
ExportFileDialog(this, mCurrentNote) {
|
||||||
if (getCurrentNoteText()?.isNotEmpty() == true) {
|
if (getCurrentNoteText()?.isNotEmpty() == true) {
|
||||||
exportNoteValueToFile(it, getCurrentNoteText()!!, true)
|
showExportFilePickUpdateDialog(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showExportFilePickUpdateDialog(exportPath: String) {
|
||||||
|
val items = arrayListOf(
|
||||||
|
RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)),
|
||||||
|
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content)))
|
||||||
|
|
||||||
|
RadioGroupDialog(this, items) {
|
||||||
|
val syncFile = it as Int == EXPORT_FILE_SYNC
|
||||||
|
val currentNoteText = getCurrentNoteText()
|
||||||
|
if (currentNoteText == null) {
|
||||||
|
toast(R.string.unknown_error_occurred)
|
||||||
|
return@RadioGroupDialog
|
||||||
|
}
|
||||||
|
|
||||||
|
exportNoteValueToFile(exportPath, currentNoteText, true) {
|
||||||
|
if (syncFile) {
|
||||||
|
mCurrentNote.path = exportPath
|
||||||
|
dbHelper.updateNotePath(mCurrentNote)
|
||||||
|
|
||||||
|
if (mCurrentNote.getNoteStoredValue() == currentNoteText) {
|
||||||
|
mCurrentNote.value = ""
|
||||||
|
dbHelper.updateNoteValue(mCurrentNote)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user