Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<RadioItem>().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")
}
}
}
}
}
4 changes: 4 additions & 0 deletions app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
android:icon="@drawable/ic_sort_vector"
android:title="@string/sort_by"
app:showAsAction="ifRoom" />
<item
android:id="@+id/copy_note"
android:title="@string/copy_note"
app:showAsAction="ifRoom" />
<item
android:id="@+id/share"
android:icon="@drawable/ic_share_vector"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="app_launcher_name">Notes</string>
<string name="widget_config">Thank you for using Fossify Notes.\nFor more apps from Fossify, please visit fossify.org.</string>
<string name="cannot_share_empty_text">Cannot share empty text</string>
<string name="cannot_copy_empty_text">Cannot copy empty text</string>
<string name="new_note">Add a new note</string>
<string name="no_title">Please name your note</string>
<string name="title_taken">A note with that title already exists</string>
Expand All @@ -14,6 +15,7 @@
<string name="general_note">General note</string>
<string name="create_new_note">Create a new note</string>
<string name="add_to_note">Add to note</string>
<string name="copy_note">Make a copy</string>
<string name="unsaved_changes_warning">You have some unsaved changes. What do you want to do with them?</string>
<string name="note_shown_widget">Note shown in the widget:</string>
<string name="show_note_title">Show note title</string>
Expand Down
Loading