mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-19 17:57:27 +02:00
add handling for exporting and sharing checklist notes
This commit is contained in:
parent
3f153822cc
commit
ec5977cf9f
@ -434,30 +434,29 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun exportAsFile() {
|
private fun exportAsFile() {
|
||||||
ExportFileDialog(this, mCurrentNote) {
|
ExportFileDialog(this, mCurrentNote) {
|
||||||
if (getCurrentNoteText()?.isNotEmpty() == true) {
|
val textToExport = if (mCurrentNote.type == TYPE_TEXT) getCurrentNoteText() else mCurrentNote.value
|
||||||
showExportFilePickUpdateDialog(it)
|
if (textToExport == null || textToExport.isEmpty()) {
|
||||||
|
toast(R.string.unknown_error_occurred)
|
||||||
|
} else if (mCurrentNote.type == TYPE_TEXT) {
|
||||||
|
showExportFilePickUpdateDialog(it, textToExport)
|
||||||
|
} else {
|
||||||
|
exportNoteValueToFile(it, textToExport, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showExportFilePickUpdateDialog(exportPath: String) {
|
private fun showExportFilePickUpdateDialog(exportPath: String, textToExport: String) {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)),
|
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) {
|
RadioGroupDialog(this, items) {
|
||||||
val syncFile = it as Int == EXPORT_FILE_SYNC
|
val syncFile = it as Int == EXPORT_FILE_SYNC
|
||||||
val currentNoteText = getCurrentNoteText()
|
exportNoteValueToFile(exportPath, textToExport, true) {
|
||||||
if (currentNoteText == null) {
|
|
||||||
toast(R.string.unknown_error_occurred)
|
|
||||||
return@RadioGroupDialog
|
|
||||||
}
|
|
||||||
|
|
||||||
exportNoteValueToFile(exportPath, currentNoteText, true) {
|
|
||||||
if (syncFile) {
|
if (syncFile) {
|
||||||
mCurrentNote.path = exportPath
|
mCurrentNote.path = exportPath
|
||||||
|
|
||||||
if (mCurrentNote.getNoteStoredValue() == currentNoteText) {
|
if (mCurrentNote.getNoteStoredValue() == textToExport) {
|
||||||
mCurrentNote.value = ""
|
mCurrentNote.value = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,7 +641,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun shareText() {
|
private fun shareText() {
|
||||||
val text = getCurrentNoteText()
|
val text = if (mCurrentNote.type == TYPE_TEXT) getCurrentNoteText() else mCurrentNote.value
|
||||||
if (text == null || text.isEmpty()) {
|
if (text == null || text.isEmpty()) {
|
||||||
toast(R.string.cannot_share_empty_text)
|
toast(R.string.cannot_share_empty_text)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user