federicoiosue / Omni-Notes

Open source note-taking application for Android
https://omninotes.app
GNU General Public License v3.0
2.69k stars 1.11k forks source link

Photo note not saved #677

Closed cabagge closed 5 years ago

cabagge commented 5 years ago

Note attachment - Photo not saved

steps to reproduction:

  1. Click on (+) (add button) in notes listview.
  2. Popup menu shown --> choose "Photo"
  3. Take a photo with camera
  4. Photo is correctly shown in note now
  5. Now press back arrow in actionBar
  6. In main list view is note shown but without photo. - Photo is missing.

Checked in latest build alpha

cabagge commented 5 years ago

In table attachments is note_id = 0

federicoiosue commented 5 years ago

Move to Beta, it contains latest fixes

cabagge commented 5 years ago

I'm sorry for confusion, maybe there is some missunderstanding.... I checked the latest develop from git. It seems, the bug is in the latest source. After some research I found the bug could be fixed in dbHelper.java --> updateNote()

There is original code: updateAttachment(note.get_id() != null ? note.get_id() : values.getAsLong(KEY_CREATION), attachment, db);

And it could be fixed with additional check for noteID = 0:

updateAttachment((note.get_id() != null && note.get_id() != 0) ? note.get_id() : values.getAsLong(KEY_CREATION), attachment, db);

With this fix is a photo attachment assigned correctly to the note. (BTW, this bug is not in current google play release 5.5.2)

cabagge commented 5 years ago

Ah, again sorry for confusion, you already fixed it in Omni-Notes-Commons. I had an old library. in src/main/java/it/feio/android/omninotes/commons/models/BaseNote.java is it fixed

public Long get_id() {      
        return creation > 0 ? creation : null;
    }

Thanks.