From 8c5f818dcf3e5a60e03ac1122c8b5b34ba9e1c29 Mon Sep 17 00:00:00 2001 From: shilpa shetty Date: Sun, 10 Aug 2025 14:06:30 +0530 Subject: [PATCH 1/2] Add copy note functionality --- .../fossify/notes/activities/MainActivity.kt | 34 +++++++++++++++++++ app/src/main/res/menu/menu.xml | 4 +++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 40 insertions(+) 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 + Copy note You have some unsaved changes. What do you want to do with them? Note shown in the widget: Show note title From 50e3781dca16d68c0483931602b482499244d4dc Mon Sep 17 00:00:00 2001 From: shilpa shetty Date: Sun, 10 Aug 2025 14:39:08 +0530 Subject: [PATCH 2/2] Changed name of Copy note to Make a copy --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f4bda870..b296c0f1e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,7 +15,7 @@ General note Create a new note Add to note - Copy 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