Please use GitHub reactions 👍 to show that you are affected by the same issue. Please don't comment if you have no relevant information to add!
Describe the bug
When editing either a new note or an existing note (created from the Android Notes app), the editor updates the title to whatever the first line of the file is, even after the title has been manually set (to something else).
To Reproduce
Steps to reproduce the behavior:
This does not happen if I first create a note in the NextCloud web interface and sync it to the Android app, or if I create the note in Android then sync it and fix the name in the web interface and sync it back to the phone -- I can edit the note after fixing it on the server, and it stops resetting the title in the Android app.
Expected behavior
The Notes app should have the same behavior as the web interface -- the title can be set manually, independent of what the first line of the file is. A user should not have to first create a note outside of the Android app in order to get the desired title.
Smartphone (please complete the following information):
Server
I don't control the server this runs on, so I don't have access to the server information. Clicking on "About" in the web interface shows an empty popup, which leads me to believe that the information may have been removed by my server admins (if this is where I would find this information).
However, I'll answer this for the apps installed on my phone:
Stacktrace
None.
Hmm, seems to only happen to notes which are currently in the create process. But to make sure: Can you reproduce the issue when you create a note and leave it - then reopen it and start editing?
So as I mentioned in the "To Reproduce" section, exiting the note and trying to edit it again resulted in the same problem.
However, when I originally encountered the issue, I was also traveling and had limited connectivity, so my notes weren't syncing with the server. Now that I'm not traveling and on consistent wifi, I'm having trouble consistently reproducing the problem (although it still happens, just not every time).
Is it possible that connectivity/sync may be partially related to the bug?
I was able to reproduce the problem again, while traveling on a train with limited connectivity during the trip (so wifi/data is not disabled via airplane mode, but there is no network connection).
Exiting out of the note and trying to re-edit, results in the title being reset every time the note is edited; but this behavior stops once the note is able to sync with the server.
The issue can easily be reproduced:
@stefan-niedermann The problem is, that currently, auto-title depends on if a note was synced: oldNote.getRemoteId() == 0, see: https://github.com/stefan-niedermann/nextcloud-notes/blob/755ef6f83b01aea97cfbd40399ccdbbcadf5f8b9/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java#L549-L551
I think you will have to add a new database column autotitle (or similar) in the notes table that tracks if the title should be auto-generated. It will be true for new notes and must be set to false when the user changes the title manually and when a note is successfully synced.
This suggestion is definitely on track.
I was experiencing this bug because my notes stopped syncing with the server after I uninstalled NextCloud from _F-Droid_, and installed the _Google Play_ version. I guess the change in the installed NextCloud app was not detected by the notes app, and it was still thinking that everything was still the same.
During this time, I was able to 100% reproduce this bug by setting a title, and changing just the first line of my note. This resulted in the title changing to match that first line, and my notes did not sync with the server.
The problem resolved itself after I re-added the same account again in the notes app, and everything synced up nicely. Now the title is no longer changing itself when I make a change to the note itself.
We have a proper workaround / fix for this from @johahauf - thanks.
It will be distributed in v3.0.1.
Most helpful comment
I was able to reproduce the problem again, while traveling on a train with limited connectivity during the trip (so wifi/data is not disabled via airplane mode, but there is no network connection).
Exiting out of the note and trying to re-edit, results in the title being reset every time the note is edited; but this behavior stops once the note is able to sync with the server.