Merge pull request #437 from qwertyfinger/fix/editing-exported-note-bug

Fix editing previously exported notes not working properly
This commit is contained in:
Tibor Kaputa 2021-08-22 20:08:45 +02:00 committed by GitHub
commit 0c37e3e176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -650,7 +650,8 @@ class MainActivity : SimpleActivity() {
} else {
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)))
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content))
)
RadioGroupDialog(this, items) {
val syncFile = it as Int == EXPORT_FILE_SYNC
@ -740,7 +741,8 @@ class MainActivity : SimpleActivity() {
private fun showExportFilePickUpdateDialog(exportPath: String, textToExport: 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)))
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content))
)
RadioGroupDialog(this, items) {
val syncFile = it as Int == EXPORT_FILE_SYNC
@ -771,7 +773,8 @@ class MainActivity : SimpleActivity() {
ExportFilesDialog(this, mNotes) { parent, extension ->
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)))
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content))
)
RadioGroupDialog(this, items) {
val syncFile = it as Int == EXPORT_FILE_SYNC
@ -858,9 +861,7 @@ class MainActivity : SimpleActivity() {
}
} else {
val file = File(path)
file.printWriter().use { out ->
out.write(content)
}
file.writeText(content)
if (showSuccessToasts) {
noteExportedSuccessfully(path.getFilenameFromPath())
@ -875,7 +876,7 @@ class MainActivity : SimpleActivity() {
private fun exportNoteValueToUri(uri: Uri, content: String, callback: ((success: Boolean) -> Unit)? = null) {
try {
val outputStream = contentResolver.openOutputStream(uri)
val outputStream = contentResolver.openOutputStream(uri, "wt")
outputStream!!.bufferedWriter().use { out ->
out.write(content)
}