mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-30 10:54:58 +01:00
Merge pull request #3636 from vector-im/feature/bma/cleanup_interface
Decorelate interfaces for code clarity
This commit is contained in:
commit
5bbb45de68
@ -23,13 +23,12 @@ import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.features.home.room.list.widget.NotifsFabMenuView
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_room_filter_footer)
|
||||
abstract class FilteredRoomFooterItem : VectorEpoxyModel<FilteredRoomFooterItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute
|
||||
var listener: FilteredRoomFooterItemListener? = null
|
||||
var listener: Listener? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var currentFilter: String = ""
|
||||
@ -47,7 +46,9 @@ abstract class FilteredRoomFooterItem : VectorEpoxyModel<FilteredRoomFooterItem.
|
||||
val openRoomDirectory by bind<Button>(R.id.roomFilterFooterOpenRoomDirectory)
|
||||
}
|
||||
|
||||
interface FilteredRoomFooterItemListener : NotifsFabMenuView.Listener {
|
||||
interface Listener {
|
||||
fun createRoom(initialName: String)
|
||||
fun createDirectChat()
|
||||
fun openRoomDirectory(initialFilter: String)
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import im.vector.app.core.epoxy.helpFooterItem
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.resources.UserPreferencesProvider
|
||||
import im.vector.app.features.home.RoomListDisplayMode
|
||||
import im.vector.app.features.home.room.filtered.FilteredRoomFooterItem
|
||||
import im.vector.app.features.home.room.filtered.filteredRoomFooterItem
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -30,7 +31,7 @@ class RoomListFooterController @Inject constructor(
|
||||
private val userPreferencesProvider: UserPreferencesProvider
|
||||
) : TypedEpoxyController<RoomListViewState>() {
|
||||
|
||||
var listener: RoomListListener? = null
|
||||
var listener: FilteredRoomFooterItem.Listener? = null
|
||||
|
||||
override fun buildModels(data: RoomListViewState?) {
|
||||
val host = this
|
||||
|
@ -42,6 +42,7 @@ import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.core.resources.UserPreferencesProvider
|
||||
import im.vector.app.databinding.FragmentRoomListBinding
|
||||
import im.vector.app.features.home.RoomListDisplayMode
|
||||
import im.vector.app.features.home.room.filtered.FilteredRoomFooterItem
|
||||
import im.vector.app.features.home.room.list.actions.RoomListActionsArgs
|
||||
import im.vector.app.features.home.room.list.actions.RoomListQuickActionsBottomSheet
|
||||
import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedAction
|
||||
@ -70,6 +71,7 @@ class RoomListFragment @Inject constructor(
|
||||
) : VectorBaseFragment<FragmentRoomListBinding>(),
|
||||
RoomListListener,
|
||||
OnBackPressed,
|
||||
FilteredRoomFooterItem.Listener,
|
||||
NotifsFabMenuView.Listener {
|
||||
|
||||
private var modelBuildListener: OnModelBuildFinishedListener? = null
|
||||
@ -178,16 +180,16 @@ class RoomListFragment @Inject constructor(
|
||||
private fun setupCreateRoomButton() {
|
||||
when (roomListParams.displayMode) {
|
||||
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true
|
||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true
|
||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true
|
||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true
|
||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true
|
||||
else -> Unit // No button in this mode
|
||||
}
|
||||
|
||||
views.createChatRoomButton.debouncedClicks {
|
||||
createDirectChat()
|
||||
fabCreateDirectChat()
|
||||
}
|
||||
views.createGroupRoomButton.debouncedClicks {
|
||||
openRoomDirectory()
|
||||
fabOpenRoomDirectory()
|
||||
}
|
||||
|
||||
// Hide FAB when list is scrolling
|
||||
@ -221,14 +223,28 @@ class RoomListFragment @Inject constructor(
|
||||
roomListViewModel.handle(RoomListAction.FilterWith(filter))
|
||||
}
|
||||
|
||||
override fun openRoomDirectory(initialFilter: String) {
|
||||
navigator.openRoomDirectory(requireActivity(), initialFilter)
|
||||
// FilteredRoomFooterItem.Listener
|
||||
override fun createRoom(initialName: String) {
|
||||
navigator.openCreateRoom(requireActivity(), initialName)
|
||||
}
|
||||
|
||||
override fun createDirectChat() {
|
||||
navigator.openCreateDirectRoom(requireActivity())
|
||||
}
|
||||
|
||||
override fun openRoomDirectory(initialFilter: String) {
|
||||
navigator.openRoomDirectory(requireActivity(), initialFilter)
|
||||
}
|
||||
|
||||
// NotifsFabMenuView.Listener
|
||||
override fun fabCreateDirectChat() {
|
||||
navigator.openCreateDirectRoom(requireActivity())
|
||||
}
|
||||
|
||||
override fun fabOpenRoomDirectory() {
|
||||
navigator.openRoomDirectory(requireActivity(), "")
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
val layoutManager = LinearLayoutManager(context)
|
||||
stateRestorer = LayoutManagerStateRestorer(layoutManager).register()
|
||||
@ -339,8 +355,8 @@ class RoomListFragment @Inject constructor(
|
||||
if (isAdded) {
|
||||
when (roomListParams.displayMode) {
|
||||
RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.show()
|
||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show()
|
||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show()
|
||||
RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show()
|
||||
RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show()
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
@ -409,14 +425,14 @@ class RoomListFragment @Inject constructor(
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper),
|
||||
message = getString(R.string.room_list_catchup_empty_body))
|
||||
}
|
||||
RoomListDisplayMode.PEOPLE ->
|
||||
RoomListDisplayMode.PEOPLE ->
|
||||
StateView.State.Empty(
|
||||
title = getString(R.string.room_list_people_empty_title),
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_dm),
|
||||
isBigImage = true,
|
||||
message = getString(R.string.room_list_people_empty_body)
|
||||
)
|
||||
RoomListDisplayMode.ROOMS ->
|
||||
RoomListDisplayMode.ROOMS ->
|
||||
StateView.State.Empty(
|
||||
title = getString(R.string.room_list_rooms_empty_title),
|
||||
image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_room),
|
||||
@ -480,8 +496,4 @@ class RoomListFragment @Inject constructor(
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(room.roomId)
|
||||
roomListViewModel.handle(RoomListAction.RejectInvitation(room))
|
||||
}
|
||||
|
||||
override fun createRoom(initialName: String) {
|
||||
navigator.openCreateRoom(requireActivity(), initialName)
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,10 @@
|
||||
|
||||
package im.vector.app.features.home.room.list
|
||||
|
||||
import im.vector.app.features.home.room.filtered.FilteredRoomFooterItem
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
||||
|
||||
interface RoomListListener : FilteredRoomFooterItem.FilteredRoomFooterItemListener {
|
||||
interface RoomListListener {
|
||||
fun onRoomClicked(room: RoomSummary)
|
||||
fun onRoomLongClicked(room: RoomSummary): Boolean
|
||||
fun onRejectRoomInvitation(room: RoomSummary)
|
||||
|
@ -43,14 +43,14 @@ class NotifsFabMenuView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
.forEach {
|
||||
it.setOnClickListener {
|
||||
closeFabMenu()
|
||||
listener?.createDirectChat()
|
||||
listener?.fabCreateDirectChat()
|
||||
}
|
||||
}
|
||||
listOf(views.createRoomItemGroup, views.createRoomItemGroupLabel)
|
||||
.forEach {
|
||||
it.setOnClickListener {
|
||||
closeFabMenu()
|
||||
listener?.openRoomDirectory()
|
||||
listener?.fabOpenRoomDirectory()
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ class NotifsFabMenuView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun createDirectChat()
|
||||
fun openRoomDirectory(initialFilter: String = "")
|
||||
fun fabCreateDirectChat()
|
||||
fun fabOpenRoomDirectory()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user