Skip to content

Commit 85ccee3

Browse files
committed
add setup view region
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 53a117a commit 85ccee3

1 file changed

Lines changed: 66 additions & 63 deletions

File tree

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

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class FileDetailsSharingProcessFragment :
192192
if (shareProcessStep == SCREEN_TYPE_PERMISSION || shareProcessStep == SCREEN_TYPE_CUSTOM_PERMISSION) {
193193
showShareProcessFirst()
194194
} else {
195-
showShareProcessSecond()
195+
updateViewForNoteScreenType()
196196
}
197197

198198
implementClickEvents()
@@ -333,6 +333,7 @@ class FileDetailsSharingProcessFragment :
333333
showFileDownloadLimitInput(binding.shareProcessSetDownloadLimitSwitch.isChecked)
334334
}
335335

336+
// region ViewUpdates
336337
private fun updateViewForShareType() {
337338
when (shareType) {
338339
ShareType.EMAIL -> {
@@ -384,20 +385,19 @@ class FileDetailsSharingProcessFragment :
384385
}
385386
}
386387

387-
/**
388-
* update views where share type external or link share
389-
*/
390388
private fun updateViewForExternalAndLinkShare() {
391-
binding.shareProcessHideDownloadCheckbox.visibility = View.VISIBLE
392-
binding.shareProcessAllowResharingCheckbox.visibility = View.GONE
393-
binding.shareProcessSetPasswordSwitch.visibility = View.VISIBLE
389+
binding.run {
390+
shareProcessHideDownloadCheckbox.visibility = View.VISIBLE
391+
shareProcessAllowResharingCheckbox.visibility = View.GONE
392+
shareProcessSetPasswordSwitch.visibility = View.VISIBLE
394393

395-
if (share != null) {
396-
if (SharingMenuHelper.isFileDrop(share)) {
397-
binding.shareProcessHideDownloadCheckbox.visibility = View.GONE
398-
} else {
399-
binding.shareProcessHideDownloadCheckbox.visibility = View.VISIBLE
400-
binding.shareProcessHideDownloadCheckbox.isChecked = share?.isHideFileDownload == true
394+
if (share != null) {
395+
if (SharingMenuHelper.isFileDrop(share)) {
396+
shareProcessHideDownloadCheckbox.visibility = View.GONE
397+
} else {
398+
shareProcessHideDownloadCheckbox.visibility = View.VISIBLE
399+
shareProcessHideDownloadCheckbox.isChecked = share?.isHideFileDownload == true
400+
}
401401
}
402402
}
403403
}
@@ -432,37 +432,41 @@ class FileDetailsSharingProcessFragment :
432432
}
433433

434434
private fun updateViewForFile() {
435-
binding.editingRadioButton.text = getString(R.string.link_share_editing)
436-
binding.fileDropRadioButton.visibility = View.GONE
435+
binding.run {
436+
editingRadioButton.text = getString(R.string.link_share_editing)
437+
fileDropRadioButton.visibility = View.GONE
438+
}
437439
}
438440

439441
private fun updateViewForFolder() {
440-
binding.editingRadioButton.text = getString(R.string.link_share_allow_upload_and_editing)
441-
binding.fileDropRadioButton.visibility = View.VISIBLE
442-
if (isSecureShare) {
443-
binding.fileDropRadioButton.visibility = View.GONE
444-
binding.shareProcessAllowResharingCheckbox.visibility = View.GONE
445-
binding.shareProcessSetExpDateSwitch.visibility = View.GONE
442+
binding.run {
443+
editingRadioButton.text = getString(R.string.link_share_allow_upload_and_editing)
444+
fileDropRadioButton.visibility = View.VISIBLE
445+
if (isSecureShare) {
446+
fileDropRadioButton.visibility = View.GONE
447+
shareProcessAllowResharingCheckbox.visibility = View.GONE
448+
shareProcessSetExpDateSwitch.visibility = View.GONE
449+
}
446450
}
447451
}
448452

449-
/**
450-
* update views for screen type Note
451-
*/
452-
private fun showShareProcessSecond() {
453-
binding.shareProcessGroupOne.visibility = View.GONE
454-
binding.shareProcessEditShareLink.visibility = View.GONE
455-
binding.shareProcessGroupTwo.visibility = View.VISIBLE
456-
if (share != null) {
457-
binding.shareProcessBtnNext.text = getString(R.string.set_note)
458-
binding.noteText.setText(share?.note)
459-
} else {
460-
binding.shareProcessBtnNext.text = getString(R.string.send_share)
461-
binding.noteText.setText(R.string.empty)
453+
private fun updateViewForNoteScreenType() {
454+
binding.run {
455+
shareProcessGroupOne.visibility = View.GONE
456+
shareProcessEditShareLink.visibility = View.GONE
457+
shareProcessGroupTwo.visibility = View.VISIBLE
458+
if (share != null) {
459+
shareProcessBtnNext.text = getString(R.string.set_note)
460+
noteText.setText(share?.note)
461+
} else {
462+
shareProcessBtnNext.text = getString(R.string.send_share)
463+
noteText.setText(R.string.empty)
464+
}
465+
shareProcessStep = SCREEN_TYPE_NOTE
466+
shareProcessBtnNext.performClick()
462467
}
463-
shareProcessStep = SCREEN_TYPE_NOTE
464-
binding.shareProcessBtnNext.performClick()
465468
}
469+
// endregion
466470

467471
@Suppress("LongMethod")
468472
private fun implementClickEvents() {
@@ -474,7 +478,7 @@ class FileDetailsSharingProcessFragment :
474478
if (shareProcessStep == SCREEN_TYPE_PERMISSION) {
475479
validateShareProcessFirst()
476480
} else {
477-
validateShareProcessSecond()
481+
createOrUpdateShare()
478482
}
479483
}
480484
shareProcessSetPasswordSwitch.setOnCheckedChangeListener { _, isChecked ->
@@ -694,8 +698,19 @@ class FileDetailsSharingProcessFragment :
694698
removeCurrentFragment()
695699
} else {
696700
// else show step 2 (note screen)
697-
showShareProcessSecond()
701+
updateViewForNoteScreenType()
702+
}
703+
}
704+
705+
private fun createOrUpdateShare() {
706+
val noteText = binding.noteText.text.toString().trim()
707+
// if modifying existing share then directly update the note and send email
708+
if (share != null && share?.note != noteText) {
709+
fileOperationsHelper?.updateNoteToShare(share, noteText)
710+
} else {
711+
createShare(noteText)
698712
}
713+
removeCurrentFragment()
699714
}
700715

701716
private fun updateShare() {
@@ -726,31 +741,19 @@ class FileDetailsSharingProcessFragment :
726741
}
727742
}
728743

729-
/**
730-
* method to validate step 2 (note screen) information
731-
*/
732-
private fun validateShareProcessSecond() {
733-
val noteText = binding.noteText.text.toString().trim()
734-
// if modifying existing share then directly update the note and send email
735-
if (share != null && share?.note != noteText) {
736-
fileOperationsHelper?.updateNoteToShare(share, noteText)
737-
} else {
738-
// else create new share
739-
fileOperationsHelper?.shareFileWithSharee(
740-
file,
741-
shareeName,
742-
shareType,
743-
permission,
744-
binding
745-
.shareProcessHideDownloadCheckbox.isChecked,
746-
binding.shareProcessEnterPassword.text.toString().trim(),
747-
chosenExpDateInMills,
748-
noteText,
749-
binding.shareProcessChangeName.text.toString().trim(),
750-
true
751-
)
752-
}
753-
removeCurrentFragment()
744+
private fun createShare(noteText: String) {
745+
fileOperationsHelper?.shareFileWithSharee(
746+
file,
747+
shareeName,
748+
shareType,
749+
permission,
750+
binding.shareProcessHideDownloadCheckbox.isChecked,
751+
binding.shareProcessEnterPassword.text.toString().trim(),
752+
chosenExpDateInMills,
753+
noteText,
754+
binding.shareProcessChangeName.text.toString().trim(),
755+
true
756+
)
754757
}
755758

756759
/**

0 commit comments

Comments
 (0)