Skip to content

Commit f7d198a

Browse files
committed
feat: create and display the new layout to add members
1 parent 7db90f9 commit f7d198a

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author Jorge Aguado Recio
5+
*
6+
* Copyright (C) 2026 ownCloud GmbH.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.owncloud.android.presentation.spaces.members
22+
23+
import android.os.Bundle
24+
import android.view.LayoutInflater
25+
import android.view.View
26+
import android.view.ViewGroup
27+
import androidx.fragment.app.Fragment
28+
import com.owncloud.android.R
29+
import com.owncloud.android.databinding.AddMemberFragmentBinding
30+
31+
class AddMemberFragment: Fragment() {
32+
private var _binding: AddMemberFragmentBinding? = null
33+
private val binding get() = _binding!!
34+
35+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
36+
_binding = AddMemberFragmentBinding.inflate(inflater, container, false)
37+
return binding.root
38+
}
39+
40+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
41+
super.onViewCreated(view, savedInstanceState)
42+
binding.searchBar.requestFocus()
43+
}
44+
45+
override fun onActivityCreated(savedInstanceState: Bundle?) {
46+
super.onActivityCreated(savedInstanceState)
47+
requireActivity().setTitle(R.string.add_member)
48+
}
49+
50+
companion object {
51+
fun newInstance(): AddMemberFragment {
52+
return AddMemberFragment()
53+
}
54+
}
55+
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.owncloud.android.domain.spaces.model.OCSpace
3030
import com.owncloud.android.ui.activity.FileActivity
3131
import com.owncloud.android.utils.DisplayUtils
3232

33-
class SpaceMembersActivity: FileActivity() {
33+
class SpaceMembersActivity: FileActivity(), SpaceMembersFragment.SpaceMemberFragmentListener {
3434

3535
private lateinit var binding: MembersActivityBinding
3636

@@ -80,8 +80,17 @@ class SpaceMembersActivity: FileActivity() {
8080
super.onOptionsItemSelected(item)
8181
}
8282

83+
override fun addMember(space: OCSpace) {
84+
supportFragmentManager.transaction {
85+
val fragment = AddMemberFragment.newInstance()
86+
replace(R.id.members_fragment_container, fragment, TAG_ADD_MEMBER_FRAGMENT)
87+
addToBackStack(null)
88+
}
89+
}
90+
8391
companion object {
8492
private const val TAG_SPACE_MEMBERS_FRAGMENT = "SPACE_MEMBERS_FRAGMENT"
93+
private const val TAG_ADD_MEMBER_FRAGMENT ="ADD_MEMBER_FRAGMENT"
8594
const val EXTRA_SPACE = "EXTRA_SPACE"
8695
}
8796

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@
2020

2121
package com.owncloud.android.presentation.spaces.members
2222

23+
import android.content.Context
2324
import android.os.Bundle
2425
import android.view.LayoutInflater
2526
import android.view.View
2627
import android.view.ViewGroup
2728
import androidx.fragment.app.Fragment
2829
import androidx.recyclerview.widget.LinearLayoutManager
2930
import androidx.recyclerview.widget.RecyclerView
31+
import com.owncloud.android.R
3032
import com.owncloud.android.databinding.MembersFragmentBinding
3133
import com.owncloud.android.domain.roles.model.OCRole
3234
import com.owncloud.android.domain.spaces.model.OCSpace
3335
import com.owncloud.android.extensions.collectLatestLifecycleFlow
3436
import com.owncloud.android.presentation.common.UIResult
3537
import org.koin.androidx.viewmodel.ext.android.viewModel
3638
import org.koin.core.parameter.parametersOf
39+
import timber.log.Timber
3740

3841
class SpaceMembersFragment : Fragment() {
3942
private var _binding: MembersFragmentBinding? = null
@@ -50,6 +53,7 @@ class SpaceMembersFragment : Fragment() {
5053
private lateinit var recyclerView: RecyclerView
5154

5255
private var roles: List<OCRole> = emptyList()
56+
private var listener: SpaceMemberFragmentListener? = null
5357

5458
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
5559
_binding = MembersFragmentBinding.inflate(inflater, container, false)
@@ -107,6 +111,30 @@ class SpaceMembersFragment : Fragment() {
107111
}
108112
}
109113
}
114+
115+
val currentSpace = requireArguments().getParcelable<OCSpace>(ARG_CURRENT_SPACE) ?: return
116+
binding.addMemberButton.setOnClickListener {
117+
listener?.addMember(currentSpace)
118+
}
119+
}
120+
121+
override fun onActivityCreated(savedInstanceState: Bundle?) {
122+
super.onActivityCreated(savedInstanceState)
123+
requireActivity().setTitle(R.string.space_members_label)
124+
}
125+
126+
override fun onAttach(context: Context) {
127+
super.onAttach(context)
128+
try {
129+
listener = context as SpaceMemberFragmentListener?
130+
} catch (e: ClassCastException) {
131+
Timber.e(e, "The activity attached does not implement SpaceMemberFragmentListener")
132+
throw ClassCastException(activity.toString() + " must implement SpaceMemberFragmentListener")
133+
}
134+
}
135+
136+
interface SpaceMemberFragmentListener {
137+
fun addMember(space: OCSpace)
110138
}
111139

112140
companion object {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
ownCloud Android client application
3+
4+
Copyright (C) 2026 ownCloud GmbH.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License version 2,
8+
as published by the Free Software Foundation.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
-->
18+
19+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
20+
xmlns:tools="http://schemas.android.com/tools"
21+
xmlns:app="http://schemas.android.com/apk/res-auto"
22+
android:id="@+id/shareScroll"
23+
android:layout_width="match_parent"
24+
android:layout_height="match_parent">
25+
26+
<LinearLayout
27+
android:id="@+id/search_member_layout"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"
30+
android:layout_margin="@dimen/standard_half_margin"
31+
android:minWidth="@dimen/share_user_groups_width"
32+
android:orientation="vertical">
33+
34+
<androidx.appcompat.widget.SearchView
35+
android:id="@+id/search_bar"
36+
android:layout_width="match_parent"
37+
android:layout_height="wrap_content"
38+
app:queryHint="@string/search_users_and_groups_hint"
39+
app:iconifiedByDefault="false"/>
40+
41+
<androidx.recyclerview.widget.RecyclerView
42+
android:id="@+id/members_recycler_view"
43+
android:layout_width="match_parent"
44+
android:layout_height="0dp"
45+
android:layout_weight="1"
46+
android:scrollbars="vertical"
47+
android:visibility="visible" />
48+
49+
</LinearLayout>
50+
51+
</ScrollView>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@
878878
<string name="delete_space_failed">Space could not be deleted</string>
879879
<string name="set_space_icon">Set icon</string>
880880
<string name="space_members">Members</string>
881+
<string name="add_member">Add member</string>
881882

882883
<string name="feedback_dialog_get_in_contact_description"><![CDATA[ Ask for help in our <a href=\"%1$s\"><b>forum</b></a> or contribute in our <a href=\"%2$s\"><b>GitHub repo</b></a>]]></string>
883884

0 commit comments

Comments
 (0)