Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ package com.nextcloud.utils.extensions
import com.nextcloud.client.database.entity.ShareEntity
import com.owncloud.android.lib.resources.shares.OCShare

fun OCShare?.remainingDownloadLimit(): Int? {
val downloadLimit = this?.fileDownloadLimit ?: return null
return if (downloadLimit.limit > 0) {
downloadLimit.limit - downloadLimit.count
} else {
null
}
}

fun OCShare.hasFileRequestPermission(): Boolean = (isFolder && shareType?.isPublicOrMail() == true)

fun List<OCShare>.mergeDistinctByToken(other: List<OCShare>): List<OCShare> = (this + other).distinctBy { it.token }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.text.TextUtils
import android.view.View
import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.RecyclerView
import com.nextcloud.utils.extensions.remainingDownloadLimit
import com.nextcloud.utils.mdm.MDMConfig
import com.owncloud.android.R
import com.owncloud.android.databinding.FileDetailsShareLinkShareItemBinding
Expand Down Expand Up @@ -105,8 +106,8 @@ internal class LinkShareViewHolder(itemView: View) : RecyclerView.ViewHolder(ite
}

val downloadLimit = publicShare.fileDownloadLimit
if (downloadLimit != null && downloadLimit.limit > 0) {
val remaining = downloadLimit.limit - downloadLimit.count
if (downloadLimit != null) {
val remaining = publicShare.remainingDownloadLimit() ?: return
val text = context.resources.getQuantityString(
R.plurals.share_download_limit_description,
remaining,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.nextcloud.client.di.Injectable
import com.nextcloud.utils.extensions.getParcelableArgument
import com.nextcloud.utils.extensions.getSerializableArgument
import com.nextcloud.utils.extensions.isPublicOrMail
import com.nextcloud.utils.extensions.remainingDownloadLimit
import com.nextcloud.utils.extensions.setVisibilityWithAnimation
import com.nextcloud.utils.extensions.setVisibleIf
import com.owncloud.android.R
Expand Down Expand Up @@ -197,7 +198,6 @@ class FileDetailsSharingProcessFragment :
setCheckboxStates()
themeView()
setVisibilitiesOfShareOption()
toggleNextButtonAvailability(isAnySharePermissionChecked())
logShareInfo()
}

Expand Down Expand Up @@ -491,15 +491,19 @@ class FileDetailsSharingProcessFragment :
}

private fun updateFileDownloadLimitView() {
if (canSetDownloadLimit()) {
binding.shareProcessSetDownloadLimitSwitch.visibility = View.VISIBLE
if (!canSetDownloadLimit()) {
return
}

val currentDownloadLimit = share?.fileDownloadLimit?.limit ?: capabilities.filesDownloadLimitDefault
if (currentDownloadLimit > 0) {
binding.shareProcessSetDownloadLimitSwitch.isChecked = true
showFileDownloadLimitInput(true)
binding.shareProcessSetDownloadLimitInput.setText("$currentDownloadLimit")
}
// user can set download limit thus no need to rely on current limit to show download limit
showFileDownloadLimitInput(true)
binding.shareProcessSetDownloadLimitSwitch.visibility = View.VISIBLE
binding.shareProcessSetDownloadLimitInput.visibility = View.VISIBLE

val currentLimit = share?.remainingDownloadLimit() ?: return
if (currentLimit > 0) {
binding.shareProcessSetDownloadLimitSwitch.isChecked = true
binding.shareProcessSetDownloadLimitInput.setText(currentLimit.toString())
}
}

Expand Down Expand Up @@ -585,7 +589,6 @@ class FileDetailsSharingProcessFragment :

val isCustomPermissionSelected = (optionId == R.id.custom_permission_radio_button)
customPermissionLayout.setVisibilityWithAnimation(isCustomPermissionSelected)
toggleNextButtonAvailability(true)
}
// endregion
}
Expand All @@ -610,13 +613,6 @@ class FileDetailsSharingProcessFragment :
)
}

private fun toggleNextButtonAvailability(value: Boolean) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User can always update current share just like iOS and Web

binding.run {
shareProcessBtnNext.isEnabled = value
shareProcessBtnNext.isClickable = value
}
}

@Suppress("NestedBlockDepth")
private fun setCheckboxStates() {
val currentPermissions = share?.permissions ?: permission
Expand Down Expand Up @@ -674,7 +670,6 @@ class FileDetailsSharingProcessFragment :

private fun togglePermission(isChecked: Boolean, permissionFlag: Int) {
permission = SharePermissionManager.togglePermission(isChecked, permission, permissionFlag)
toggleNextButtonAvailability(true)
}

private fun showExpirationDateDialog(chosenDateInMillis: Long = chosenExpDateInMills) {
Expand Down Expand Up @@ -779,14 +774,6 @@ class FileDetailsSharingProcessFragment :
return
}

if (!isSharePermissionChecked() && !isCustomPermissionSelectedAndAnyCustomPermissionTypeChecked()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User can always update current share just like iOS and Web

DisplayUtils.showSnackMessage(
binding.root,
R.string.file_details_sharing_fragment_custom_permission_not_selected
)
return
}

// if modifying existing share information then execute the process
if (share != null) {
updateShare()
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,6 @@
<string name="sync_duplication">Sync duplication</string>
<string name="server_not_reachable">Could not load content</string>
<string name="server_not_reachable_content">The device is likely not connected to the internet</string>
<string name="file_details_sharing_fragment_custom_permission_not_selected">Please select custom permission</string>
<string name="unknown">Unknown</string>
<string name="upload_missing_storage_permission_title">Upload Stopped – Storage Permission Required</string>
<string name="upload_missing_storage_permission_description">Your files cannot be uploaded without access to local storage. Tap to grant permission.</string>
Expand Down
Loading