From ee3abd25771567f1b7f6f067ce4082de8da9b698 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 30 Jan 2023 10:27:08 +0100 Subject: [PATCH] simplify note exporting --- .../notes/pro/activities/MainActivity.kt | 40 ++++++++++--------- app/src/main/res/menu/menu.xml | 4 -- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 0de3bb02..d22b17f2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -183,8 +183,7 @@ class MainActivity : SimpleActivity() { findItem(R.id.rename_note).isVisible = multipleNotesExist findItem(R.id.open_note).isVisible = multipleNotesExist findItem(R.id.delete_note).isVisible = multipleNotesExist - findItem(R.id.export_all_notes).isVisible = multipleNotesExist && !isQPlus() - findItem(R.id.export_notes).isVisible = multipleNotesExist && isQPlus() + findItem(R.id.export_all_notes).isVisible = multipleNotesExist findItem(R.id.open_search).isVisible = !isCurrentItemChecklist findItem(R.id.remove_done_items).isVisible = isCurrentItemChecklist findItem(R.id.sort_checklist).isVisible = isCurrentItemChecklist @@ -223,8 +222,7 @@ class MainActivity : SimpleActivity() { R.id.open_file -> tryOpenFile() R.id.import_folder -> openFolder() R.id.export_as_file -> fragment?.handleUnlocking { tryExportAsFile() } - R.id.export_all_notes -> tryExportAllNotes() - R.id.export_notes -> tryExportNotes() + R.id.export_all_notes -> tryExportNotes() R.id.import_notes -> tryImportNotes() R.id.print -> fragment?.handleUnlocking { printText() } R.id.delete_note -> fragment?.handleUnlocking { displayDeleteNotePrompt() } @@ -889,20 +887,24 @@ class MainActivity : SimpleActivity() { } private fun tryExportNotes() { - hideKeyboard() - val fileName = "${getString(R.string.notes)}_${getCurrentFormattedDateTime()}" - Intent(Intent.ACTION_CREATE_DOCUMENT).apply { - type = EXPORT_MIME_TYPE - putExtra(Intent.EXTRA_TITLE, fileName) - addCategory(Intent.CATEGORY_OPENABLE) + if (isQPlus()) { + hideKeyboard() + val fileName = "${getString(R.string.notes)}_${getCurrentFormattedDateTime()}" + Intent(Intent.ACTION_CREATE_DOCUMENT).apply { + type = EXPORT_MIME_TYPE + putExtra(Intent.EXTRA_TITLE, fileName) + addCategory(Intent.CATEGORY_OPENABLE) - try { - startActivityForResult(this, PICK_EXPORT_NOTES_INTENT) - } catch (e: ActivityNotFoundException) { - toast(R.string.system_service_disabled, Toast.LENGTH_LONG) - } catch (e: Exception) { - showErrorToast(e) + try { + startActivityForResult(this, PICK_EXPORT_NOTES_INTENT) + } catch (e: ActivityNotFoundException) { + toast(R.string.system_service_disabled, Toast.LENGTH_LONG) + } catch (e: Exception) { + showErrorToast(e) + } } + } else { + tryExportAllNotesBelowQ() } } @@ -1002,17 +1004,17 @@ class MainActivity : SimpleActivity() { } } - private fun tryExportAllNotes() { + private fun tryExportAllNotesBelowQ() { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { - exportAllNotes() + exportAllNotesBelowQ() } else { toast(R.string.no_storage_permissions) } } } - private fun exportAllNotes() { + private fun exportAllNotesBelowQ() { ExportFilesDialog(this, mNotes) { parent, extension -> val items = arrayListOf( RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)), diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml index 52cca205..d2b0ef87 100644 --- a/app/src/main/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -76,10 +76,6 @@ app:showAsAction="never" /> -