From 14e375318323200f4ed64a1594d0b4494110bb3b Mon Sep 17 00:00:00 2001 From: Nikita Fedrunov <66663241+fedrunov@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:26:39 +0200 Subject: [PATCH] fabs are moved from HomeRoomListFragment to NewHomeDetailFragment (#6943) --- changelog.d/6765.wip | 1 + .../features/home/NewHomeDetailFragment.kt | 45 +++++++++++++++ .../room/list/home/HomeRoomListFragment.kt | 57 ------------------- .../res/layout/fragment_new_home_detail.xml | 36 ++++++++++++ .../main/res/layout/fragment_room_list.xml | 43 -------------- 5 files changed, 82 insertions(+), 100 deletions(-) create mode 100644 changelog.d/6765.wip diff --git a/changelog.d/6765.wip b/changelog.d/6765.wip new file mode 100644 index 0000000000..ccdc1c025f --- /dev/null +++ b/changelog.d/6765.wip @@ -0,0 +1 @@ +[App Layout] Fabs doesn't go off screen anymore diff --git a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt index 9dcf6d0922..f47da1e6a0 100644 --- a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt @@ -47,14 +47,20 @@ import im.vector.app.features.call.SharedKnownCallsViewModel import im.vector.app.features.call.VectorCallActivity import im.vector.app.features.call.dialpad.PstnDialActivity import im.vector.app.features.call.webrtc.WebRtcCallManager +import im.vector.app.features.home.room.list.actions.RoomListSharedAction +import im.vector.app.features.home.room.list.actions.RoomListSharedActionViewModel import im.vector.app.features.home.room.list.home.HomeRoomListFragment +import im.vector.app.features.home.room.list.home.NewChatBottomSheet import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.popup.VerificationVectorAlert import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.VectorSettingsActivity.Companion.EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY_MANAGE_SESSIONS +import im.vector.app.features.spaces.SpaceListBottomSheet import im.vector.app.features.workers.signout.BannerState import im.vector.app.features.workers.signout.ServerBackupStatusViewModel import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo @@ -84,8 +90,12 @@ class NewHomeDetailFragment : private val serverBackupStatusViewModel: ServerBackupStatusViewModel by activityViewModel() private lateinit var sharedActionViewModel: HomeSharedActionViewModel + private lateinit var sharedRoomListActionViewModel: RoomListSharedActionViewModel private lateinit var sharedCallActionViewModel: SharedKnownCallsViewModel + private val newChatBottomSheet = NewChatBottomSheet() + private val spaceListBottomSheet = SpaceListBottomSheet() + private var hasUnreadRooms = false set(value) { if (value != field) { @@ -132,6 +142,8 @@ class NewHomeDetailFragment : setupKeysBackupBanner() setupActiveCallView() setupDebugButton() + setupFabs() + setupObservers() childFragmentManager.commitTransaction { add(R.id.roomListContainer, HomeRoomListFragment::class.java, null, HOME_ROOM_LIST_FRAGMENT_TAG) @@ -174,6 +186,39 @@ class NewHomeDetailFragment : } } + private fun setupObservers() { + sharedRoomListActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java] + + sharedRoomListActionViewModel + .stream() + .onEach(::handleSharedAction) + .launchIn(viewLifecycleOwner.lifecycleScope) + } + + private fun handleSharedAction(action: RoomListSharedAction) { + when (action) { + RoomListSharedAction.CloseBottomSheet -> spaceListBottomSheet.dismiss() + } + } + + private fun setupFabs() { + showFABs() + + views.newLayoutCreateChatButton.setOnClickListener { + newChatBottomSheet.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG) + } + + views.newLayoutOpenSpacesButton.setOnClickListener { + // Click action for open spaces modal goes here + spaceListBottomSheet.show(requireActivity().supportFragmentManager, SpaceListBottomSheet.TAG) + } + } + + private fun showFABs() { + views.newLayoutCreateChatButton.show() + views.newLayoutOpenSpacesButton.show() + } + private fun setCurrentSpace(spaceId: String?) { spaceStateHandler.setCurrentSpace(spaceId, isForwardNavigation = false) sharedActionViewModel.post(HomeActivitySharedAction.OnCloseSpace) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index 3e8c2b5dcd..32635e3407 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -45,14 +45,11 @@ import im.vector.app.features.home.room.list.RoomSummaryItemFactory import im.vector.app.features.home.room.list.actions.RoomListQuickActionsBottomSheet import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedAction import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel -import im.vector.app.features.home.room.list.actions.RoomListSharedAction -import im.vector.app.features.home.room.list.actions.RoomListSharedActionViewModel import im.vector.app.features.home.room.list.home.filter.HomeFilteredRoomsController import im.vector.app.features.home.room.list.home.filter.HomeRoomFilter import im.vector.app.features.home.room.list.home.invites.InvitesActivity import im.vector.app.features.home.room.list.home.invites.InvitesCounterController import im.vector.app.features.home.room.list.home.recent.RecentRoomCarouselController -import im.vector.app.features.spaces.SpaceListBottomSheet import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.matrix.android.sdk.api.session.room.model.RoomSummary @@ -73,16 +70,11 @@ class HomeRoomListFragment : private val roomListViewModel: HomeRoomListViewModel by fragmentViewModel() private lateinit var sharedQuickActionsViewModel: RoomListQuickActionsSharedActionViewModel - private lateinit var sharedActionViewModel: RoomListSharedActionViewModel private var concatAdapter = ConcatAdapter() private var modelBuildListener: OnModelBuildFinishedListener? = null - private val spaceListBottomSheet = SpaceListBottomSheet() - private lateinit var stateRestorer: LayoutManagerStateRestorer - private val newChatBottomSheet = NewChatBottomSheet() - override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding { return FragmentRoomListBinding.inflate(inflater, container, false) } @@ -93,17 +85,10 @@ class HomeRoomListFragment : views.stateView.state = StateView.State.Loading setupObservers() setupRecyclerView() - setupFabs() } private fun setupObservers() { sharedQuickActionsViewModel = activityViewModelProvider[RoomListQuickActionsSharedActionViewModel::class.java] - sharedActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java] - - sharedActionViewModel - .stream() - .onEach(::handleSharedAction) - .launchIn(viewLifecycleOwner.lifecycleScope) sharedQuickActionsViewModel .stream() .onEach(::handleQuickActions) @@ -119,12 +104,6 @@ class HomeRoomListFragment : } } - private fun handleSharedAction(action: RoomListSharedAction) { - when (action) { - RoomListSharedAction.CloseBottomSheet -> spaceListBottomSheet.dismiss() - } - } - private fun handleQuickActions(quickAction: RoomListQuickActionsSharedAction) { when (quickAction) { is RoomListQuickActionsSharedAction.NotificationsAllNoisy -> { @@ -180,42 +159,6 @@ class HomeRoomListFragment : }) } - private fun setupFabs() { - showFABs() - - views.newLayoutCreateChatButton.setOnClickListener { - newChatBottomSheet.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG) - } - - views.newLayoutOpenSpacesButton.setOnClickListener { - // Click action for open spaces modal goes here - spaceListBottomSheet.show(requireActivity().supportFragmentManager, SpaceListBottomSheet.TAG) - } - - // Hide FABs when list is scrolling - views.roomListView.addOnScrollListener(object : RecyclerView.OnScrollListener() { - override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { - views.createChatFabMenu.handler.removeCallbacksAndMessages(null) - - when (newState) { - RecyclerView.SCROLL_STATE_IDLE -> views.createChatFabMenu.postDelayed(::showFABs, 250) - RecyclerView.SCROLL_STATE_DRAGGING, - RecyclerView.SCROLL_STATE_SETTLING -> hideFABs() - } - } - }) - } - - private fun showFABs() { - views.newLayoutCreateChatButton.show() - views.newLayoutOpenSpacesButton.show() - } - - private fun hideFABs() { - views.newLayoutCreateChatButton.hide() - views.newLayoutOpenSpacesButton.hide() - } - override fun invalidate() = withState(roomListViewModel) { state -> views.stateView.state = state.state } diff --git a/vector/src/main/res/layout/fragment_new_home_detail.xml b/vector/src/main/res/layout/fragment_new_home_detail.xml index 57ba666be7..82bc6bb36e 100644 --- a/vector/src/main/res/layout/fragment_new_home_detail.xml +++ b/vector/src/main/res/layout/fragment_new_home_detail.xml @@ -101,4 +101,40 @@ + + + + + diff --git a/vector/src/main/res/layout/fragment_room_list.xml b/vector/src/main/res/layout/fragment_room_list.xml index 4b6f8f5895..19310bdf67 100644 --- a/vector/src/main/res/layout/fragment_room_list.xml +++ b/vector/src/main/res/layout/fragment_room_list.xml @@ -59,49 +59,6 @@ tools:layout_marginEnd="144dp" tools:visibility="visible" /> - - - - - - - - -