Skip to content

Commit

Permalink
Merge pull request #214 from nextcloud/backport-213
Browse files Browse the repository at this point in the history
Backport 213
  • Loading branch information
tobiasKaminsky authored Dec 21, 2018
2 parents 58e861d + 792ba8a commit c884d1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
private static final String NODE_RICHDOCUMENTS = "richdocuments";
private static final String NODE_MIMETYPES = "mimetypes";
private static final String NODE_RICHDOCUMENTS_DIRECT_EDITING = "direct_editing";
private static final String NODE_RICHDOCUMENTS_TEMPLATES = "templates";

// activity
private static final String NODE_ACTIVITY = "activity";
Expand Down Expand Up @@ -403,10 +404,10 @@ protected RemoteOperationResult run(OwnCloudClient client) {
}

if (respCapabilities.has(NODE_RICHDOCUMENTS)) {
JSONObject richDocumentsCapability = respCapabilities.getJSONObject(NODE_RICHDOCUMENTS);
capability.setRichDocuments(CapabilityBooleanType.TRUE);

JSONArray mimeTypesArray = respCapabilities.getJSONObject(NODE_RICHDOCUMENTS)
.getJSONArray(NODE_MIMETYPES);
JSONArray mimeTypesArray = richDocumentsCapability.getJSONArray(NODE_MIMETYPES);

ArrayList<String> mimeTypes = new ArrayList<>();

Expand All @@ -416,11 +417,25 @@ protected RemoteOperationResult run(OwnCloudClient client) {

capability.setRichDocumentsMimeTypeList(mimeTypes);

if (respCapabilities.has(NODE_RICHDOCUMENTS_DIRECT_EDITING)) {
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
if (richDocumentsCapability.has(NODE_RICHDOCUMENTS_DIRECT_EDITING)) {
if (richDocumentsCapability.getBoolean(NODE_RICHDOCUMENTS_DIRECT_EDITING)) {
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
} else {
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.FALSE);
}
} else {
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.FALSE);
}

if (richDocumentsCapability.has(NODE_RICHDOCUMENTS_TEMPLATES)) {
if (richDocumentsCapability.getBoolean(NODE_RICHDOCUMENTS_TEMPLATES)) {
capability.setRichdocumentsTemplatesAvailable(CapabilityBooleanType.TRUE);
} else {
capability.setRichdocumentsTemplatesAvailable(CapabilityBooleanType.FALSE);
}
} else {
capability.setRichdocumentsTemplatesAvailable(CapabilityBooleanType.FALSE);
}
} else {
capability.setRichDocuments(CapabilityBooleanType.FALSE);
}
Expand Down
10 changes: 10 additions & 0 deletions src/com/owncloud/android/lib/resources/status/OCCapability.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class OCCapability {
// Richdocuments
private CapabilityBooleanType richdocuments;
private CapabilityBooleanType richdocumentsDirectEditing;
private CapabilityBooleanType richdocumentsTemplatesAvailable;
private List<String> richdocumentsMimeTypeList;

private CapabilityBooleanType activity;
Expand Down Expand Up @@ -145,6 +146,7 @@ public OCCapability() {
richdocuments = CapabilityBooleanType.UNKNOWN;
richdocumentsMimeTypeList = new ArrayList<>();
richdocumentsDirectEditing = CapabilityBooleanType.FALSE;
richdocumentsTemplatesAvailable = CapabilityBooleanType.FALSE;
}


Expand Down Expand Up @@ -496,4 +498,12 @@ public void setRichDocumentsDirectEditing(CapabilityBooleanType directEditing) {
public CapabilityBooleanType getRichDocumentsDirectEditing() {
return richdocumentsDirectEditing;
}

public CapabilityBooleanType getRichdocumentsTemplatesAvailable() {
return richdocumentsTemplatesAvailable;
}

public void setRichdocumentsTemplatesAvailable(CapabilityBooleanType richdocumentsTemplatesAvailable) {
this.richdocumentsTemplatesAvailable = richdocumentsTemplatesAvailable;
}
}

0 comments on commit c884d1f

Please sign in to comment.