mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-22 03:20:16 +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) {
|
||||
showExportFilePickUpdateDialog(it, textToExport)
|
||||
} else {
|
||||
tryExportNoteValueToFile(it, textToExport, true)
|
||||
tryExportNoteValueToFile(it, mCurrentNote.title, textToExport, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -857,7 +857,7 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
RadioGroupDialog(this, items) {
|
||||
val syncFile = it as Int == EXPORT_FILE_SYNC
|
||||
tryExportNoteValueToFile(exportPath, textToExport, true) { exportedSuccessfully ->
|
||||
tryExportNoteValueToFile(exportPath, mCurrentNote.title, textToExport, true) { exportedSuccessfully ->
|
||||
if (exportedSuccessfully) {
|
||||
if (syncFile) {
|
||||
mCurrentNote.path = exportPath
|
||||
@ -901,7 +901,7 @@ class MainActivity : SimpleActivity() {
|
||||
toast(String.format(getString(R.string.filename_invalid_characters_placeholder, filename)))
|
||||
} else {
|
||||
val noteStoredValue = note.getNoteStoredValue(this) ?: ""
|
||||
tryExportNoteValueToFile(file.absolutePath, note.value, false) { exportedSuccessfully ->
|
||||
tryExportNoteValueToFile(file.absolutePath, mCurrentNote.title, note.value, false) { exportedSuccessfully ->
|
||||
if (exportedSuccessfully) {
|
||||
if (syncFile) {
|
||||
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://")) {
|
||||
exportNoteValueToUri(Uri.parse(path), content, callback)
|
||||
exportNoteValueToUri(Uri.parse(path), title, content, showSuccessToasts, callback)
|
||||
} else {
|
||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||
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 {
|
||||
val outputStream = contentResolver.openOutputStream(uri, "rwt")
|
||||
outputStream!!.bufferedWriter().use { out ->
|
||||
out.write(content)
|
||||
}
|
||||
noteExportedSuccessfully(mCurrentNote.title)
|
||||
if (showSuccessToasts) {
|
||||
noteExportedSuccessfully(title)
|
||||
}
|
||||
callback?.invoke(true)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
|
@ -43,7 +43,7 @@ abstract class NoteFragment : Fragment() {
|
||||
} else {
|
||||
if (content != null) {
|
||||
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