File tree Expand file tree Collapse file tree
app/src/main/java/com/owncloud/android/ui/fragment/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,21 +91,23 @@ class SharePermissionManager {
9191
9292 fun toggleAllowDownloadAndSync (isChecked : Boolean , share : OCShare ? ): String? {
9393 val shareAttributes = getShareAttributes(share)?.toMutableList()
94- val downloadAttributeIndex = shareAttributes?.indexOf(shareAttributes.getDownloadAttribute())
95- if (downloadAttributeIndex != null && downloadAttributeIndex >= 0 ) {
96- val updatedAttribute = shareAttributes[downloadAttributeIndex].copy(isEnabled = isChecked )
97- shareAttributes[downloadAttributeIndex] = updatedAttribute
94+ if (shareAttributes == null ) {
95+ val downloadAttribute = ShareAttributes .createDownloadAttributes(isChecked)
96+ val updatedShareAttributes = listOf (downloadAttribute )
97+ return ShareAttributesJsonHandler .toJson(updatedShareAttributes)
9898 }
9999
100- if (shareAttributes == null ) {
101- return null
100+ val downloadAttributeIndex = shareAttributes.indexOf(shareAttributes.getDownloadAttribute())
101+ if (downloadAttributeIndex >= 0 ) {
102+ val updatedAttribute = shareAttributes[downloadAttributeIndex].copy(value = isChecked)
103+ shareAttributes[downloadAttributeIndex] = updatedAttribute
102104 }
103105
104106 return ShareAttributesJsonHandler .toJson(shareAttributes)
105107 }
106108
107109 fun isAllowDownloadAndSyncEnabled (share : OCShare ? ): Boolean {
108- return getShareAttributes(share).getDownloadAttribute()?.isEnabled == true
110+ return getShareAttributes(share).getDownloadAttribute()?.value == true
109111 }
110112
111113 private fun getShareAttributes (share : OCShare ? ): List <ShareAttributes >? {
You can’t perform that action at this time.
0 commit comments