diff --git a/CHANGES.md b/CHANGES.md
index 05d189ed12..187d9ad8f4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -16,6 +16,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)
Bugfix 🐛:
- Improve support for image/audio/video/file selection with intent changes (#1376)
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..f38877ca6b 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)
+ // 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()
+ }
+ }
+ }
+ }
+ )
viewModel.selectSubscribe(this, RoomMemberListViewState::actionsPermissions) {
invalidateOptionsMenu()
}
}
+ private fun setupInviteUsersButton() {
+ inviteUsersButton.debouncedClicks {
+ navigator.openInviteUsersToRoom(requireContext(), roomProfileArgs.roomId)
+ }
+ }
+
private fun setupSearchView() {
searchViewAppBarLayout.isVisible = true
searchView.queryHint = getString(R.string.search_members_hint)
@@ -131,5 +137,6 @@ class RoomMemberListFragment @Inject constructor(
roomSettingsToolbarTitleView.text = it.displayName
avatarRenderer.render(it.toMatrixItem(), roomSettingsToolbarAvatarImageView)
}
+ inviteUsersButton.isVisible = state.actionsPermissions.canInvite
}
}
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 @@
+