mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
fabs are moved from HomeRoomListFragment to NewHomeDetailFragment (#6943)
This commit is contained in:
parent
8168420877
commit
14e3753183
5 changed files with 82 additions and 100 deletions
1
changelog.d/6765.wip
Normal file
1
changelog.d/6765.wip
Normal file
|
@ -0,0 +1 @@
|
|||
[App Layout] Fabs doesn't go off screen anymore
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -101,4 +101,40 @@
|
|||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutOpenSpacesButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
|
||||
android:contentDescription="@string/a11y_open_spaces"
|
||||
android:src="@drawable/ic_open_spaces"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="?attr/vctr_toolbar_background"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
|
||||
app:tint="?attr/colorPrimary"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutCreateChatButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:accessibilityTraversalBefore="@id/roomListView"
|
||||
android:contentDescription="@string/a11y_create_message"
|
||||
android:src="@drawable/ic_new_chat"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -59,49 +59,6 @@
|
|||
tools:layout_marginEnd="144dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="bottom|end">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutOpenSpacesButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
|
||||
android:contentDescription="@string/a11y_open_spaces"
|
||||
android:src="@drawable/ic_open_spaces"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="?attr/vctr_toolbar_background"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
|
||||
app:tint="?attr/colorPrimary"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutCreateChatButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:accessibilityTraversalBefore="@id/roomListView"
|
||||
android:contentDescription="@string/a11y_create_message"
|
||||
android:src="@drawable/ic_new_chat"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</im.vector.app.core.platform.StateView>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
Loading…
Reference in a new issue