mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
adding the undo/redo functionality
This commit is contained in:
@ -132,6 +132,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
when (item.itemId) {
|
||||
R.id.open_note -> displayOpenNoteDialog()
|
||||
R.id.save_note -> saveNote()
|
||||
R.id.undo -> undo()
|
||||
R.id.redo -> redo()
|
||||
R.id.new_note -> displayNewNoteDialog()
|
||||
R.id.rename_note -> displayRenameDialog()
|
||||
R.id.share -> shareText()
|
||||
@ -287,11 +289,11 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
|
||||
private fun openFile() {
|
||||
FilePickerDialog(this) {
|
||||
openFile(it, true, {
|
||||
openFile(it, true) {
|
||||
OpenFileDialog(this, it.path) {
|
||||
addNewNote(it)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,6 +526,14 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun undo() {
|
||||
mAdapter?.undo(view_pager.currentItem)
|
||||
}
|
||||
|
||||
private fun redo() {
|
||||
mAdapter?.redo(view_pager.currentItem)
|
||||
}
|
||||
|
||||
private fun getNoteIndexWithId(id: Int): Int {
|
||||
for (i in 0 until mNotes.count()) {
|
||||
if (mNotes[i].id == id) {
|
||||
|
Reference in New Issue
Block a user