Skip to content

Commit 1c94e82

Browse files
public sharing: ask for password
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent b15a976 commit 1c94e82

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
7171
private static final String NODE_FILES_SHARING = "files_sharing";
7272
private static final String NODE_PUBLIC = "public";
7373
private static final String NODE_PASSWORD = "password";
74+
private static final String NODE_ASK_FOR_OPTIONAL_PASSWORD = "askForOptionalPassword";
7475
private static final String NODE_FILES_DROP = "upload_files_drop";
7576
private static final String NODE_EXPIRE_DATE = "expire_date";
7677
private static final String NODE_USER = "user";
@@ -220,9 +221,20 @@ protected RemoteOperationResult run(OwnCloudClient client) {
220221
capability.setFilesSharingPublicEnabled(CapabilityBooleanType.fromBooleanValue(
221222
respPublic.getBoolean(PROPERTY_ENABLED)));
222223
if(respPublic.has(NODE_PASSWORD)) {
224+
JSONObject passwordJson = respPublic.getJSONObject(NODE_PASSWORD);
225+
223226
capability.setFilesSharingPublicPasswordEnforced(
224227
CapabilityBooleanType.fromBooleanValue(
225-
respPublic.getJSONObject(NODE_PASSWORD).getBoolean(PROPERTY_ENFORCED)));
228+
passwordJson.getBoolean(PROPERTY_ENFORCED)));
229+
230+
if (passwordJson.has(NODE_ASK_FOR_OPTIONAL_PASSWORD)) {
231+
capability.setFilesSharingPublicAskForPassword(
232+
CapabilityBooleanType.fromBooleanValue(
233+
passwordJson.getBoolean(NODE_ASK_FOR_OPTIONAL_PASSWORD))
234+
);
235+
} else {
236+
capability.setFilesSharingPublicAskForPassword(CapabilityBooleanType.FALSE);
237+
}
226238
}
227239
if(respPublic.has(NODE_FILES_DROP)) {
228240
capability.setFilesFileDrop(
@@ -373,15 +385,11 @@ protected RemoteOperationResult run(OwnCloudClient client) {
373385
JSONObject provider = (JSONObject) providers.get(i);
374386

375387
String id = provider.getString("id");
376-
377-
switch (id) {
378-
case "files":
379-
capability.setFullNextSearchFiles(CapabilityBooleanType.TRUE);
380-
Log_OC.d(TAG, "full next search: file provider enabled");
381-
break;
382-
default:
383-
// do nothing
384-
break;
388+
389+
// do nothing
390+
if ("files".equals(id)) {
391+
capability.setFullNextSearchFiles(CapabilityBooleanType.TRUE);
392+
Log_OC.d(TAG, "full next search: file provider enabled");
385393
}
386394
}
387395
}

src/main/java/com/owncloud/android/lib/resources/status/OCCapability.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class OCCapability {
6666
private CapabilityBooleanType filesSharingApiEnabled;
6767
private CapabilityBooleanType filesSharingPublicEnabled;
6868
private CapabilityBooleanType filesSharingPublicPasswordEnforced;
69+
private CapabilityBooleanType filesSharingPublicAskForOptionalPassword;
6970
private CapabilityBooleanType filesSharingPublicExpireDateEnabled;
7071
private int filesSharingPublicExpireDateDays;
7172
private CapabilityBooleanType filesSharingPublicExpireDateEnforced;
@@ -126,6 +127,7 @@ public OCCapability() {
126127
filesSharingApiEnabled = CapabilityBooleanType.UNKNOWN;
127128
filesSharingPublicEnabled = CapabilityBooleanType.UNKNOWN;
128129
filesSharingPublicPasswordEnforced = CapabilityBooleanType.UNKNOWN;
130+
filesSharingPublicAskForOptionalPassword = CapabilityBooleanType.UNKNOWN;
129131
filesSharingPublicExpireDateEnabled = CapabilityBooleanType.UNKNOWN;
130132
filesSharingPublicExpireDateDays = 0;
131133
filesSharingPublicExpireDateEnforced = CapabilityBooleanType.UNKNOWN;

0 commit comments

Comments
 (0)