mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-15 15:57:24 +02:00
simplify note exporting
This commit is contained in:
parent
0e45034e72
commit
ee3abd2577
@ -183,8 +183,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
findItem(R.id.rename_note).isVisible = multipleNotesExist
|
findItem(R.id.rename_note).isVisible = multipleNotesExist
|
||||||
findItem(R.id.open_note).isVisible = multipleNotesExist
|
findItem(R.id.open_note).isVisible = multipleNotesExist
|
||||||
findItem(R.id.delete_note).isVisible = multipleNotesExist
|
findItem(R.id.delete_note).isVisible = multipleNotesExist
|
||||||
findItem(R.id.export_all_notes).isVisible = multipleNotesExist && !isQPlus()
|
findItem(R.id.export_all_notes).isVisible = multipleNotesExist
|
||||||
findItem(R.id.export_notes).isVisible = multipleNotesExist && isQPlus()
|
|
||||||
findItem(R.id.open_search).isVisible = !isCurrentItemChecklist
|
findItem(R.id.open_search).isVisible = !isCurrentItemChecklist
|
||||||
findItem(R.id.remove_done_items).isVisible = isCurrentItemChecklist
|
findItem(R.id.remove_done_items).isVisible = isCurrentItemChecklist
|
||||||
findItem(R.id.sort_checklist).isVisible = isCurrentItemChecklist
|
findItem(R.id.sort_checklist).isVisible = isCurrentItemChecklist
|
||||||
@ -223,8 +222,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
R.id.open_file -> tryOpenFile()
|
R.id.open_file -> tryOpenFile()
|
||||||
R.id.import_folder -> openFolder()
|
R.id.import_folder -> openFolder()
|
||||||
R.id.export_as_file -> fragment?.handleUnlocking { tryExportAsFile() }
|
R.id.export_as_file -> fragment?.handleUnlocking { tryExportAsFile() }
|
||||||
R.id.export_all_notes -> tryExportAllNotes()
|
R.id.export_all_notes -> tryExportNotes()
|
||||||
R.id.export_notes -> tryExportNotes()
|
|
||||||
R.id.import_notes -> tryImportNotes()
|
R.id.import_notes -> tryImportNotes()
|
||||||
R.id.print -> fragment?.handleUnlocking { printText() }
|
R.id.print -> fragment?.handleUnlocking { printText() }
|
||||||
R.id.delete_note -> fragment?.handleUnlocking { displayDeleteNotePrompt() }
|
R.id.delete_note -> fragment?.handleUnlocking { displayDeleteNotePrompt() }
|
||||||
@ -889,20 +887,24 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun tryExportNotes() {
|
private fun tryExportNotes() {
|
||||||
hideKeyboard()
|
if (isQPlus()) {
|
||||||
val fileName = "${getString(R.string.notes)}_${getCurrentFormattedDateTime()}"
|
hideKeyboard()
|
||||||
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
val fileName = "${getString(R.string.notes)}_${getCurrentFormattedDateTime()}"
|
||||||
type = EXPORT_MIME_TYPE
|
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||||
putExtra(Intent.EXTRA_TITLE, fileName)
|
type = EXPORT_MIME_TYPE
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
putExtra(Intent.EXTRA_TITLE, fileName)
|
||||||
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startActivityForResult(this, PICK_EXPORT_NOTES_INTENT)
|
startActivityForResult(this, PICK_EXPORT_NOTES_INTENT)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tryExportAllNotesBelowQ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,17 +1004,17 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryExportAllNotes() {
|
private fun tryExportAllNotesBelowQ() {
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||||
if (it) {
|
if (it) {
|
||||||
exportAllNotes()
|
exportAllNotesBelowQ()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(R.string.no_storage_permissions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exportAllNotes() {
|
private fun exportAllNotesBelowQ() {
|
||||||
ExportFilesDialog(this, mNotes) { parent, extension ->
|
ExportFilesDialog(this, mNotes) { parent, extension ->
|
||||||
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)),
|
||||||
|
@ -76,10 +76,6 @@
|
|||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/export_all_notes"
|
android:id="@+id/export_all_notes"
|
||||||
android:title="@string/export_all_notes"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/export_notes"
|
|
||||||
android:title="@string/export_notes"
|
android:title="@string/export_notes"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
|
Loading…
x
Reference in New Issue
Block a user