Improved chat rooms list while forward is pending

This commit is contained in:
Sylvain Berfini 2021-05-21 11:59:56 +02:00
parent 7d1f9b6d5a
commit f774c535ab
4 changed files with 42 additions and 0 deletions

View file

@ -171,6 +171,13 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
listSelectionViewModel.isEditionEnabled.value = true listSelectionViewModel.isEditionEnabled.value = true
} }
binding.setCancelForwardClickListener {
sharedViewModel.messageToForwardEvent.value?.consume {
Log.i("[Chat] Cancelling message forward")
}
listViewModel.forwardPending.value = false
}
binding.setNewOneToOneChatRoomClickListener { binding.setNewOneToOneChatRoomClickListener {
sharedViewModel.chatRoomParticipants.value = arrayListOf() sharedViewModel.chatRoomParticipants.value = arrayListOf()
navigateToChatRoomCreation(false) navigateToChatRoomCreation(false)
@ -221,9 +228,12 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
sharedViewModel.messageToForwardEvent.observe(viewLifecycleOwner, { sharedViewModel.messageToForwardEvent.observe(viewLifecycleOwner, {
if (!it.consumed()) { if (!it.consumed()) {
Log.i("[Chat] Found chat message to transfer") Log.i("[Chat] Found chat message to transfer")
listViewModel.forwardPending.value = true
val activity = requireActivity() as MainActivity val activity = requireActivity() as MainActivity
activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing) activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
} else {
listViewModel.forwardPending.value = false
} }
}) })

View file

@ -39,6 +39,8 @@ class ChatRoomsListViewModel : ErrorReportingViewModel() {
MutableLiveData<Event<Boolean>>() MutableLiveData<Event<Boolean>>()
} }
val forwardPending = MutableLiveData<Boolean>()
val groupChatAvailable: Boolean = LinphoneUtils.isGroupChatAvailable() val groupChatAvailable: Boolean = LinphoneUtils.isGroupChatAvailable()
private val contactsUpdatedListener = object : ContactsUpdatedListenerStub() { private val contactsUpdatedListener = object : ContactsUpdatedListenerStub() {

View file

@ -14,6 +14,9 @@
<variable <variable
name="editClickListener" name="editClickListener"
type="android.view.View.OnClickListener"/> type="android.view.View.OnClickListener"/>
<variable
name="cancelForwardClickListener"
type="android.view.View.OnClickListener" />
<variable <variable
name="viewModel" name="viewModel"
type="org.linphone.activities.main.chat.viewmodels.ChatRoomsListViewModel" /> type="org.linphone.activities.main.chat.viewmodels.ChatRoomsListViewModel" />
@ -40,6 +43,17 @@
android:background="?attr/lightToolbarBackgroundColor" android:background="?attr/lightToolbarBackgroundColor"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView
android:onClick="@{cancelForwardClickListener}"
android:visibility="@{viewModel.forwardPending ? View.VISIBLE : View.GONE}"
android:contentDescription="@string/content_description_cancel_contact_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="?attr/button_background_drawable"
android:padding="15dp"
android:src="@drawable/cancel_edit" />
<ImageView <ImageView
android:onClick="@{newOneToOneChatRoomClickListener}" android:onClick="@{newOneToOneChatRoomClickListener}"
android:contentDescription="@string/content_description_create_one_to_one_chat_room" android:contentDescription="@string/content_description_create_one_to_one_chat_room"
@ -69,6 +83,7 @@
<ImageView <ImageView
android:onClick="@{editClickListener}" android:onClick="@{editClickListener}"
android:enabled="@{!viewModel.chatRooms.empty}" android:enabled="@{!viewModel.chatRooms.empty}"
android:visibility="@{viewModel.forwardPending ? View.GONE : View.VISIBLE}"
android:contentDescription="@string/content_description_enter_edition_mode" android:contentDescription="@string/content_description_enter_edition_mode"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -13,6 +13,9 @@
<variable <variable
name="editClickListener" name="editClickListener"
type="android.view.View.OnClickListener"/> type="android.view.View.OnClickListener"/>
<variable
name="cancelForwardClickListener"
type="android.view.View.OnClickListener" />
<variable <variable
name="viewModel" name="viewModel"
type="org.linphone.activities.main.chat.viewmodels.ChatRoomsListViewModel" /> type="org.linphone.activities.main.chat.viewmodels.ChatRoomsListViewModel" />
@ -29,6 +32,17 @@
android:background="?attr/lightToolbarBackgroundColor" android:background="?attr/lightToolbarBackgroundColor"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView
android:onClick="@{cancelForwardClickListener}"
android:visibility="@{viewModel.forwardPending ? View.VISIBLE : View.GONE}"
android:contentDescription="@string/content_description_cancel_contact_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="?attr/button_background_drawable"
android:padding="15dp"
android:src="@drawable/cancel_edit" />
<ImageView <ImageView
android:onClick="@{newOneToOneChatRoomClickListener}" android:onClick="@{newOneToOneChatRoomClickListener}"
android:contentDescription="@string/content_description_create_one_to_one_chat_room" android:contentDescription="@string/content_description_create_one_to_one_chat_room"
@ -58,6 +72,7 @@
<ImageView <ImageView
android:onClick="@{editClickListener}" android:onClick="@{editClickListener}"
android:enabled="@{!viewModel.chatRooms.empty}" android:enabled="@{!viewModel.chatRooms.empty}"
android:visibility="@{viewModel.forwardPending ? View.GONE : View.VISIBLE}"
android:contentDescription="@string/content_description_enter_edition_mode" android:contentDescription="@string/content_description_enter_edition_mode"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"