Skip to content

Commit 758ad2d

Browse files
committed
feat: add swipe to refresh for members and links
1 parent 148d5cf commit 758ad2d

2 files changed

Lines changed: 133 additions & 130 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ class SpaceMembersFragment : Fragment(), SpaceMembersAdapter.SpaceMembersAdapter
118118

119119
subscribeToViewModels()
120120

121+
binding.swipeRefreshMembers.setOnRefreshListener {
122+
spaceMembersViewModel.getSpacePermissions()
123+
spaceMembersViewModel.getSpaceMembers()
124+
}
125+
121126
binding.addMemberButton.setOnClickListener {
122127
spaceMembersViewModel.resetViewModel()
123128
listener?.addMember(
@@ -244,11 +249,11 @@ class SpaceMembersFragment : Fragment(), SpaceMembersAdapter.SpaceMembersAdapter
244249
showOrHideEmptyView(hasLinks)
245250
if (hasLinks) { showSpaceLinks(it.links) }
246251
}
247-
binding.indeterminateProgressBar.isVisible = false
252+
binding.swipeRefreshMembers.isRefreshing = false
248253
}
249254
}
250255
}
251-
is UIResult.Loading -> { binding.indeterminateProgressBar.isVisible = true }
256+
is UIResult.Loading -> { binding.swipeRefreshMembers.isRefreshing = true }
252257
is UIResult.Error -> {
253258
requireActivity().finish()
254259
Timber.e(uiResult.error, "Failed to retrieve space members for space: ${currentSpace.id} (${currentSpace.id})")

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

Lines changed: 126 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -16,155 +16,153 @@
1616
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
-->
1818

19-
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
19+
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
2020
xmlns:tools="http://schemas.android.com/tools"
2121
xmlns:app="http://schemas.android.com/apk/res-auto"
22-
android:id="@+id/shareScroll"
22+
android:id="@+id/swipe_refresh_members"
2323
android:layout_width="match_parent"
2424
android:layout_height="match_parent"
2525
tools:context=".presentation.spaces.members.SpaceMembersActivity">
2626

27-
<LinearLayout
28-
android:id="@+id/members_section"
27+
<androidx.core.widget.NestedScrollView
2928
android:layout_width="match_parent"
30-
android:layout_height="wrap_content"
31-
android:orientation="vertical">
29+
android:layout_height="match_parent">
3230

3331
<LinearLayout
34-
android:id="@+id/members_list_section"
32+
android:id="@+id/members_section"
3533
android:layout_width="match_parent"
3634
android:layout_height="wrap_content"
3735
android:orientation="vertical">
3836

39-
<androidx.constraintlayout.widget.ConstraintLayout
37+
<LinearLayout
38+
android:id="@+id/members_list_section"
4039
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"
7940
android:layout_height="wrap_content"
80-
android:layout_gravity="center"
81-
android:indeterminate="true"
82-
android:visibility="gone"/>
83-
84-
<androidx.recyclerview.widget.RecyclerView
85-
android:id="@+id/members_recycler_view"
41+
android:orientation="vertical">
42+
43+
<androidx.constraintlayout.widget.ConstraintLayout
44+
android:layout_width="match_parent"
45+
android:layout_height="match_parent"
46+
android:background="@color/actionbar_start_color">
47+
48+
<TextView
49+
android:id="@+id/members_title"
50+
android:layout_width="wrap_content"
51+
android:layout_height="50dp"
52+
android:layout_centerVertical="true"
53+
android:gravity="center"
54+
android:text="@string/members_title"
55+
android:layout_marginStart="@dimen/standard_half_margin"
56+
android:textAllCaps="true"
57+
android:textColor="@color/white"
58+
android:textStyle="bold"
59+
android:accessibilityHeading="true"
60+
app:layout_constraintStart_toStartOf="parent"
61+
app:layout_constraintTop_toTopOf="parent"/>
62+
63+
<ImageButton
64+
android:id="@+id/add_member_button"
65+
android:layout_width="48dp"
66+
android:layout_height="48dp"
67+
android:padding="@dimen/standard_padding"
68+
android:background="@color/transparent"
69+
android:src="@drawable/ic_add"
70+
android:contentDescription="@string/content_description_add_member"
71+
android:visibility="gone"
72+
android:focusable="true"
73+
android:clickable="true"
74+
app:layout_constraintEnd_toEndOf="parent"
75+
app:layout_constraintTop_toTopOf="parent"
76+
tools:visibility="visible"/>
77+
78+
</androidx.constraintlayout.widget.ConstraintLayout>
79+
80+
<androidx.recyclerview.widget.RecyclerView
81+
android:id="@+id/members_recycler_view"
82+
android:layout_width="match_parent"
83+
android:layout_height="wrap_content"
84+
android:scrollbars="vertical"/>
85+
86+
</LinearLayout>
87+
88+
<LinearLayout
89+
android:id="@+id/public_links_section"
8690
android:layout_width="match_parent"
8791
android:layout_height="wrap_content"
88-
android:scrollbars="vertical"/>
89-
90-
</LinearLayout>
91-
92-
<LinearLayout
93-
android:id="@+id/public_links_section"
94-
android:layout_width="match_parent"
95-
android:layout_height="wrap_content"
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">
92+
android:orientation="vertical">
93+
94+
<androidx.constraintlayout.widget.ConstraintLayout
95+
android:layout_width="match_parent"
96+
android:layout_height="match_parent"
97+
android:background="@color/actionbar_start_color">
98+
99+
<TextView
100+
android:id="@+id/public_links_title"
101+
android:layout_width="wrap_content"
102+
android:layout_height="50dp"
103+
android:layout_centerVertical="true"
104+
android:gravity="center"
105+
android:text="@string/share_via_link_section_title"
106+
android:layout_marginStart="@dimen/standard_half_margin"
107+
android:textAllCaps="true"
108+
android:textColor="@color/white"
109+
android:textStyle="bold"
110+
android:accessibilityHeading="true"
111+
app:layout_constraintStart_toStartOf="parent"
112+
app:layout_constraintTop_toTopOf="parent"/>
113+
114+
<ImageButton
115+
android:id="@+id/add_public_link_button"
116+
android:layout_width="48dp"
117+
android:layout_height="48dp"
118+
android:padding="@dimen/standard_padding"
119+
android:background="@color/transparent"
120+
android:src="@drawable/ic_add"
121+
android:contentDescription="@string/content_description_add_public_link"
122+
android:visibility="gone"
123+
android:focusable="true"
124+
android:clickable="true"
125+
app:layout_constraintEnd_toEndOf="parent"
126+
app:layout_constraintTop_toTopOf="parent"
127+
tools:visibility="visible"/>
128+
129+
</androidx.constraintlayout.widget.ConstraintLayout>
102130

103131
<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-
<ImageButton
119-
android:id="@+id/add_public_link_button"
120-
android:layout_width="48dp"
121-
android:layout_height="48dp"
122-
android:padding="@dimen/standard_padding"
123-
android:background="@color/transparent"
124-
android:src="@drawable/ic_add"
125-
android:contentDescription="@string/content_description_add_public_link"
126-
android:visibility="gone"
127-
android:focusable="true"
128-
android:clickable="true"
129-
app:layout_constraintEnd_toEndOf="parent"
130-
app:layout_constraintTop_toTopOf="parent"
131-
tools:visibility="visible"/>
132-
133-
</androidx.constraintlayout.widget.ConstraintLayout>
134-
135-
<TextView
136-
android:id="@+id/public_links_warning"
137-
android:layout_width="match_parent"
138-
android:layout_height="wrap_content"
139-
android:background="@color/warning_background_color"
140-
android:paddingTop="@dimen/standard_padding"
141-
android:paddingBottom="@dimen/standard_padding"
142-
android:paddingStart="@dimen/standard_half_padding"
143-
android:paddingEnd="@dimen/standard_half_padding"
144-
android:text="@string/share_warning_about_forwarding_space_public_links"
145-
android:textColor="@color/warning_grey_text"
146-
android:textSize="15sp" />
147-
148-
<androidx.recyclerview.widget.RecyclerView
149-
android:id="@+id/public_links_recycler_view"
150-
android:layout_width="match_parent"
151-
android:layout_height="wrap_content"
152-
android:scrollbars="vertical" />
132+
android:id="@+id/public_links_warning"
133+
android:layout_width="match_parent"
134+
android:layout_height="wrap_content"
135+
android:background="@color/warning_background_color"
136+
android:paddingTop="@dimen/standard_padding"
137+
android:paddingBottom="@dimen/standard_padding"
138+
android:paddingStart="@dimen/standard_half_padding"
139+
android:paddingEnd="@dimen/standard_half_padding"
140+
android:text="@string/share_warning_about_forwarding_space_public_links"
141+
android:textColor="@color/warning_grey_text"
142+
android:textSize="15sp" />
143+
144+
<androidx.recyclerview.widget.RecyclerView
145+
android:id="@+id/public_links_recycler_view"
146+
android:layout_width="match_parent"
147+
android:layout_height="wrap_content"
148+
android:scrollbars="vertical" />
153149

154-
<TextView
155-
android:id="@+id/no_public_links_message"
156-
android:layout_width="match_parent"
157-
android:layout_height="wrap_content"
158-
android:paddingTop="@dimen/standard_padding"
159-
android:paddingBottom="@dimen/standard_padding"
160-
android:paddingStart="@dimen/standard_half_padding"
161-
android:paddingEnd="@dimen/standard_half_padding"
162-
android:text="@string/share_no_public_links"
163-
android:textSize="15sp"
164-
android:visibility="gone"/>
150+
<TextView
151+
android:id="@+id/no_public_links_message"
152+
android:layout_width="match_parent"
153+
android:layout_height="wrap_content"
154+
android:paddingTop="@dimen/standard_padding"
155+
android:paddingBottom="@dimen/standard_padding"
156+
android:paddingStart="@dimen/standard_half_padding"
157+
android:paddingEnd="@dimen/standard_half_padding"
158+
android:text="@string/share_no_public_links"
159+
android:textSize="15sp"
160+
android:visibility="gone"/>
161+
162+
</LinearLayout>
165163

166164
</LinearLayout>
167165

168-
</LinearLayout>
166+
</androidx.core.widget.NestedScrollView>
169167

170-
</androidx.core.widget.NestedScrollView>
168+
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

0 commit comments

Comments
 (0)