diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java
index d233eb4e..e28c9fc8 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java
@@ -481,7 +481,7 @@ public class NoteServerSyncHelper {
db.getAccountDao().updateModified(localAccount.getId(), localAccount.getModified().getTimeInMillis());
try {
if (db.updateApiVersion(localAccount.getId(), response.getSupportedApiVersions())) {
- localAccount.setPreferredApiVersion(response.getSupportedApiVersions());
+ localAccount.setApiVersion(response.getSupportedApiVersions());
}
} catch (Exception e) {
exceptions.add(e);
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Account.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Account.java
index 0c21b073..ed6dcd6c 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Account.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/Account.java
@@ -61,10 +61,6 @@ public class Account implements Serializable {
@Nullable
private String capabilitiesETag;
- @Nullable
- @Ignore
- private ApiVersion preferredApiVersion;
-
public Account() {
// Default constructor
}
@@ -78,20 +74,12 @@ public class Account implements Serializable {
@Nullable
public ApiVersion getPreferredApiVersion() {
- return preferredApiVersion;
- }
-
- /**
- * @param availableApiVersions ["0.2", "1.0", ...]
- */
- public void setPreferredApiVersion(@Nullable String availableApiVersions) {
// TODO move this logic to NotesClient?
try {
- if (availableApiVersions == null) {
- this.preferredApiVersion = null;
- return;
+ if (apiVersion == null) {
+ return null;
}
- final JSONArray versionsArray = new JSONArray(availableApiVersions);
+ final JSONArray versionsArray = new JSONArray(apiVersion);
final Collection supportedApiVersions = new HashSet<>(versionsArray.length());
for (int i = 0; i < versionsArray.length(); i++) {
final ApiVersion parsedApiVersion = ApiVersion.of(versionsArray.getString(i));
@@ -102,10 +90,10 @@ public class Account implements Serializable {
}
}
}
- this.preferredApiVersion = Collections.max(supportedApiVersions);
+ return Collections.max(supportedApiVersions);
} catch (JSONException | NoSuchElementException e) {
e.printStackTrace();
- this.preferredApiVersion = null;
+ return null;
}
}
@@ -223,7 +211,7 @@ public class Account implements Serializable {
return false;
if (capabilitiesETag != null ? !capabilitiesETag.equals(account.capabilitiesETag) : account.capabilitiesETag != null)
return false;
- return preferredApiVersion != null ? preferredApiVersion.equals(account.preferredApiVersion) : account.preferredApiVersion == null;
+ return true;
}
@Override
@@ -238,7 +226,6 @@ public class Account implements Serializable {
result = 31 * result + color;
result = 31 * result + textColor;
result = 31 * result + (capabilitiesETag != null ? capabilitiesETag.hashCode() : 0);
- result = 31 * result + (preferredApiVersion != null ? preferredApiVersion.hashCode() : 0);
return result;
}
@@ -255,7 +242,6 @@ public class Account implements Serializable {
", color=" + color +
", textColor=" + textColor +
", capabilitiesETag='" + capabilitiesETag + '\'' +
- ", preferredApiVersion=" + preferredApiVersion +
'}';
}
}
\ No newline at end of file