New feature: set a note as favorite (star/unstar) #151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Setting a note as favorite was already introduced on the server side (owncloud/notes#248 and nextcloud/notes#4) and can be used to stick important notes to the top of the list in order to find them easier (cp. #92). My changes here introduce this feature for the android app.
Beside this, I did some necessary refactoring in the
NotesListViewActivity
/ItemAdapter
: (re-)loading the list of notes is now done in anAsyncTask
and reuses theItemAdapter
instance (instead of creating a new instance on every refresh). As a result, the list of notes does not jump to the top anymore (cp. #118).The implementation of the favorite feature is straight forward and has no special treatment for old(*) server app versions (i.e., versions that do not support the favorite feature). As a result, if a user sets a note as favorite, the star disappears after the next synchronization with an old server app. This behavior can be improved with some effort:
a) activate the feature only on demand => add a checkbox to the settings activity and only show the favorite feature, if this checkbox is activated
b) detect server features automatically => like a), but instead of setting the checkbox by the user, the app has to check if the server uses an appropriate version. This requires changes in the server API (e.g. an
info
URL which returns a JSON with the version number) and its unclear, at which point of time the app should check this in order to detect updates of the server app.c) activate the feature, but keep the local state if the server result does not contain any information about favorites => requires some changes in the app; problem: when the user updates the server app he/she will lose the local favorites setting (the server favorites will overwrite the local favorites). In order to improve this, some more effort is needed, e.g. a new DB column is required, which notices if the local meta data (i.e. favorite setting) was changed and not yet synchronized. Therefore, this solution requires the most effort (I didn't see this in my first estimation: #92 (comment)).
As an overall consequence, I would leave this as is -- for now. If a better downward compatibility is required, then we can do this in a separate commit/pull request.
(*) today, "old server app" means also the current official version of the server app. For now, the favorite feature is only in the git
master
branch and is waiting for the next release.