Skip to content

Commit db2dc63

Browse files
committed
add new checkboxes
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 5f03cf4 commit db2dc63

3 files changed

Lines changed: 151 additions & 70 deletions

File tree

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

Lines changed: 94 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ class FileDetailsSharingProcessFragment :
8080
shareType: ShareType,
8181
secureShare: Boolean
8282
): FileDetailsSharingProcessFragment {
83-
val args = Bundle()
84-
args.putParcelable(ARG_OCFILE, file)
85-
args.putSerializable(ARG_SHARE_TYPE, shareType)
86-
args.putString(ARG_SHAREE_NAME, shareeName)
87-
args.putBoolean(ARG_SECURE_SHARE, secureShare)
88-
val fragment = FileDetailsSharingProcessFragment()
89-
fragment.arguments = args
90-
return fragment
83+
val bundle = Bundle().apply {
84+
putParcelable(ARG_OCFILE, file)
85+
putSerializable(ARG_SHARE_TYPE, shareType)
86+
putString(ARG_SHAREE_NAME, shareeName)
87+
putBoolean(ARG_SECURE_SHARE, secureShare)
88+
}
89+
90+
return FileDetailsSharingProcessFragment().apply {
91+
arguments = bundle
92+
}
9193
}
9294

9395
/**
@@ -100,14 +102,16 @@ class FileDetailsSharingProcessFragment :
100102
isReshareShown: Boolean,
101103
isExpirationDateShown: Boolean
102104
): FileDetailsSharingProcessFragment {
103-
val args = Bundle()
104-
args.putParcelable(ARG_OCSHARE, share)
105-
args.putInt(ARG_SCREEN_TYPE, screenType)
106-
args.putBoolean(ARG_RESHARE_SHOWN, isReshareShown)
107-
args.putBoolean(ARG_EXP_DATE_SHOWN, isExpirationDateShown)
108-
val fragment = FileDetailsSharingProcessFragment()
109-
fragment.arguments = args
110-
return fragment
105+
val bundle = Bundle().apply {
106+
putParcelable(ARG_OCSHARE, share)
107+
putInt(ARG_SCREEN_TYPE, screenType)
108+
putBoolean(ARG_RESHARE_SHOWN, isReshareShown)
109+
putBoolean(ARG_EXP_DATE_SHOWN, isExpirationDateShown)
110+
}
111+
112+
return FileDetailsSharingProcessFragment().apply {
113+
arguments = bundle
114+
}
111115
}
112116
}
113117

@@ -190,28 +194,44 @@ class FileDetailsSharingProcessFragment :
190194
}
191195

192196
private fun themeView() {
193-
viewThemeUtils.platform.colorTextView(binding.shareProcessEditShareLink)
194-
viewThemeUtils.platform.colorTextView(binding.shareProcessAdvancePermissionTitle)
195-
196-
viewThemeUtils.platform.themeRadioButton(binding.shareProcessPermissionReadOnly)
197-
viewThemeUtils.platform.themeRadioButton(binding.shareProcessPermissionUploadEditing)
198-
viewThemeUtils.platform.themeRadioButton(binding.shareProcessPermissionFileDrop)
199-
200-
viewThemeUtils.platform.themeCheckbox(binding.shareProcessAllowResharingCheckbox)
201-
202-
viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessSetPasswordSwitch)
203-
viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessSetExpDateSwitch)
204-
viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessSetDownloadLimitSwitch)
205-
viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessHideDownloadCheckbox)
206-
viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessChangeNameSwitch)
197+
viewThemeUtils.platform.run {
198+
binding.run {
199+
colorTextView(shareProcessEditShareLink)
200+
colorTextView(shareProcessAdvancePermissionTitle)
201+
202+
themeRadioButton(shareProcessPermissionReadOnly)
203+
themeRadioButton(shareProcessPermissionUploadEditing)
204+
themeRadioButton(shareProcessPermissionFileDrop)
205+
206+
themeCheckbox(shareCustomCheckbox)
207+
themeCheckbox(shareReadCheckbox)
208+
themeCheckbox(shareCreateCheckbox)
209+
themeCheckbox(shareEditCheckbox)
210+
themeCheckbox(shareProcessAllowResharingCheckbox)
211+
themeCheckbox(shareDeleteCheckbox)
212+
}
213+
}
207214

208-
viewThemeUtils.material.colorTextInputLayout(binding.shareProcessEnterPasswordContainer)
209-
viewThemeUtils.material.colorTextInputLayout(binding.shareProcessSetDownloadLimitInputContainer)
210-
viewThemeUtils.material.colorTextInputLayout(binding.shareProcessChangeNameContainer)
211-
viewThemeUtils.material.colorTextInputLayout(binding.noteContainer)
215+
viewThemeUtils.androidx.run {
216+
binding.run {
217+
colorSwitchCompat(shareProcessSetPasswordSwitch)
218+
colorSwitchCompat(shareProcessSetExpDateSwitch)
219+
colorSwitchCompat(shareProcessSetDownloadLimitSwitch)
220+
colorSwitchCompat(shareProcessHideDownloadCheckbox)
221+
colorSwitchCompat(shareProcessChangeNameSwitch)
222+
}
223+
}
212224

213-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.shareProcessBtnNext)
214-
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.shareProcessBtnCancel)
225+
viewThemeUtils.material.run {
226+
binding.run {
227+
colorTextInputLayout(shareProcessEnterPasswordContainer)
228+
colorTextInputLayout(shareProcessSetDownloadLimitInputContainer)
229+
colorTextInputLayout(shareProcessChangeNameContainer)
230+
colorTextInputLayout(noteContainer)
231+
colorMaterialButtonPrimaryFilled(shareProcessBtnNext)
232+
colorMaterialButtonPrimaryOutlined(shareProcessBtnCancel)
233+
}
234+
}
215235
}
216236

217237
override fun onConfigurationChanged(newConfig: Configuration) {
@@ -243,11 +263,7 @@ class FileDetailsSharingProcessFragment :
243263
}
244264

245265
// show or hide expiry date
246-
if (isExpDateShown && !isSecureShare) {
247-
binding.shareProcessSetExpDateSwitch.visibility = View.VISIBLE
248-
} else {
249-
binding.shareProcessSetExpDateSwitch.visibility = View.GONE
250-
}
266+
binding.shareProcessSetExpDateSwitch.setVisibleIf(isExpDateShown && !isSecureShare)
251267
shareProcessStep = SCREEN_TYPE_PERMISSION
252268
}
253269

@@ -430,30 +446,39 @@ class FileDetailsSharingProcessFragment :
430446
}
431447

432448
private fun implementClickEvents() {
433-
binding.shareProcessBtnCancel.setOnClickListener {
434-
onCancelClick()
435-
}
436-
binding.shareProcessBtnNext.setOnClickListener {
437-
if (shareProcessStep == SCREEN_TYPE_PERMISSION) {
438-
validateShareProcessFirst()
439-
} else {
440-
validateShareProcessSecond()
449+
binding.run {
450+
shareProcessBtnCancel.setOnClickListener {
451+
onCancelClick()
452+
}
453+
shareProcessBtnNext.setOnClickListener {
454+
if (shareProcessStep == SCREEN_TYPE_PERMISSION) {
455+
validateShareProcessFirst()
456+
} else {
457+
validateShareProcessSecond()
458+
}
459+
}
460+
shareProcessSetPasswordSwitch.setOnCheckedChangeListener { _, isChecked ->
461+
showPasswordInput(isChecked)
462+
}
463+
shareProcessSetExpDateSwitch.setOnCheckedChangeListener { _, isChecked ->
464+
showExpirationDateInput(isChecked)
465+
}
466+
shareProcessSetDownloadLimitSwitch.setOnCheckedChangeListener { _, isChecked ->
467+
showFileDownloadLimitInput(isChecked)
468+
}
469+
shareProcessChangeNameSwitch.setOnCheckedChangeListener { _, isChecked ->
470+
showChangeNameInput(isChecked)
471+
}
472+
shareProcessSelectExpDate.setOnClickListener {
473+
showExpirationDateDialog()
474+
}
475+
shareCustomCheckbox.setOnCheckedChangeListener { _, isChecked ->
476+
shareReadCheckbox.isChecked = isChecked
477+
shareCreateCheckbox.isChecked = isChecked
478+
shareEditCheckbox.isChecked = isChecked
479+
shareProcessAllowResharingCheckbox.isChecked = isChecked
480+
shareDeleteCheckbox.isChecked = isChecked
441481
}
442-
}
443-
binding.shareProcessSetPasswordSwitch.setOnCheckedChangeListener { _, isChecked ->
444-
showPasswordInput(isChecked)
445-
}
446-
binding.shareProcessSetExpDateSwitch.setOnCheckedChangeListener { _, isChecked ->
447-
showExpirationDateInput(isChecked)
448-
}
449-
binding.shareProcessSetDownloadLimitSwitch.setOnCheckedChangeListener { _, isChecked ->
450-
showFileDownloadLimitInput(isChecked)
451-
}
452-
binding.shareProcessChangeNameSwitch.setOnCheckedChangeListener { _, isChecked ->
453-
showChangeNameInput(isChecked)
454-
}
455-
binding.shareProcessSelectExpDate.setOnClickListener {
456-
showExpirationDateDialog()
457482
}
458483
}
459484

@@ -493,8 +518,8 @@ class FileDetailsSharingProcessFragment :
493518
}
494519

495520
private fun showExpirationDateInput(isChecked: Boolean) {
496-
binding.shareProcessSelectExpDate.visibility = if (isChecked) View.VISIBLE else View.GONE
497-
binding.shareProcessExpDateDivider.visibility = if (isChecked) View.VISIBLE else View.GONE
521+
binding.shareProcessSelectExpDate.setVisibleIf(isChecked)
522+
binding.shareProcessExpDateDivider.setVisibleIf(isChecked)
498523

499524
// reset the expiration date if switch is unchecked
500525
if (!isChecked) {
@@ -527,9 +552,9 @@ class FileDetailsSharingProcessFragment :
527552
}
528553

529554
private fun getReSharePermission(): Int {
530-
val spb = SharePermissionsBuilder()
531-
spb.setSharePermission(true)
532-
return spb.build()
555+
return SharePermissionsBuilder().apply {
556+
setSharePermission(true)
557+
}.build()
533558
}
534559

535560
/**

app/src/main/res/layout/file_details_sharing_process_fragment.xml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,62 @@
7676
android:textColor="@color/primary"
7777
android:textStyle="bold"/>
7878

79+
<com.google.android.material.checkbox.MaterialCheckBox
80+
android:id="@+id/share_custom_checkbox"
81+
android:layout_width="match_parent"
82+
android:layout_height="wrap_content"
83+
android:minHeight="@dimen/minimum_size_for_touchable_area"
84+
android:text="@string/share_custom_permission"
85+
android:visibility="visible"
86+
tools:visibility="visible" />
87+
88+
<com.google.android.material.checkbox.MaterialCheckBox
89+
android:id="@+id/share_read_checkbox"
90+
android:layout_width="match_parent"
91+
android:layout_height="wrap_content"
92+
android:layout_marginStart="@dimen/standard_margin"
93+
android:minHeight="@dimen/minimum_size_for_touchable_area"
94+
android:text="@string/share_read_permission"
95+
android:visibility="gone"
96+
tools:visibility="visible" />
97+
98+
<com.google.android.material.checkbox.MaterialCheckBox
99+
android:id="@+id/share_create_checkbox"
100+
android:layout_width="match_parent"
101+
android:layout_height="wrap_content"
102+
android:layout_marginStart="@dimen/standard_margin"
103+
android:minHeight="@dimen/minimum_size_for_touchable_area"
104+
android:text="@string/share_create_permission"
105+
android:visibility="gone"
106+
tools:visibility="visible" />
107+
108+
<com.google.android.material.checkbox.MaterialCheckBox
109+
android:id="@+id/share_edit_checkbox"
110+
android:layout_width="match_parent"
111+
android:layout_height="wrap_content"
112+
android:layout_marginStart="@dimen/standard_margin"
113+
android:minHeight="@dimen/minimum_size_for_touchable_area"
114+
android:text="@string/share_edit_permission"
115+
android:visibility="gone"
116+
tools:visibility="visible" />
117+
79118
<com.google.android.material.checkbox.MaterialCheckBox
80119
android:id="@+id/share_process_allow_resharing_checkbox"
81120
android:layout_width="match_parent"
82121
android:layout_height="wrap_content"
122+
android:layout_marginStart="@dimen/standard_margin"
123+
android:minHeight="@dimen/minimum_size_for_touchable_area"
124+
android:text="@string/share_re_share_permission"
125+
android:visibility="gone"
126+
tools:visibility="visible" />
127+
128+
<com.google.android.material.checkbox.MaterialCheckBox
129+
android:id="@+id/share_delete_checkbox"
130+
android:layout_width="match_parent"
131+
android:layout_height="wrap_content"
132+
android:layout_marginStart="@dimen/standard_margin"
83133
android:minHeight="@dimen/minimum_size_for_touchable_area"
84-
android:text="@string/allow_resharing"
134+
android:text="@string/share_delete_permission"
85135
android:visibility="gone"
86136
tools:visibility="visible" />
87137

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,12 @@
10901090
<string name="share_link_with_label">Share link (%1$s)</string>
10911091
<string name="share_link">Share link</string>
10921092
<string name="allow_resharing">Allow resharing</string>
1093+
<string name="share_custom_permission">Custom permissions</string>
1094+
<string name="share_read_permission">Read</string>
1095+
<string name="share_create_permission">Create</string>
1096+
<string name="share_edit_permission">Edit</string>
1097+
<string name="share_re_share_permission">Share</string>
1098+
<string name="share_delete_permission">Delete</string>
10931099
<string name="link_share_view_only">View only</string>
10941100
<string name="link_share_editing">Editing</string>
10951101
<string name="link_share_allow_upload_and_editing">Allow upload and editing</string>

0 commit comments

Comments
 (0)