mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Lookup for conference's chat room if any, and allow navigating to it if found
This commit is contained in:
parent
135ca527ee
commit
70b4a500d2
7 changed files with 108 additions and 7 deletions
|
|
@ -237,6 +237,24 @@ class ActiveConferenceCallFragment : GenericCallFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
callViewModel.conferenceModel.goToConversationEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
if (findNavController().currentDestination?.id == R.id.activeConferenceCallFragment) {
|
||||
val localSipUri = pair.first
|
||||
val remoteSipUri = pair.second
|
||||
Log.i(
|
||||
"$TAG Display conversation with local SIP URI [$localSipUri] and remote SIP URI [$remoteSipUri]"
|
||||
)
|
||||
val action =
|
||||
ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToInCallConversationFragment(
|
||||
localSipUri,
|
||||
remoteSipUri
|
||||
)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callViewModel.goToCallEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
if (findNavController().currentDestination?.id == R.id.activeConferenceCallFragment) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.linphone.core.Address
|
|||
import org.linphone.core.Call
|
||||
import org.linphone.core.Conference
|
||||
import org.linphone.core.ConferenceListenerStub
|
||||
import org.linphone.core.ConferenceParams
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.Participant
|
||||
import org.linphone.core.ParticipantDevice
|
||||
|
|
@ -73,6 +74,8 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() {
|
|||
|
||||
val isMeAdmin = MutableLiveData<Boolean>()
|
||||
|
||||
val isConversationAvailable = MutableLiveData<Boolean>()
|
||||
|
||||
val firstParticipantOtherThanOurselvesJoinedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -85,6 +88,10 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() {
|
|||
MutableLiveData<Event<Pair<String, Participant>>>()
|
||||
}
|
||||
|
||||
val goToConversationEvent: MutableLiveData<Event<Pair<String, String>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, String>>>()
|
||||
}
|
||||
|
||||
private lateinit var conference: Conference
|
||||
|
||||
private val conferenceListener = object : ConferenceListenerStub() {
|
||||
|
|
@ -248,6 +255,7 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() {
|
|||
|
||||
init {
|
||||
isPaused.value = false
|
||||
isConversationAvailable.value = false
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -282,6 +290,9 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() {
|
|||
val screenSharing = conference.screenSharingParticipant != null
|
||||
isScreenSharing.postValue(screenSharing)
|
||||
|
||||
val chatEnabled = conference.currentParams.isChatEnabled
|
||||
isConversationAvailable.postValue(chatEnabled)
|
||||
|
||||
val confSubject = conference.subject.orEmpty()
|
||||
Log.i(
|
||||
"$TAG Configuring conference with subject [$confSubject] from call [${call.callLog.callId}]"
|
||||
|
|
@ -307,6 +318,28 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun goToConversation() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
Log.i("$TAG Navigating to conference's conversation")
|
||||
val chatParams: ConferenceParams? = null
|
||||
val address = conference.conferenceAddress
|
||||
val chatRoom = core.searchChatRoom(chatParams, address, null, null)
|
||||
if (chatRoom != null) {
|
||||
goToConversationEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
chatRoom.localAddress.asStringUriOnly(),
|
||||
chatRoom.peerAddress.asStringUriOnly()
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
Log.e("$TAG Couldn't find chat room for address [${address?.asStringUriOnly()}]")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun showLayoutMenu() {
|
||||
showLayoutMenuEvent.value = Event(true)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.linphone.ui.call.fragment
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.chat.fragment.ConversationFragment
|
||||
|
||||
class ConversationFragment : ConversationFragment() {
|
||||
|
|
@ -32,6 +33,7 @@ class ConversationFragment : ConversationFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
Log.i("$TAG Creating an in-call ConversationFragment")
|
||||
sendMessageViewModel.isInCallConversation.value = true
|
||||
viewModel.isInCallConversation.value = true
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/gray_400" />
|
||||
<item android:state_enabled="false" android:color="@color/gray_500" />
|
||||
<item android:state_pressed="true" android:color="@color/white" />
|
||||
<item android:color="@color/white"/>
|
||||
</selector>
|
||||
|
|
|
|||
|
|
@ -120,19 +120,39 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:onClick="@{() -> viewModel.conferenceModel.goToConversation()}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/call_button_size"
|
||||
android:layout_marginTop="@dimen/call_extra_button_top_margin"
|
||||
android:padding="@dimen/call_button_icon_padding"
|
||||
android:src="@drawable/chat_teardrop_text"
|
||||
android:enabled="@{viewModel.conferenceModel.isConversationAvailable}"
|
||||
android:contentDescription="@string/call_action_show_messages"
|
||||
android:background="@drawable/shape_round_in_call_disabled_button_background"
|
||||
app:tint="?attr/color_grey_500"
|
||||
android:background="@drawable/in_call_button_background_red"
|
||||
app:tint="@color/in_call_button_tint_color"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintTop_toBottomOf="@id/main_actions"
|
||||
app:layout_constraintStart_toStartOf="@id/chat_label"
|
||||
app:layout_constraintEnd_toEndOf="@id/chat_label"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/unread_messages_count"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_red_round"
|
||||
android:text="@{String.valueOf(viewModel.unreadMessagesCount), default=`1`}"
|
||||
android:textColor="?attr/color_on_main"
|
||||
android:textSize="13sp"
|
||||
android:paddingBottom="2dp"
|
||||
android:visibility="@{viewModel.unreadMessagesCount > 0 ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toBottomOf="@id/main_actions"
|
||||
app:layout_constraintStart_toStartOf="@id/chat"
|
||||
app:layout_constraintEnd_toEndOf="@id/chat"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pause_call"
|
||||
android:onClick="@{() -> viewModel.togglePause()}"
|
||||
|
|
@ -219,11 +239,12 @@
|
|||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/in_call_extra_action_label_style"
|
||||
android:id="@+id/chat_label"
|
||||
android:onClick="@{() -> viewModel.conferenceModel.goToConversation()}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dp"
|
||||
android:text="@string/call_action_show_messages"
|
||||
android:enabled="false"
|
||||
android:enabled="@{viewModel.conferenceModel.isConversationAvailable}"
|
||||
app:layout_constraintTop_toBottomOf="@id/chat"
|
||||
app:layout_constraintStart_toEndOf="@id/layout_label"
|
||||
app:layout_constraintEnd_toStartOf="@id/pause_call_label" />
|
||||
|
|
|
|||
|
|
@ -120,19 +120,39 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:onClick="@{() -> viewModel.conferenceModel.goToConversation()}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/call_button_size"
|
||||
android:layout_marginTop="@dimen/call_extra_button_top_margin"
|
||||
android:padding="@dimen/call_button_icon_padding"
|
||||
android:src="@drawable/chat_teardrop_text"
|
||||
android:enabled="@{viewModel.conferenceModel.isConversationAvailable}"
|
||||
android:contentDescription="@string/call_action_show_messages"
|
||||
android:background="@drawable/shape_round_in_call_disabled_button_background"
|
||||
app:tint="?attr/color_grey_500"
|
||||
android:background="@drawable/in_call_button_background_red"
|
||||
app:tint="@color/in_call_button_tint_color"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintTop_toBottomOf="@id/screen_sharing_label"
|
||||
app:layout_constraintStart_toStartOf="@id/screen_sharing"
|
||||
app:layout_constraintEnd_toEndOf="@id/screen_sharing"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/unread_messages_count"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_red_round"
|
||||
android:text="@{String.valueOf(viewModel.unreadMessagesCount), default=`1`}"
|
||||
android:textColor="?attr/color_on_main"
|
||||
android:textSize="13sp"
|
||||
android:paddingBottom="2dp"
|
||||
android:visibility="@{viewModel.unreadMessagesCount > 0 ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toBottomOf="@id/screen_sharing_label"
|
||||
app:layout_constraintStart_toStartOf="@id/chat"
|
||||
app:layout_constraintEnd_toEndOf="@id/chat"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pause_call"
|
||||
android:onClick="@{() -> viewModel.togglePause()}"
|
||||
|
|
@ -215,11 +235,12 @@
|
|||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/in_call_extra_action_label_style"
|
||||
android:id="@+id/chat_label"
|
||||
android:onClick="@{() -> viewModel.conferenceModel.goToConversation()}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dp"
|
||||
android:text="@string/call_action_show_messages"
|
||||
android:enabled="false"
|
||||
android:enabled="@{viewModel.conferenceModel.isConversationAvailable}"
|
||||
app:layout_constraintTop_toBottomOf="@id/chat"
|
||||
app:layout_constraintStart_toStartOf="@id/screen_sharing_label"
|
||||
app:layout_constraintEnd_toEndOf="@id/screen_sharing_label" />
|
||||
|
|
|
|||
|
|
@ -158,6 +158,12 @@
|
|||
app:enterAnim="@anim/slide_in"
|
||||
app:popExitAnim="@anim/slide_out"
|
||||
app:launchSingleTop="true" />
|
||||
<action
|
||||
android:id="@+id/action_activeConferenceCallFragment_to_inCallConversationFragment"
|
||||
app:destination="@id/inCallConversationFragment"
|
||||
app:enterAnim="@anim/slide_in"
|
||||
app:popExitAnim="@anim/slide_out"
|
||||
app:launchSingleTop="true" />
|
||||
</fragment>
|
||||
|
||||
<action android:id="@+id/action_global_activeConferenceCallFragment"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue