diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java
index 532c8c6e..20d5523c 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java
@@ -6,9 +6,11 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.google.gson.annotations.Expose;
import com.nextcloud.android.sso.api.NextcloudAPI;
import com.nextcloud.android.sso.api.ParsedResponse;
+import java.util.Calendar;
import java.util.List;
import io.reactivex.Observable;
@@ -70,7 +72,7 @@ public class NotesAPI {
if (ApiVersion.API_VERSION_1_0.equals(usedApiVersion)) {
return notesAPI_1_0.createNote(note);
} else if (ApiVersion.API_VERSION_0_2.equals(usedApiVersion)) {
- return notesAPI_0_2.createNote(note);
+ return notesAPI_0_2.createNote(new Note_0_2(note));
} else {
throw new UnsupportedOperationException("Used API version " + usedApiVersion + " does not support createNote().");
}
@@ -80,7 +82,7 @@ public class NotesAPI {
if (ApiVersion.API_VERSION_1_0.equals(usedApiVersion)) {
return notesAPI_1_0.editNote(note, remoteId);
} else if (ApiVersion.API_VERSION_0_2.equals(usedApiVersion)) {
- return notesAPI_0_2.editNote(note, remoteId);
+ return notesAPI_0_2.editNote(new Note_0_2(note), remoteId);
} else {
throw new UnsupportedOperationException("Used API version " + usedApiVersion + " does not support editNote().");
}
@@ -95,4 +97,28 @@ public class NotesAPI {
throw new UnsupportedOperationException("Used API version " + usedApiVersion + " does not support createNote().");
}
}
+
+ /**
+ * {@link ApiVersion#API_VERSION_0_2} didn't have a separate title
property.
+ */
+ static class Note_0_2 {
+ @Expose
+ public final String category;
+ @Expose
+ public final Calendar modified;
+ @Expose
+ public final String content;
+ @Expose
+ public final boolean favorite;
+
+ private Note_0_2(Note note) {
+ if (note == null) {
+ throw new IllegalArgumentException(Note.class.getSimpleName() + " can not be converted to " + Note_0_2.class.getSimpleName() + " because it is null.");
+ }
+ this.category = note.getCategory();
+ this.modified = note.getModified();
+ this.content = note.getContent();
+ this.favorite = note.getFavorite();
+ }
+ }
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java
index 5febe1e5..75097359 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java
@@ -1,10 +1,8 @@
package it.niedermann.owncloud.notes.persistence.sync;
-import com.google.gson.annotations.Expose;
import com.nextcloud.android.sso.api.ParsedResponse;
-import java.util.Calendar;
import java.util.List;
import io.reactivex.Observable;
@@ -27,46 +25,12 @@ public interface NotesAPI_0_2 {
@GET("notes")
Observable>> getNotes(@Query(value = "pruneBefore") long lastModified, @Header("If-None-Match") String lastETag);
- default Call createNote(@Body Note note) {
- return createNote(new Note_0_2(note));
- }
-
@POST("notes")
- Call createNote(@Body Note_0_2 note);
+ Call createNote(@Body NotesAPI.Note_0_2 note);
@PUT("notes/{remoteId}")
- Call editNote(@Body Note note, @Path("remoteId") long remoteId);
+ Call editNote(@Body NotesAPI.Note_0_2 note, @Path("remoteId") long remoteId);
@DELETE("notes/{remoteId}")
Call deleteNote(@Path("remoteId") long noteId);
-
- class Note_0_2 {
- @Expose
- public final long id;
- @Expose
- public final String title;
- @Expose
- public final String category;
- @Expose
- public final Calendar modified;
- @Expose
- public final String content;
- @Expose
- public final boolean favorite;
- @Expose
- public final String etag;
-
- private Note_0_2(Note note) {
- if (note == null) {
- throw new IllegalArgumentException(Note.class.getSimpleName() + " can not be converted to " + Note_0_2.class.getSimpleName() + " because it is null.");
- }
- this.id = note.getRemoteId();
- this.title = note.getTitle();
- this.category = note.getCategory();
- this.modified = note.getModified();
- this.content = note.getContent();
- this.favorite = note.getFavorite();
- this.etag = note.getETag();
- }
- }
}