Skip to content

Commit 2daaa32

Browse files
committed
show fail message only for download limit and check canSetDownloadLimit before updating
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 870eb51 commit 2daaa32

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

app/src/main/java/com/owncloud/android/operations/UpdateShareInfoOperation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
7979

8080
if (share == null) {
8181
// TODO try to get remote share before failing?
82-
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
82+
return new RemoteOperationResult<>(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
8383
}
8484

8585
// Update remote share
@@ -96,10 +96,10 @@ protected RemoteOperationResult run(OwnCloudClient client) {
9696
updateOp.setLabel(label);
9797
updateOp.setAttributes(attributes);
9898

99-
RemoteOperationResult result = updateOp.execute(client);
99+
var result = updateOp.execute(client);
100100

101101
if (result.isSuccess()) {
102-
RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
102+
final var getShareOp = new GetShareRemoteOperation(share.getRemoteId());
103103
result = getShareOp.execute(client);
104104

105105
//only update the share in storage if shareId is available

app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,10 @@ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationRe
421421
onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);
422422
} else if (operation instanceof CreateShareWithShareeOperation) {
423423
onUpdateShareInformation(result, R.string.sharee_add_failed);
424-
} else if (operation instanceof UpdateShareViaLinkOperation || operation instanceof UpdateShareInfoOperation || operation instanceof SetFilesDownloadLimitOperation) {
424+
} else if (operation instanceof UpdateShareViaLinkOperation || operation instanceof UpdateShareInfoOperation) {
425425
onUpdateShareInformation(result, R.string.updating_share_failed);
426+
} else if (operation instanceof SetFilesDownloadLimitOperation) {
427+
onUpdateShareInformation(result, R.string.set_download_limit_failed);
426428
} else if (operation instanceof UpdateSharePermissionsOperation) {
427429
onUpdateShareInformation(result, R.string.updating_share_failed);
428430
} else if (operation instanceof UnshareOperation) {

app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class FileDetailsSharingProcessFragment :
176176

177177
permission = share?.permissions
178178
?: capabilities.defaultPermissions
179-
?: sharePermissionManager.getMaximumPermission(isFolder())
179+
?: sharePermissionManager.getMaximumPermission(isFolder())
180180
}
181181

182182
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
@@ -290,7 +290,9 @@ class FileDetailsSharingProcessFragment :
290290
binding.run {
291291
when {
292292
SharingMenuHelper.isUploadAndEditingAllowed(share) -> editingRadioButton.isChecked = true
293-
SharingMenuHelper.isFileRequest(share) && share?.isFolder == true -> fileRequestRadioButton.isChecked = true
293+
SharingMenuHelper.isFileRequest(share) && share?.isFolder == true -> fileRequestRadioButton.isChecked =
294+
true
295+
294296
SharingMenuHelper.isReadOnly(share) -> viewOnlyRadioButton.isChecked = true
295297
else -> {
296298
if (sharePermissionManager.isCustomPermission(share) ||
@@ -428,7 +430,7 @@ class FileDetailsSharingProcessFragment :
428430
}
429431

430432
private fun updateFileDownloadLimitView() {
431-
if (isPublicShare() && capabilities.filesDownloadLimit.isTrue && share?.isFolder == false) {
433+
if (canSetDownloadLimit()) {
432434
binding.shareProcessSetDownloadLimitSwitch.visibility = View.VISIBLE
433435

434436
val currentDownloadLimit = share?.fileDownloadLimit?.limit ?: capabilities.filesDownloadLimitDefault
@@ -724,7 +726,7 @@ class FileDetailsSharingProcessFragment :
724726
binding.shareProcessChangeName.text.toString().trim()
725727
)
726728

727-
if (capabilities.filesDownloadLimit.isTrue) {
729+
if (canSetDownloadLimit()) {
728730
val downloadLimitInput = binding.shareProcessSetDownloadLimitInput.text.toString().trim()
729731
val downloadLimit =
730732
if (binding.shareProcessSetDownloadLimitSwitch.isChecked && downloadLimitInput.isNotEmpty()) {
@@ -780,6 +782,9 @@ class FileDetailsSharingProcessFragment :
780782
// region Helpers
781783
private fun isFolder(): Boolean = (file?.isFolder == true || share?.isFolder == true)
782784

785+
private fun canSetDownloadLimit(): Boolean =
786+
(isPublicShare() && capabilities.filesDownloadLimit.isTrue && share?.isFolder == false)
787+
783788
private fun isPublicShare(): Boolean = (shareType == ShareType.PUBLIC_LINK)
784789
// endregion
785790
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@
13311331
<string name="re_enable_auto_upload_desc">Due to new restrictions imposed by Google, we have been forced to remove an important permission. We are currently working with Google to resolve this issue and restore full functionality.\n\nTo re-enable auto upload for new photos and videos:\nSelect \"Allow all\" in the following dialogue or the system settings.\nAllow media location when prompted, as this allows Nextcloud to store location data when uploading images.\n\nThe permissions dialogue is only displayed when necessary. If in doubt, check the system settings.\n\nAuto upload will only be able to upload image and video files when using the Google Play version of the Nextcloud app.\n\nPlease check for any files that may not have been uploaded since December 2024.</string>
13321332
<string name="click_to_learn_how_to_re_enable_auto_uploads">Manual intervention required to re-enable auto-upload</string>
13331333
<string name="share_download_limit">Set download limit</string>
1334+
<string name="set_download_limit_failed">Unable to set download limit. Please check capabilities.</string>
13341335
<string name="download_limit">Download limit</string>
13351336
<plurals name="share_download_limit_description">
13361337
<item quantity="one">%1$d download remaining</item>

0 commit comments

Comments
 (0)