diff --git a/CHANGES.md b/CHANGES.md
index 257837dc6a..534194c2a9 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -17,6 +17,7 @@ Improvements 🙌:
- Drawer: move settings access and add sign out action (#2171)
- Filter room member (and banned users) by name (#2184)
- Implement "Jump to read receipt" and "Mention" actions on the room member profile screen
+ - Add FAB to room members list (#2226)
- Add Sygnal API implementation to test is Push are correctly received
- Add PushGateway API implementation to test if Push are correctly received
- Cross signing: shouldn't offer to verify with other session when there is not. (#2227)
diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt
index 67577e866e..77337d7208 100644
--- a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt
@@ -17,12 +17,11 @@
package im.vector.app.features.roomprofile.members
import android.os.Bundle
-import android.view.Menu
-import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.SearchView
import androidx.core.view.isVisible
+import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
@@ -37,6 +36,7 @@ import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.roomprofile.RoomProfileArgs
+import kotlinx.android.synthetic.main.fragment_room_member_list.*
import kotlinx.android.synthetic.main.fragment_room_setting_generic.*
import javax.inject.Inject
@@ -49,38 +49,44 @@ class RoomMemberListFragment @Inject constructor(
private val viewModel: RoomMemberListViewModel by fragmentViewModel()
private val roomProfileArgs: RoomProfileArgs by args()
- override fun getLayoutResId() = R.layout.fragment_room_setting_generic
-
- override fun getMenuRes() = R.menu.menu_room_member_list
-
- override fun onPrepareOptionsMenu(menu: Menu) {
- val canInvite = withState(viewModel) {
- it.actionsPermissions.canInvite
- }
- menu.findItem(R.id.menu_room_member_list_add_member).isVisible = canInvite
- }
-
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- when (item.itemId) {
- R.id.menu_room_member_list_add_member -> {
- navigator.openInviteUsersToRoom(requireContext(), roomProfileArgs.roomId)
- return true
- }
- }
- return super.onOptionsItemSelected(item)
- }
+ override fun getLayoutResId() = R.layout.fragment_room_member_list
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
roomMemberListController.callback = this
setupToolbar(roomSettingsToolbar)
setupSearchView()
+ setupInviteUsersButton()
recyclerView.configureWith(roomMemberListController, hasFixedSize = true)
viewModel.selectSubscribe(this, RoomMemberListViewState::actionsPermissions) {
invalidateOptionsMenu()
}
}
+ private fun setupInviteUsersButton() {
+ inviteUsersButton.debouncedClicks {
+ navigator.openInviteUsersToRoom(requireContext(), roomProfileArgs.roomId)
+ }
+ // Hide FAB when list is scrolling
+ recyclerView.addOnScrollListener(
+ object : RecyclerView.OnScrollListener() {
+ override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
+ when (newState) {
+ RecyclerView.SCROLL_STATE_IDLE -> {
+ if (withState(viewModel) { it.actionsPermissions.canInvite }) {
+ inviteUsersButton.show()
+ }
+ }
+ RecyclerView.SCROLL_STATE_DRAGGING,
+ RecyclerView.SCROLL_STATE_SETTLING -> {
+ inviteUsersButton.hide()
+ }
+ }
+ }
+ }
+ )
+ }
+
private fun setupSearchView() {
searchViewAppBarLayout.isVisible = true
searchView.queryHint = getString(R.string.search_members_hint)
@@ -104,6 +110,7 @@ class RoomMemberListFragment @Inject constructor(
override fun invalidate() = withState(viewModel) { viewState ->
roomMemberListController.setData(viewState)
renderRoomSummary(viewState)
+ inviteUsersButton.isVisible = viewState.actionsPermissions.canInvite
}
override fun onRoomMemberClicked(roomMember: RoomMemberSummary) {
diff --git a/vector/src/main/res/drawable/ic_fab_add_members.xml b/vector/src/main/res/drawable/ic_fab_add_members.xml
new file mode 100644
index 0000000000..50768871ab
--- /dev/null
+++ b/vector/src/main/res/drawable/ic_fab_add_members.xml
@@ -0,0 +1,30 @@
+