mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-23 12:00:15 +01:00
Fixed wrong title in export toast
This commit is contained in:
parent
0068d3d821
commit
fba3ad40f9
@ -844,7 +844,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
} else if (mCurrentNote.type == NoteType.TYPE_TEXT.value) {
|
} else if (mCurrentNote.type == NoteType.TYPE_TEXT.value) {
|
||||||
showExportFilePickUpdateDialog(it, textToExport)
|
showExportFilePickUpdateDialog(it, textToExport)
|
||||||
} else {
|
} else {
|
||||||
tryExportNoteValueToFile(it, textToExport, true)
|
tryExportNoteValueToFile(it, mCurrentNote.title, textToExport, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,7 +857,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
RadioGroupDialog(this, items) {
|
RadioGroupDialog(this, items) {
|
||||||
val syncFile = it as Int == EXPORT_FILE_SYNC
|
val syncFile = it as Int == EXPORT_FILE_SYNC
|
||||||
tryExportNoteValueToFile(exportPath, textToExport, true) { exportedSuccessfully ->
|
tryExportNoteValueToFile(exportPath, mCurrentNote.title, textToExport, true) { exportedSuccessfully ->
|
||||||
if (exportedSuccessfully) {
|
if (exportedSuccessfully) {
|
||||||
if (syncFile) {
|
if (syncFile) {
|
||||||
mCurrentNote.path = exportPath
|
mCurrentNote.path = exportPath
|
||||||
@ -901,7 +901,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
toast(String.format(getString(R.string.filename_invalid_characters_placeholder, filename)))
|
toast(String.format(getString(R.string.filename_invalid_characters_placeholder, filename)))
|
||||||
} else {
|
} else {
|
||||||
val noteStoredValue = note.getNoteStoredValue(this) ?: ""
|
val noteStoredValue = note.getNoteStoredValue(this) ?: ""
|
||||||
tryExportNoteValueToFile(file.absolutePath, note.value, false) { exportedSuccessfully ->
|
tryExportNoteValueToFile(file.absolutePath, mCurrentNote.title, note.value, false) { exportedSuccessfully ->
|
||||||
if (exportedSuccessfully) {
|
if (exportedSuccessfully) {
|
||||||
if (syncFile) {
|
if (syncFile) {
|
||||||
note.path = file.absolutePath
|
note.path = file.absolutePath
|
||||||
@ -935,9 +935,9 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tryExportNoteValueToFile(path: String, content: String, showSuccessToasts: Boolean, callback: ((success: Boolean) -> Unit)? = null) {
|
fun tryExportNoteValueToFile(path: String, title: String, content: String, showSuccessToasts: Boolean, callback: ((success: Boolean) -> Unit)? = null) {
|
||||||
if (path.startsWith("content://")) {
|
if (path.startsWith("content://")) {
|
||||||
exportNoteValueToUri(Uri.parse(path), content, callback)
|
exportNoteValueToUri(Uri.parse(path), title, content, showSuccessToasts, callback)
|
||||||
} else {
|
} else {
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||||
if (it) {
|
if (it) {
|
||||||
@ -990,13 +990,15 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exportNoteValueToUri(uri: Uri, content: String, callback: ((success: Boolean) -> Unit)? = null) {
|
private fun exportNoteValueToUri(uri: Uri, title: String, content: String, showSuccessToasts: Boolean, callback: ((success: Boolean) -> Unit)? = null) {
|
||||||
try {
|
try {
|
||||||
val outputStream = contentResolver.openOutputStream(uri, "rwt")
|
val outputStream = contentResolver.openOutputStream(uri, "rwt")
|
||||||
outputStream!!.bufferedWriter().use { out ->
|
outputStream!!.bufferedWriter().use { out ->
|
||||||
out.write(content)
|
out.write(content)
|
||||||
}
|
}
|
||||||
noteExportedSuccessfully(mCurrentNote.title)
|
if (showSuccessToasts) {
|
||||||
|
noteExportedSuccessfully(title)
|
||||||
|
}
|
||||||
callback?.invoke(true)
|
callback?.invoke(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
|
@ -43,7 +43,7 @@ abstract class NoteFragment : Fragment() {
|
|||||||
} else {
|
} else {
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
val displaySuccess = activity?.config?.displaySuccess ?: false
|
val displaySuccess = activity?.config?.displaySuccess ?: false
|
||||||
(activity as? MainActivity)?.tryExportNoteValueToFile(note.path, content, displaySuccess)
|
(activity as? MainActivity)?.tryExportNoteValueToFile(note.path, note.title, content, displaySuccess)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user