diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt index 7f538a967..127e8652c 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationInfoFragment.kt @@ -205,6 +205,31 @@ class ConversationInfoFragment : GenericFragment() { dialog.show() } + binding.setGoToContactClickListener { + val refKey = viewModel.oneToOneParticipantRefKey.value + Log.i("$TAG Trying to display participant [$refKey] contact page") + if (!refKey.isNullOrEmpty()) { + sharedViewModel.navigateToContactsEvent.value = Event(true) + sharedViewModel.showContactEvent.value = Event(refKey) + } else { + Log.e("$TAG Can't go to contact page, friend ref key is null or empty!") + // TODO: show toast + } + } + + binding.setAddToContactsClickListener { + val sipUri = viewModel.sipUri.value + if (!sipUri.isNullOrEmpty()) { + Log.i("$TAG Trying to add participant [$sipUri] to contacts") + sharedViewModel.sipAddressToAddToNewContact = sipUri + sharedViewModel.navigateToContactsEvent.value = Event(true) + sharedViewModel.showNewContactEvent.value = Event(true) + } else { + Log.e("$TAG Can't add empty/null SIP URI to contacts!") + // TODO: show toast + } + } + binding.setConfigureEphemeralMessagesClickListener { val currentValue = viewModel.ephemeralLifetime.value ?: 0L if (findNavController().currentDestination?.id == R.id.conversationInfoFragment) { @@ -241,25 +266,25 @@ class ConversationInfoFragment : GenericFragment() { popupView.isParticipantContact = !friendRefKey.isNullOrEmpty() popupView.setRemoveParticipantClickListener { - Log.w("$TAG Trying to remove participant [$address]") + Log.i("$TAG Trying to remove participant [$address]") viewModel.removeParticipant(participantModel) popupWindow.dismiss() } popupView.setSetAdminClickListener { - Log.w("$TAG Trying to give admin rights to participant [$address]") + Log.i("$TAG Trying to give admin rights to participant [$address]") viewModel.giveAdminRightsTo(participantModel) popupWindow.dismiss() } popupView.setUnsetAdminClickListener { - Log.w("$TAG Trying to remove admin rights from participant [$address]") + Log.i("$TAG Trying to remove admin rights from participant [$address]") viewModel.removeAdminRightsFrom(participantModel) popupWindow.dismiss() } popupView.setSeeContactProfileClickListener { - Log.w("$TAG Trying to display participant [$address] contact page") + Log.i("$TAG Trying to display participant [$address] contact page") if (!friendRefKey.isNullOrEmpty()) { sharedViewModel.navigateToContactsEvent.value = Event(true) sharedViewModel.showContactEvent.value = Event(friendRefKey) @@ -271,7 +296,7 @@ class ConversationInfoFragment : GenericFragment() { } popupView.setAddToContactsClickListener { - Log.w("$TAG Trying to add participant [${participantModel.sipUri}] to contacts") + Log.i("$TAG Trying to add participant [${participantModel.sipUri}] to contacts") sharedViewModel.sipAddressToAddToNewContact = participantModel.sipUri sharedViewModel.navigateToContactsEvent.value = Event(true) sharedViewModel.showNewContactEvent.value = Event(true) diff --git a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationInfoViewModel.kt b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationInfoViewModel.kt index ca275d4a4..ed7a6d89d 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationInfoViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationInfoViewModel.kt @@ -64,6 +64,8 @@ class ConversationInfoViewModel @UiThread constructor() : ViewModel() { val chatRoomFoundEvent = MutableLiveData>() + val oneToOneParticipantRefKey = MutableLiveData() + val groupLeftEvent: MutableLiveData> by lazy { MutableLiveData>() } @@ -379,7 +381,14 @@ class ConversationInfoViewModel @UiThread constructor() : ViewModel() { } subject.postValue(chatRoom.subject) - sipUri.postValue(chatRoom.participants.firstOrNull()?.address?.asStringUriOnly()) + + val firstParticipant = chatRoom.participants.firstOrNull() + if (firstParticipant != null) { + val address = firstParticipant.address + sipUri.postValue(address.asStringUriOnly()) + val friend = coreContext.contactsManager.findContactByAddress(address) + oneToOneParticipantRefKey.postValue(friend?.refKey ?: "") + } ephemeralLifetime.postValue( if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime diff --git a/app/src/main/res/layout/chat_info_fragment.xml b/app/src/main/res/layout/chat_info_fragment.xml index 95e239165..9ceced9d9 100644 --- a/app/src/main/res/layout/chat_info_fragment.xml +++ b/app/src/main/res/layout/chat_info_fragment.xml @@ -18,6 +18,12 @@ + + @@ -60,25 +66,27 @@ android:id="@+id/scrollView" android:layout_width="0dp" android:layout_height="0dp" - android:fillViewport="true" android:background="@color/gray_100" - app:layout_constraintStart_toStartOf="parent" + android:fillViewport="true" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/invisible_title" - app:layout_constraintBottom_toBottomOf="parent"> + app:layout_constraintVertical_bias="0.0"> @@ -90,62 +98,60 @@ android:layout_marginEnd="@dimen/avatar_presence_badge_big_end_margin" android:background="@drawable/led_background" android:padding="@dimen/avatar_presence_badge_big_padding" - app:presenceIcon="@{viewModel.avatarModel.presenceStatus}" android:visibility="@{viewModel.avatarModel.presenceStatus == ConsolidatedPresence.Offline ? View.GONE : View.VISIBLE, default=gone}" + app:layout_constraintBottom_toBottomOf="@id/avatar" app:layout_constraintEnd_toEndOf="@id/avatar" - app:layout_constraintBottom_toBottomOf="@id/avatar"/> + app:presenceIcon="@{viewModel.avatarModel.presenceStatus}" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/avatar" /> + app:layout_constraintTop_toTopOf="@id/title" /> + app:layout_constraintTop_toBottomOf="@id/status" + app:tint="@color/gray_main2_500" /> + app:layout_constraintTop_toBottomOf="@id/mute" /> + app:layout_constraintStart_toEndOf="@id/mute" + app:layout_constraintTop_toBottomOf="@id/status" + app:tint="@color/gray_main2_500" /> + app:layout_constraintTop_toBottomOf="@id/call" /> + app:layout_constraintTop_toBottomOf="@id/status" + app:tint="@color/gray_main2_500" /> + app:layout_constraintTop_toBottomOf="@id/meeting" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/mute_label" /> + app:layout_constraintBottom_toBottomOf="@id/add_participants" + app:layout_constraintTop_toTopOf="@id/participants" /> + app:layout_constraintVertical_weight="1" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/participants" /> + app:layout_constraintVertical_bias="0" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/actions" /> + + + + + + + + - - - - + app:layout_constraintTop_toBottomOf="@id/action_add_to_contacts" /> + app:layout_constraintEnd_toEndOf="@id/action_ephemeral_messages" + app:layout_constraintStart_toStartOf="@id/action_ephemeral_messages" + app:layout_constraintTop_toBottomOf="@+id/action_ephemeral_messages" /> + + + + + app:layout_constraintTop_toBottomOf="@id/action_leave_group" + app:layout_constraintVertical_bias="0" />