mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Merge pull request #10313 from nextcloud/chore/detekt-cleanup-again
Fix last remaining unsuppressed detekt issues
This commit is contained in:
commit
42e79cb176
2 changed files with 84 additions and 88 deletions
|
@ -1,5 +1,5 @@
|
|||
build:
|
||||
maxIssues: 3
|
||||
maxIssues: 0
|
||||
weights:
|
||||
# complexity: 2
|
||||
# LongParameterList: 1
|
||||
|
|
|
@ -181,8 +181,22 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
|||
binding.shareProcessEditShareLink.visibility = View.VISIBLE
|
||||
binding.shareProcessGroupTwo.visibility = View.GONE
|
||||
|
||||
// set up UI for modifying share
|
||||
if (share != null) {
|
||||
setupModificationUI()
|
||||
} else {
|
||||
setupUpdateUI()
|
||||
}
|
||||
|
||||
// show or hide expiry date
|
||||
if (isExpDateShown) {
|
||||
binding.shareProcessSetExpDateSwitch.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.shareProcessSetExpDateSwitch.visibility = View.GONE
|
||||
}
|
||||
shareProcessStep = SCREEN_TYPE_PERMISSION
|
||||
}
|
||||
|
||||
private fun setupModificationUI() {
|
||||
if (share?.isFolder == true) {
|
||||
updateViewForFolder()
|
||||
} else {
|
||||
|
@ -213,8 +227,7 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
|||
showExpirationDateInput(binding.shareProcessSetExpDateSwitch.isChecked)
|
||||
}
|
||||
|
||||
// update UI for creating new share
|
||||
else {
|
||||
private fun setupUpdateUI() {
|
||||
binding.shareProcessBtnNext.text = requireContext().resources.getString(R.string.common_next)
|
||||
file.let {
|
||||
if (file?.isFolder == true) {
|
||||
|
@ -228,15 +241,6 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
|||
showExpirationDateInput(binding.shareProcessSetExpDateSwitch.isChecked)
|
||||
}
|
||||
|
||||
// show or hide expiry date
|
||||
if (isExpDateShown) {
|
||||
binding.shareProcessSetExpDateSwitch.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.shareProcessSetExpDateSwitch.visibility = View.GONE
|
||||
}
|
||||
shareProcessStep = SCREEN_TYPE_PERMISSION
|
||||
}
|
||||
|
||||
/**
|
||||
* method to update views on the basis of Share type
|
||||
*/
|
||||
|
@ -434,54 +438,28 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
|||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun validateShareProcessFirst() {
|
||||
// get the permissions on the basis of selection
|
||||
when {
|
||||
binding.shareProcessPermissionReadOnly.isChecked -> {
|
||||
permission = OCShare.READ_PERMISSION_FLAG
|
||||
}
|
||||
binding.shareProcessPermissionUploadEditing.isChecked -> {
|
||||
permission = if (file?.isFolder == true || share?.isFolder == true) {
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER
|
||||
} else {
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE
|
||||
}
|
||||
}
|
||||
binding.shareProcessPermissionFileDrop.isChecked -> {
|
||||
permission = OCShare.CREATE_PERMISSION_FLAG
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.shareProcessAllowResharingCheckbox.isChecked) {
|
||||
permission = getResharePermission()
|
||||
}
|
||||
|
||||
permission = getSelectedPermission()
|
||||
if (permission == OCShare.NO_PERMISSION) {
|
||||
DisplayUtils.showSnackMessage(binding.root, R.string.no_share_permission_selected)
|
||||
return
|
||||
}
|
||||
|
||||
if (binding.shareProcessSetPasswordSwitch.isChecked && TextUtils.isEmpty(
|
||||
binding.shareProcessEnterPassword
|
||||
.text.toString().trim()
|
||||
)
|
||||
if (binding.shareProcessSetPasswordSwitch.isChecked &&
|
||||
binding.shareProcessEnterPassword.text?.trim().isNullOrEmpty()
|
||||
) {
|
||||
DisplayUtils.showSnackMessage(binding.root, R.string.share_link_empty_password)
|
||||
return
|
||||
}
|
||||
|
||||
if (binding.shareProcessSetExpDateSwitch.isChecked && TextUtils.isEmpty(
|
||||
binding.shareProcessSelectExpDate
|
||||
.text.toString().trim()
|
||||
)
|
||||
if (binding.shareProcessSetExpDateSwitch.isChecked &&
|
||||
binding.shareProcessSelectExpDate.text?.trim().isNullOrEmpty()
|
||||
) {
|
||||
showExpirationDateDialog()
|
||||
return
|
||||
}
|
||||
|
||||
if (binding.shareProcessChangeNameSwitch.isChecked && TextUtils.isEmpty(
|
||||
binding.shareProcessChangeNameEt
|
||||
.text.toString().trim()
|
||||
)
|
||||
if (binding.shareProcessChangeNameSwitch.isChecked &&
|
||||
binding.shareProcessChangeNameEt.text?.trim().isNullOrEmpty()
|
||||
) {
|
||||
DisplayUtils.showSnackMessage(binding.root, R.string.label_empty)
|
||||
return
|
||||
|
@ -489,6 +467,29 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
|||
|
||||
// if modifying existing share information then execute the process
|
||||
if (share != null) {
|
||||
updateShare()
|
||||
removeCurrentFragment()
|
||||
} else {
|
||||
// else show step 2 (note screen)
|
||||
showShareProcessSecond()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the permissions on the basis of selection
|
||||
*/
|
||||
private fun getSelectedPermission() = when {
|
||||
binding.shareProcessAllowResharingCheckbox.isChecked -> getResharePermission()
|
||||
binding.shareProcessPermissionReadOnly.isChecked -> OCShare.READ_PERMISSION_FLAG
|
||||
binding.shareProcessPermissionUploadEditing.isChecked -> when {
|
||||
file?.isFolder == true || share?.isFolder == true -> OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER
|
||||
else -> OCShare.MAXIMUM_PERMISSIONS_FOR_FILE
|
||||
}
|
||||
binding.shareProcessPermissionFileDrop.isChecked -> OCShare.CREATE_PERMISSION_FLAG
|
||||
else -> permission
|
||||
}
|
||||
|
||||
private fun updateShare() {
|
||||
fileOperationsHelper?.updateShareInformation(
|
||||
share, permission,
|
||||
binding.shareProcessHideDownloadCheckbox.isChecked,
|
||||
|
@ -499,11 +500,6 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
|||
if (!TextUtils.isEmpty(share?.shareLink)) {
|
||||
ClipboardUtil.copyToClipboard(activity, share?.shareLink)
|
||||
}
|
||||
removeCurrentFragment()
|
||||
} else {
|
||||
// else show step 2 (note screen)
|
||||
showShareProcessSecond()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue