Skip to content

Commit 5870a78

Browse files
committed
fix: hide public links when there is no read permission
fix: remove updateToolbarTitle() as this is not in the requirement fix: keep simple UX refactor: remove updateMembersLoadingProgressVisibility refactor: resolve code review comment feedback fix: remove redundant properties
1 parent bf812a9 commit 5870a78

2 files changed

Lines changed: 122 additions & 106 deletions

File tree

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/members/SpaceMembersFragment.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class SpaceMembersFragment : Fragment(), SpaceMembersAdapter.SpaceMembersAdapter
101101
canEditMembers = it.getBoolean(CAN_EDIT_MEMBERS, false)
102102
canReadMembers = it.getBoolean(CAN_READ_MEMBERS, false)
103103
}
104-
binding.membersRecyclerView.isVisible = canReadMembers
105104

106105
subscribeToViewModels()
107106

@@ -208,11 +207,12 @@ class SpaceMembersFragment : Fragment(), SpaceMembersAdapter.SpaceMembersAdapter
208207
spaceMember.roles.contains(OCRoleType.toString(OCRoleType.CAN_MANAGE)) }
209208
spaceMembers = it.members
210209
addMemberRoles = it.roles
211-
val membersForList = if (canReadMembers) spaceMembers else emptyList()
212-
spaceMembersAdapter.setSpaceMembers(membersForList, roles, canRemoveMembers, canEditMembers, numberOfManagers)
213-
val hasLinks = it.links.isNotEmpty()
214-
showOrHideEmptyView(hasLinks)
215-
if (hasLinks) { showSpaceLinks(it.links) }
210+
if (canReadMembers) {
211+
spaceMembersAdapter.setSpaceMembers(spaceMembers, roles, canRemoveMembers, canEditMembers, numberOfManagers)
212+
val hasLinks = it.links.isNotEmpty()
213+
showOrHideEmptyView(hasLinks)
214+
if (hasLinks) { showSpaceLinks(it.links) }
215+
}
216216
binding.indeterminateProgressBar.isVisible = false
217217
}
218218
}
@@ -237,9 +237,11 @@ class SpaceMembersFragment : Fragment(), SpaceMembersAdapter.SpaceMembersAdapter
237237
canRemoveMembers = DRIVES_DELETE_PERMISSION in spacePermissions
238238
canEditMembers = DRIVES_UPDATE_PERMISSION in spacePermissions
239239
canReadMembers = DRIVES_READ_PERMISSION in spacePermissions
240-
binding.membersRecyclerView.isVisible = canReadMembers
241-
val membersForList = if (canReadMembers) spaceMembers else emptyList()
242-
spaceMembersAdapter.setSpaceMembers(membersForList, roles, canRemoveMembers, canEditMembers, numberOfManagers)
240+
binding.membersListSection.isVisible = canReadMembers
241+
binding.publicLinksSection.isVisible = canReadMembers
242+
if (canReadMembers) {
243+
spaceMembersAdapter.setSpaceMembers(spaceMembers, roles, canRemoveMembers, canEditMembers, numberOfManagers)
244+
}
243245
}
244246
}
245247
is UIResult.Loading -> { }

owncloudApp/src/main/res/layout/members_fragment.xml

Lines changed: 111 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -30,111 +30,125 @@
3030
android:layout_height="wrap_content"
3131
android:orientation="vertical">
3232

33-
<androidx.constraintlayout.widget.ConstraintLayout
33+
<LinearLayout
34+
android:id="@+id/members_list_section"
3435
android:layout_width="match_parent"
35-
android:layout_height="match_parent"
36-
android:background="@color/actionbar_start_color">
37-
38-
<TextView
39-
android:id="@+id/members_title"
40-
android:layout_width="wrap_content"
41-
android:layout_height="50dp"
42-
android:layout_centerVertical="true"
43-
android:gravity="center"
44-
android:text="@string/members_title"
45-
android:layout_marginStart="@dimen/standard_half_margin"
46-
android:textAllCaps="true"
47-
android:textColor="@color/white"
48-
android:textStyle="bold"
49-
android:accessibilityHeading="true"
50-
app:layout_constraintStart_toStartOf="parent"
51-
app:layout_constraintTop_toTopOf="parent"/>
52-
53-
<ImageButton
54-
android:id="@+id/add_member_button"
55-
android:layout_width="48dp"
56-
android:layout_height="48dp"
57-
android:padding="@dimen/standard_padding"
58-
android:background="@color/transparent"
59-
android:src="@drawable/ic_add"
60-
android:contentDescription="@string/content_description_add_member"
61-
android:visibility="gone"
62-
android:focusable="true"
63-
android:clickable="true"
64-
app:layout_constraintEnd_toEndOf="parent"
65-
app:layout_constraintTop_toTopOf="parent"
66-
tools:visibility="visible"/>
67-
68-
</androidx.constraintlayout.widget.ConstraintLayout>
69-
70-
<ProgressBar
71-
android:id="@+id/indeterminate_progress_bar"
72-
android:layout_width="wrap_content"
7336
android:layout_height="wrap_content"
74-
android:layout_gravity="center"
75-
android:indeterminate="true"
76-
android:visibility="gone"/>
37+
android:orientation="vertical">
38+
39+
<androidx.constraintlayout.widget.ConstraintLayout
40+
android:layout_width="match_parent"
41+
android:layout_height="match_parent"
42+
android:background="@color/actionbar_start_color">
43+
44+
<TextView
45+
android:id="@+id/members_title"
46+
android:layout_width="wrap_content"
47+
android:layout_height="50dp"
48+
android:layout_centerVertical="true"
49+
android:gravity="center"
50+
android:text="@string/members_title"
51+
android:layout_marginStart="@dimen/standard_half_margin"
52+
android:textAllCaps="true"
53+
android:textColor="@color/white"
54+
android:textStyle="bold"
55+
android:accessibilityHeading="true"
56+
app:layout_constraintStart_toStartOf="parent"
57+
app:layout_constraintTop_toTopOf="parent"/>
58+
59+
<ImageButton
60+
android:id="@+id/add_member_button"
61+
android:layout_width="48dp"
62+
android:layout_height="48dp"
63+
android:padding="@dimen/standard_padding"
64+
android:background="@color/transparent"
65+
android:src="@drawable/ic_add"
66+
android:contentDescription="@string/content_description_add_member"
67+
android:visibility="gone"
68+
android:focusable="true"
69+
android:clickable="true"
70+
app:layout_constraintEnd_toEndOf="parent"
71+
app:layout_constraintTop_toTopOf="parent"
72+
tools:visibility="visible"/>
73+
74+
</androidx.constraintlayout.widget.ConstraintLayout>
75+
76+
<ProgressBar
77+
android:id="@+id/indeterminate_progress_bar"
78+
android:layout_width="wrap_content"
79+
android:layout_height="wrap_content"
80+
android:layout_gravity="center"
81+
android:indeterminate="true"
82+
android:visibility="gone"/>
7783

78-
<androidx.recyclerview.widget.RecyclerView
79-
android:id="@+id/members_recycler_view"
80-
android:layout_width="match_parent"
81-
android:layout_height="wrap_content"
82-
android:scrollbars="vertical"
83-
android:visibility="visible"
84-
tools:visibility="visible"/>
84+
<androidx.recyclerview.widget.RecyclerView
85+
android:id="@+id/members_recycler_view"
86+
android:layout_width="match_parent"
87+
android:layout_height="wrap_content"
88+
android:scrollbars="vertical"/>
8589

86-
<androidx.constraintlayout.widget.ConstraintLayout
87-
android:layout_width="match_parent"
88-
android:layout_height="match_parent"
89-
android:background="@color/actionbar_start_color">
90+
</LinearLayout>
9091

91-
<TextView
92-
android:id="@+id/public_links_title"
93-
android:layout_width="wrap_content"
94-
android:layout_height="50dp"
95-
android:layout_centerVertical="true"
96-
android:gravity="center"
97-
android:text="@string/share_via_link_section_title"
98-
android:layout_marginStart="@dimen/standard_half_margin"
99-
android:textAllCaps="true"
100-
android:textColor="@color/white"
101-
android:textStyle="bold"
102-
android:accessibilityHeading="true"
103-
app:layout_constraintStart_toStartOf="parent"
104-
app:layout_constraintTop_toTopOf="parent"/>
105-
106-
</androidx.constraintlayout.widget.ConstraintLayout>
107-
108-
<TextView
109-
android:id="@+id/public_links_warning"
110-
android:layout_width="match_parent"
111-
android:layout_height="wrap_content"
112-
android:background="@color/warning_background_color"
113-
android:paddingTop="@dimen/standard_padding"
114-
android:paddingBottom="@dimen/standard_padding"
115-
android:paddingStart="@dimen/standard_half_padding"
116-
android:paddingEnd="@dimen/standard_half_padding"
117-
android:text="@string/share_warning_about_forwarding_space_public_links"
118-
android:textColor="@color/warning_grey_text"
119-
android:textSize="15sp" />
120-
121-
<androidx.recyclerview.widget.RecyclerView
122-
android:id="@+id/public_links_recycler_view"
92+
<LinearLayout
93+
android:id="@+id/public_links_section"
12394
android:layout_width="match_parent"
12495
android:layout_height="wrap_content"
125-
android:scrollbars="vertical" />
96+
android:orientation="vertical">
97+
98+
<androidx.constraintlayout.widget.ConstraintLayout
99+
android:layout_width="match_parent"
100+
android:layout_height="match_parent"
101+
android:background="@color/actionbar_start_color">
102+
103+
<TextView
104+
android:id="@+id/public_links_title"
105+
android:layout_width="wrap_content"
106+
android:layout_height="50dp"
107+
android:layout_centerVertical="true"
108+
android:gravity="center"
109+
android:text="@string/share_via_link_section_title"
110+
android:layout_marginStart="@dimen/standard_half_margin"
111+
android:textAllCaps="true"
112+
android:textColor="@color/white"
113+
android:textStyle="bold"
114+
android:accessibilityHeading="true"
115+
app:layout_constraintStart_toStartOf="parent"
116+
app:layout_constraintTop_toTopOf="parent"/>
117+
118+
</androidx.constraintlayout.widget.ConstraintLayout>
126119

127-
<TextView
128-
android:id="@+id/no_public_links_message"
129-
android:layout_width="match_parent"
130-
android:layout_height="wrap_content"
131-
android:paddingTop="@dimen/standard_padding"
132-
android:paddingBottom="@dimen/standard_padding"
133-
android:paddingStart="@dimen/standard_half_padding"
134-
android:paddingEnd="@dimen/standard_half_padding"
135-
android:text="@string/share_no_public_links"
136-
android:textSize="15sp"
137-
android:visibility="gone"/>
120+
<TextView
121+
android:id="@+id/public_links_warning"
122+
android:layout_width="match_parent"
123+
android:layout_height="wrap_content"
124+
android:background="@color/warning_background_color"
125+
android:paddingTop="@dimen/standard_padding"
126+
android:paddingBottom="@dimen/standard_padding"
127+
android:paddingStart="@dimen/standard_half_padding"
128+
android:paddingEnd="@dimen/standard_half_padding"
129+
android:text="@string/share_warning_about_forwarding_space_public_links"
130+
android:textColor="@color/warning_grey_text"
131+
android:textSize="15sp" />
132+
133+
<androidx.recyclerview.widget.RecyclerView
134+
android:id="@+id/public_links_recycler_view"
135+
android:layout_width="match_parent"
136+
android:layout_height="wrap_content"
137+
android:scrollbars="vertical" />
138+
139+
<TextView
140+
android:id="@+id/no_public_links_message"
141+
android:layout_width="match_parent"
142+
android:layout_height="wrap_content"
143+
android:paddingTop="@dimen/standard_padding"
144+
android:paddingBottom="@dimen/standard_padding"
145+
android:paddingStart="@dimen/standard_half_padding"
146+
android:paddingEnd="@dimen/standard_half_padding"
147+
android:text="@string/share_no_public_links"
148+
android:textSize="15sp"
149+
android:visibility="gone"/>
150+
151+
</LinearLayout>
138152

139153
</LinearLayout>
140154

0 commit comments

Comments
 (0)