diff --git a/app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt b/app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt index e9e6e66de..cd3cc0a9c 100644 --- a/app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt +++ b/app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt @@ -321,6 +321,7 @@ class MainActivity : SimpleActivity() { R.id.remove_done_items -> fragment?.handleUnlocking { removeDoneItems() } R.id.uncheck_all_items -> fragment?.handleUnlocking { uncheckAllItems() } R.id.sort_checklist -> fragment?.handleUnlocking { displaySortChecklistDialog() } + R.id.copy_note -> fragment?.handleUnlocking { copyNote() } else -> return@setOnMenuItemClickListener false } return@setOnMenuItemClickListener true @@ -1593,4 +1594,37 @@ class MainActivity : SimpleActivity() { updateWidgets() } } + + private fun copyNote() { + + val text = if (mCurrentNote.type == NoteType.TYPE_TEXT) { + getCurrentNoteText() + } else { + mCurrentNote.value + } + + if (text.isNullOrEmpty()) { + toast(R.string.cannot_copy_empty_text) + return + } + + NotesHelper(this).getNotes { + val notes = it + val list = arrayListOf().apply { + add(RadioItem(0, getString(R.string.create_new_note))) + notes.forEachIndexed { index, note -> + add(RadioItem(index + 1, note.title)) + } + } + + RadioGroupDialog(this, list, -1, R.string.add_to_note) { + if (it as Int == 0) { + displayNewNoteDialog(text) + } else { + updateSelectedNote(notes[it - 1].id!!) + addTextToCurrentNote(if (mCurrentNote.value.isEmpty()) text else "\n$text") + } + } + } + } } diff --git a/app/src/main/res/menu/menu.xml b/app/src/main/res/menu/menu.xml index 3e0266844..1c1c4a95c 100644 --- a/app/src/main/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -49,6 +49,10 @@ android:icon="@drawable/ic_sort_vector" android:title="@string/sort_by" app:showAsAction="ifRoom" /> + Notes Thank you for using Fossify Notes.\nFor more apps from Fossify, please visit fossify.org. Cannot share empty text + Cannot copy empty text Add a new note Please name your note A note with that title already exists @@ -14,6 +15,7 @@ General note Create a new note Add to note + Make a copy You have some unsaved changes. What do you want to do with them? Note shown in the widget: Show note title