Create if necessary then go to 1-1 chat room when using message button from contact/history details

This commit is contained in:
Sylvain Berfini 2023-10-26 14:31:38 +02:00
parent 425722ef65
commit 6dea7c3fec
9 changed files with 1067 additions and 722 deletions

View file

@ -154,6 +154,7 @@ class ConversationFragment : GenericFragment() {
(view.parent as? ViewGroup)?.doOnPreDraw {
Log.e("$TAG Failed to find chat room, going back")
goBack()
// TODO: show toast
}
}
}

View file

@ -168,7 +168,9 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
super.onCleared()
coreContext.postOnCoreThread {
chatRoom.removeListener(chatRoomListener)
if (::chatRoom.isInitialized) {
chatRoom.removeListener(chatRoomListener)
}
events.value.orEmpty().forEach(EventLogModel::destroy)
}
}

View file

@ -191,17 +191,27 @@ class StartConversationViewModel @UiThread constructor() : AddressSelectionViewM
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
params.isGroupEnabled = false
params.subject = AppUtils.getString(R.string.conversation_one_to_one_hidden_subject)
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
if (account.isInSecureMode() && sameDomain) {
Log.i("$TAG Account is in secure mode & domain matches, creating a E2E chat room")
params.backend = ChatRoom.Backend.FlexisipChat
params.isEncryptionEnabled = true
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
} else if (!account.isInSecureMode()) {
Log.i("$TAG Account is in interop mode, creating a SIP simple chat room")
params.backend = ChatRoom.Backend.Basic
params.isEncryptionEnabled = false
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
Log.i(
"$TAG Account is in interop mode but LIME is available, creating a E2E chat room"
)
params.backend = ChatRoom.Backend.FlexisipChat
params.isEncryptionEnabled = true
} else {
Log.i(
"$TAG Account is in interop mode but LIME isn't available, creating a SIP simple chat room"
)
params.backend = ChatRoom.Backend.Basic
params.isEncryptionEnabled = false
}
} else {
Log.e(
"$TAG Account is in secure mode, can't chat with SIP address of different domain [${remote.asStringUriOnly()}]"

View file

@ -178,6 +178,14 @@ class ContactFragment : GenericFragment() {
}
}
viewModel.goToConversationEvent.observe(viewLifecycleOwner) {
it.consume { pair ->
Log.i("$TAG Going to conversation [${pair.first}][${pair.second}]")
sharedViewModel.showConversationEvent.value = Event(pair)
sharedViewModel.navigateToConversationsEvent.value = Event(true)
}
}
viewModel.vCardTerminatedEvent.observe(viewLifecycleOwner) {
it.consume { pair ->
val contactName = pair.first

View file

@ -29,8 +29,13 @@ import java.util.Locale
import kotlinx.coroutines.launch
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R
import org.linphone.contacts.ContactsManager
import org.linphone.contacts.getListOfSipAddressesAndPhoneNumbers
import org.linphone.core.Address
import org.linphone.core.ChatRoom
import org.linphone.core.ChatRoomListenerStub
import org.linphone.core.ChatRoomParams
import org.linphone.core.Friend
import org.linphone.core.tools.Log
import org.linphone.ui.main.contacts.model.ContactAvatarModel
@ -38,8 +43,10 @@ import org.linphone.ui.main.contacts.model.ContactDeviceModel
import org.linphone.ui.main.contacts.model.ContactNumberOrAddressClickListener
import org.linphone.ui.main.contacts.model.ContactNumberOrAddressModel
import org.linphone.ui.main.model.isInSecureMode
import org.linphone.utils.AppUtils
import org.linphone.utils.Event
import org.linphone.utils.FileUtils
import org.linphone.utils.LinphoneUtils
class ContactViewModel @UiThread constructor() : ViewModel() {
companion object {
@ -70,6 +77,12 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
val videoCallDisabled = MutableLiveData<Boolean>()
val operationInProgress = MutableLiveData<Boolean>()
val chatRoomCreationErrorEvent: MutableLiveData<Event<String>> by lazy {
MutableLiveData<Event<String>>()
}
val showLongPressMenuForNumberOrAddressEvent: MutableLiveData<Event<ContactNumberOrAddressModel>> by lazy {
MutableLiveData<Event<ContactNumberOrAddressModel>>()
}
@ -86,6 +99,10 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<String>>()
}
val goToConversationEvent: MutableLiveData<Event<Pair<String, String>>> by lazy {
MutableLiveData<Event<Pair<String, String>>>()
}
val vCardTerminatedEvent: MutableLiveData<Event<Pair<String, File>>> by lazy {
MutableLiveData<Event<Pair<String, File>>>()
}
@ -107,6 +124,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
override fun onClicked(model: ContactNumberOrAddressModel) {
val address = model.address
if (model.isEnabled && address != null) {
// TODO FIXME: handle chat action & video call as well
coreContext.postOnCoreThread {
Log.i("$TAG Calling SIP address [${address.asStringUriOnly()}]")
coreContext.startCall(address)
@ -139,6 +157,34 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
}
}
private val chatRoomListener = object : ChatRoomListenerStub() {
@WorkerThread
override fun onStateChanged(chatRoom: ChatRoom, newState: ChatRoom.State?) {
val state = chatRoom.state
val id = LinphoneUtils.getChatRoomId(chatRoom)
Log.i("$TAG Chat room [$id] (${chatRoom.subject}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Chat room [$id] successfully created")
chatRoom.removeListener(this)
operationInProgress.postValue(false)
goToConversationEvent.postValue(
Event(
Pair(
chatRoom.localAddress.asStringUriOnly(),
chatRoom.peerAddress.asStringUriOnly()
)
)
)
} else if (state == ChatRoom.State.CreationFailed) {
Log.e("$TAG Chat room [$id] creation has failed!")
chatRoom.removeListener(this)
operationInProgress.postValue(false)
chatRoomCreationErrorEvent.postValue(Event("Error!")) // TODO FIXME: use translated string
}
}
}
private lateinit var friend: Friend
private var refKey: String = ""
@ -387,7 +433,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
}
@UiThread
fun sendMessage() {
fun goToConversation() {
coreContext.postOnCoreThread { core ->
val addressesCount = friend.addresses.size
val numbersCount = friend.phoneNumbers.size
@ -399,7 +445,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
Log.i(
"$TAG Only 1 SIP address found for contact [${friend.name}], sending message directly"
)
// TODO: send message feature
goToConversation(friend.addresses.first())
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
val number = friend.phoneNumbers.first()
val address = core.interpretUrl(number, true)
@ -407,7 +453,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
Log.i(
"$TAG Only 1 phone number found for contact [${friend.name}], sending message directly"
)
// TODO: send message feature
goToConversation(address)
} else {
Log.e("$TAG Failed to interpret phone number [$number] as SIP address")
}
@ -420,4 +466,100 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
}
}
}
@WorkerThread
private fun goToConversation(remote: Address) {
val core = coreContext.core
val account = core.defaultAccount
val localSipUri = account?.params?.identityAddress?.asStringUriOnly()
if (!localSipUri.isNullOrEmpty()) {
val remoteSipUri = remote.asStringUriOnly()
Log.i("$TAG Looking for existing chat room between [$localSipUri] and [$remoteSipUri]")
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
params.isGroupEnabled = false
params.subject = AppUtils.getString(R.string.conversation_one_to_one_hidden_subject)
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
if (account.isInSecureMode() && sameDomain) {
Log.i("$TAG Account is in secure mode & domain matches, creating a E2E chat room")
params.backend = ChatRoom.Backend.FlexisipChat
params.isEncryptionEnabled = true
} else if (!account.isInSecureMode()) {
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
Log.i(
"$TAG Account is in interop mode but LIME is available, creating a E2E chat room"
)
params.backend = ChatRoom.Backend.FlexisipChat
params.isEncryptionEnabled = true
} else {
Log.i(
"$TAG Account is in interop mode but LIME isn't available, creating a SIP simple chat room"
)
params.backend = ChatRoom.Backend.Basic
params.isEncryptionEnabled = false
}
} else {
Log.e(
"$TAG Account is in secure mode, can't chat with SIP address of different domain [${remote.asStringUriOnly()}]"
)
return
}
val participants = arrayOf(remote)
val localAddress = account.params.identityAddress
val existingChatRoom = core.searchChatRoom(params, localAddress, null, participants)
if (existingChatRoom != null) {
Log.i(
"$TAG Found existing chat room [${LinphoneUtils.getChatRoomId(existingChatRoom)}], going to it"
)
goToConversationEvent.postValue(
Event(Pair(localSipUri, existingChatRoom.peerAddress.asStringUriOnly()))
)
} else {
Log.i(
"$TAG No existing chat room between [$localSipUri] and [$remoteSipUri] was found, let's create it"
)
operationInProgress.postValue(true)
val chatRoom = core.createChatRoom(params, localAddress, participants)
if (chatRoom != null) {
if (params.backend == ChatRoom.Backend.FlexisipChat) {
if (chatRoom.state == ChatRoom.State.Created) {
val id = LinphoneUtils.getChatRoomId(chatRoom)
Log.i("$TAG 1-1 chat room [$id] has been created")
operationInProgress.postValue(false)
goToConversationEvent.postValue(
Event(
Pair(
chatRoom.localAddress.asStringUriOnly(),
chatRoom.peerAddress.asStringUriOnly()
)
)
)
} else {
Log.i("$TAG Chat room isn't in Created state yet, wait for it")
chatRoom.addListener(chatRoomListener)
}
} else {
val id = LinphoneUtils.getChatRoomId(chatRoom)
Log.i("$TAG Chat room successfully created [$id]")
operationInProgress.postValue(false)
goToConversationEvent.postValue(
Event(
Pair(
chatRoom.localAddress.asStringUriOnly(),
chatRoom.peerAddress.asStringUriOnly()
)
)
)
}
} else {
Log.e("$TAG Failed to create 1-1 chat room with [${remote.asStringUriOnly()}]!")
operationInProgress.postValue(false)
chatRoomCreationErrorEvent.postValue(Event("Error!")) // TODO FIXME: use translated string
}
}
}
}
}

View file

@ -128,6 +128,14 @@ class HistoryContactFragment : GenericFragment() {
goBack() // TODO FIXME : issue with tablet when pane can't be closed
}
}
viewModel.goToConversationEvent.observe(viewLifecycleOwner) {
it.consume { pair ->
Log.i("$TAG Going to conversation [${pair.first}][${pair.second}]")
sharedViewModel.showConversationEvent.value = Event(pair)
sharedViewModel.navigateToConversationsEvent.value = Event(true)
}
}
}
private fun copyNumberOrAddressToClipboard(value: String) {

View file

@ -1,18 +1,30 @@
package org.linphone.ui.main.history.viewmodel
import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R
import org.linphone.core.Address
import org.linphone.core.Call
import org.linphone.core.ChatRoom
import org.linphone.core.ChatRoomListenerStub
import org.linphone.core.ChatRoomParams
import org.linphone.core.tools.Log
import org.linphone.ui.main.history.model.CallLogHistoryModel
import org.linphone.ui.main.history.model.CallLogModel
import org.linphone.ui.main.model.isInSecureMode
import org.linphone.utils.AppUtils
import org.linphone.utils.Event
import org.linphone.utils.LinphoneUtils
class ContactHistoryViewModel @UiThread constructor() : ViewModel() {
companion object {
private const val TAG = "[Contact History ViewModel]"
}
val showBackButton = MutableLiveData<Boolean>()
val callLogModel = MutableLiveData<CallLogModel>()
@ -23,12 +35,50 @@ class ContactHistoryViewModel @UiThread constructor() : ViewModel() {
val videoCallDisabled = MutableLiveData<Boolean>()
val operationInProgress = MutableLiveData<Boolean>()
val chatRoomCreationErrorEvent: MutableLiveData<Event<String>> by lazy {
MutableLiveData<Event<String>>()
}
val goToConversationEvent: MutableLiveData<Event<Pair<String, String>>> by lazy {
MutableLiveData<Event<Pair<String, String>>>()
}
val historyDeletedEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
private lateinit var address: Address
private val chatRoomListener = object : ChatRoomListenerStub() {
@WorkerThread
override fun onStateChanged(chatRoom: ChatRoom, newState: ChatRoom.State?) {
val state = chatRoom.state
val id = LinphoneUtils.getChatRoomId(chatRoom)
Log.i("$TAG Chat room [$id] (${chatRoom.subject}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Chat room [$id] successfully created")
chatRoom.removeListener(this)
operationInProgress.postValue(false)
goToConversationEvent.postValue(
Event(
Pair(
chatRoom.localAddress.asStringUriOnly(),
chatRoom.peerAddress.asStringUriOnly()
)
)
)
} else if (state == ChatRoom.State.CreationFailed) {
Log.e("$TAG Chat room [$id] creation has failed!")
chatRoom.removeListener(this)
operationInProgress.postValue(false)
chatRoomCreationErrorEvent.postValue(Event("Error!")) // TODO FIXME: use translated string
}
}
}
init {
coreContext.postOnCoreThread { core ->
chatDisabled.postValue(corePreferences.disableChat)
@ -92,7 +142,108 @@ class ContactHistoryViewModel @UiThread constructor() : ViewModel() {
}
@UiThread
fun sendMessage() {
// TODO: chat feature
fun goToConversation() {
coreContext.postOnCoreThread { core ->
val account = core.defaultAccount
val localSipUri = account?.params?.identityAddress?.asStringUriOnly()
if (!localSipUri.isNullOrEmpty()) {
val remote = address
val remoteSipUri = remote.asStringUriOnly()
Log.i(
"$TAG Looking for existing chat room between [$localSipUri] and [$remoteSipUri]"
)
val params: ChatRoomParams = coreContext.core.createDefaultChatRoomParams()
params.isGroupEnabled = false
params.subject = AppUtils.getString(R.string.conversation_one_to_one_hidden_subject)
params.ephemeralLifetime = 0 // Make sure ephemeral is disabled by default
val sameDomain = remote.domain == corePreferences.defaultDomain && remote.domain == account.params.domain
if (account.isInSecureMode() && sameDomain) {
Log.i(
"$TAG Account is in secure mode & domain matches, creating a E2E chat room"
)
params.backend = ChatRoom.Backend.FlexisipChat
params.isEncryptionEnabled = true
} else if (!account.isInSecureMode()) {
if (LinphoneUtils.isEndToEndEncryptedChatAvailable(core)) {
Log.i(
"$TAG Account is in interop mode but LIME is available, creating a E2E chat room"
)
params.backend = ChatRoom.Backend.FlexisipChat
params.isEncryptionEnabled = true
} else {
Log.i(
"$TAG Account is in interop mode but LIME isn't available, creating a SIP simple chat room"
)
params.backend = ChatRoom.Backend.Basic
params.isEncryptionEnabled = false
}
} else {
Log.e(
"$TAG Account is in secure mode, can't chat with SIP address of different domain [${remote.asStringUriOnly()}]"
)
return@postOnCoreThread
}
val participants = arrayOf(remote)
val localAddress = account.params.identityAddress
val existingChatRoom = core.searchChatRoom(params, localAddress, null, participants)
if (existingChatRoom != null) {
Log.i(
"$TAG Found existing chat room [${LinphoneUtils.getChatRoomId(
existingChatRoom
)}], going to it"
)
goToConversationEvent.postValue(
Event(Pair(localSipUri, existingChatRoom.peerAddress.asStringUriOnly()))
)
} else {
Log.i(
"$TAG No existing chat room between [$localSipUri] and [$remoteSipUri] was found, let's create it"
)
operationInProgress.postValue(true)
val chatRoom = core.createChatRoom(params, localAddress, participants)
if (chatRoom != null) {
if (params.backend == ChatRoom.Backend.FlexisipChat) {
if (chatRoom.state == ChatRoom.State.Created) {
val id = LinphoneUtils.getChatRoomId(chatRoom)
Log.i("$TAG 1-1 chat room [$id] has been created")
operationInProgress.postValue(false)
goToConversationEvent.postValue(
Event(
Pair(
chatRoom.localAddress.asStringUriOnly(),
chatRoom.peerAddress.asStringUriOnly()
)
)
)
} else {
Log.i("$TAG Chat room isn't in Created state yet, wait for it")
chatRoom.addListener(chatRoomListener)
}
} else {
val id = LinphoneUtils.getChatRoomId(chatRoom)
Log.i("$TAG Chat room successfully created [$id]")
operationInProgress.postValue(false)
goToConversationEvent.postValue(
Event(
Pair(
chatRoom.localAddress.asStringUriOnly(),
chatRoom.peerAddress.asStringUriOnly()
)
)
)
}
} else {
Log.e(
"$TAG Failed to create 1-1 chat room with [${remote.asStringUriOnly()}]!"
)
operationInProgress.postValue(false)
chatRoomCreationErrorEvent.postValue(Event("Error!")) // TODO FIXME: use translated string
}
}
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
@ -17,231 +18,241 @@
type="org.linphone.ui.main.history.viewmodel.ContactHistoryViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
android:layout_height="match_parent">
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:onClick="@{backClickListener}"
android:visibility="@{viewModel.showBackButton ? View.VISIBLE : View.GONE}"
android:src="@drawable/caret_left"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<androidx.appcompat.widget.AppCompatTextView
style="@style/main_page_title_style"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="@dimen/top_bar_height"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/history_title"
app:layout_constraintEnd_toStartOf="@id/menu"
app:layout_constraintStart_toEndOf="@id/back"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:onClick="@{backClickListener}"
android:visibility="@{viewModel.showBackButton ? View.VISIBLE : View.GONE}"
android:src="@drawable/caret_left"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title"/>
<ImageView
android:onClick="@{menuClickListener}"
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/dots_three_vertical"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/main_page_title_style"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="@dimen/top_bar_height"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/history_title"
app:layout_constraintEnd_toStartOf="@id/menu"
app:layout_constraintStart_toEndOf="@id/back"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/background"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/gray_100"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:onClick="@{menuClickListener}"
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/dots_three_vertical"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<com.google.android.material.imageview.ShapeableImageView
style="@style/avatar_imageview"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_big_size"
android:layout_height="@dimen/avatar_big_size"
android:layout_marginTop="8dp"
coilBigAvatar="@{viewModel.callLogModel.avatarModel}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />
<View
android:id="@+id/background"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/gray_100"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/presence_badge"
android:layout_width="@dimen/avatar_presence_badge_big_size"
android:layout_height="@dimen/avatar_presence_badge_big_size"
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.callLogModel.avatarModel.presenceStatus}"
android:visibility="@{viewModel.callLogModel.avatarModel.presenceStatus == ConsolidatedPresence.Offline ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="@id/avatar"
app:layout_constraintBottom_toBottomOf="@id/avatar"/>
<com.google.android.material.imageview.ShapeableImageView
style="@style/avatar_imageview"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_big_size"
android:layout_height="@dimen/avatar_big_size"
android:layout_marginTop="8dp"
coilBigAvatar="@{viewModel.callLogModel.avatarModel}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />
<ImageView
android:id="@+id/trust_badge"
android:layout_width="@dimen/avatar_presence_badge_in_call_size"
android:layout_height="@dimen/avatar_presence_badge_in_call_size"
android:src="@{viewModel.callLogModel.avatarModel.trust == SecurityLevel.Safe ? @drawable/trusted : @drawable/not_trusted, default=@drawable/trusted}"
android:visibility="@{viewModel.callLogModel.avatarModel.trust == SecurityLevel.Safe || viewModel.callLogModel.avatarModel.trust == SecurityLevel.Unsafe ? View.VISIBLE : View.GONE}"
app:layout_constraintStart_toStartOf="@id/avatar"
app:layout_constraintBottom_toBottomOf="@id/avatar"/>
<ImageView
android:id="@+id/presence_badge"
android:layout_width="@dimen/avatar_presence_badge_big_size"
android:layout_height="@dimen/avatar_presence_badge_big_size"
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.callLogModel.avatarModel.presenceStatus}"
android:visibility="@{viewModel.callLogModel.avatarModel.presenceStatus == ConsolidatedPresence.Offline ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="@id/avatar"
app:layout_constraintBottom_toBottomOf="@id/avatar"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{viewModel.callLogModel.avatarModel.name, default=`John Doe`}"
android:textColor="@color/gray_main2_700"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/avatar" />
<ImageView
android:id="@+id/trust_badge"
android:layout_width="@dimen/avatar_presence_badge_in_call_size"
android:layout_height="@dimen/avatar_presence_badge_in_call_size"
android:src="@{viewModel.callLogModel.avatarModel.trust == SecurityLevel.Safe ? @drawable/trusted : @drawable/not_trusted, default=@drawable/trusted}"
android:visibility="@{viewModel.callLogModel.avatarModel.trust == SecurityLevel.Safe || viewModel.callLogModel.avatarModel.trust == SecurityLevel.Unsafe ? View.VISIBLE : View.GONE}"
app:layout_constraintStart_toStartOf="@id/avatar"
app:layout_constraintBottom_toBottomOf="@id/avatar"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.callLogModel.displayedAddress, default=`+33601020304`}"
android:textColor="@color/gray_main2_700"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/name" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{viewModel.callLogModel.avatarModel.name, default=`John Doe`}"
android:textColor="@color/gray_main2_700"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/avatar" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_300"
android:id="@+id/status"
android:visibility="@{viewModel.callLogModel.avatarModel.presenceStatus == ConsolidatedPresence.Offline ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.callLogModel.avatarModel.lastPresenceInfo, default=@string/friend_presence_status_online}"
android:textColor="@{viewModel.callLogModel.avatarModel.presenceStatus == ConsolidatedPresence.Online ? @color/green_success_500 : @color/orange_warning_600, default=@color/green_success_500}"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/address" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.callLogModel.displayedAddress, default=`+33601020304`}"
android:textColor="@color/gray_main2_700"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/name" />
<ImageView
android:onClick="@{() -> viewModel.startAudioCall()}"
android:id="@+id/call"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
android:background="@drawable/circle_light_blue_button_background"
android:padding="16dp"
android:src="@drawable/phone"
app:tint="@color/gray_main2_500"
app:layout_constraintEnd_toStartOf="@id/chat"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_300"
android:id="@+id/status"
android:visibility="@{viewModel.callLogModel.avatarModel.presenceStatus == ConsolidatedPresence.Offline ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.callLogModel.avatarModel.lastPresenceInfo, default=@string/friend_presence_status_online}"
android:textColor="@{viewModel.callLogModel.avatarModel.presenceStatus == ConsolidatedPresence.Online ? @color/green_success_500 : @color/orange_warning_600, default=@color/green_success_500}"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/address" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:onClick="@{() -> viewModel.startAudioCall()}"
android:id="@+id/call_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/friend_call_action"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/call"
app:layout_constraintStart_toStartOf="@id/call"
app:layout_constraintEnd_toEndOf="@id/call"/>
<ImageView
android:id="@+id/call"
android:onClick="@{() -> viewModel.startAudioCall()}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
android:background="@drawable/circle_light_blue_button_background"
android:padding="16dp"
android:src="@drawable/phone"
app:tint="@color/gray_main2_500"
app:layout_constraintEnd_toStartOf="@id/chat"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status" />
<ImageView
android:onClick="@{() -> viewModel.sendMessage()}"
android:id="@+id/chat"
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
android:background="@drawable/circle_light_blue_button_background"
android:padding="16dp"
android:src="@drawable/chat_teardrop_text"
app:tint="@color/gray_main2_500"
app:layout_constraintEnd_toStartOf="@id/video_call"
app:layout_constraintStart_toEndOf="@id/call"
app:layout_constraintTop_toBottomOf="@id/status" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/call_label"
android:onClick="@{() -> viewModel.startAudioCall()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/friend_call_action"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/call"
app:layout_constraintStart_toStartOf="@id/call"
app:layout_constraintEnd_toEndOf="@id/call"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:onClick="@{() -> viewModel.sendMessage()}"
android:id="@+id/chat_label"
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/friend_message_action"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/chat"
app:layout_constraintStart_toStartOf="@id/chat"
app:layout_constraintEnd_toEndOf="@id/chat"/>
<ImageView
android:id="@+id/chat"
android:onClick="@{() -> viewModel.goToConversation()}"
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
android:background="@drawable/circle_light_blue_button_background"
android:padding="16dp"
android:src="@drawable/chat_teardrop_text"
app:tint="@color/gray_main2_500"
app:layout_constraintEnd_toStartOf="@id/video_call"
app:layout_constraintStart_toEndOf="@id/call"
app:layout_constraintTop_toBottomOf="@id/status" />
<ImageView
android:onClick="@{() -> viewModel.startVideoCall()}"
android:id="@+id/video_call"
android:visibility="@{viewModel.videoCallDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
android:background="@drawable/circle_light_blue_button_background"
android:padding="16dp"
android:src="@drawable/video_camera"
app:tint="@color/gray_main2_500"
app:layout_constraintStart_toEndOf="@id/chat"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/status" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/chat_label"
android:onClick="@{() -> viewModel.goToConversation()}"
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/friend_message_action"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/chat"
app:layout_constraintStart_toStartOf="@id/chat"
app:layout_constraintEnd_toEndOf="@id/chat"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:onClick="@{() -> viewModel.startVideoCall()}"
android:id="@+id/video_call_label"
android:visibility="@{viewModel.videoCallDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/friend_video_call_action"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/video_call"
app:layout_constraintStart_toStartOf="@id/video_call"
app:layout_constraintEnd_toEndOf="@id/video_call"/>
<ImageView
android:id="@+id/video_call"
android:onClick="@{() -> viewModel.startVideoCall()}"
android:visibility="@{viewModel.videoCallDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
android:background="@drawable/circle_light_blue_button_background"
android:padding="16dp"
android:src="@drawable/video_camera"
app:tint="@color/gray_main2_500"
app:layout_constraintStart_toEndOf="@id/chat"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/status" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/call_history"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="28dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="@dimen/screen_bottom_margin"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="@drawable/shape_squircle_white_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/call_label"
app:layout_constraintBottom_toBottomOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/video_call_label"
android:onClick="@{() -> viewModel.startVideoCall()}"
android:visibility="@{viewModel.videoCallDisabled ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/friend_video_call_action"
android:textSize="14sp"
app:layout_constraintTop_toBottomOf="@id/video_call"
app:layout_constraintStart_toStartOf="@id/video_call"
app:layout_constraintEnd_toEndOf="@id/video_call"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/call_history"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="28dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="@dimen/screen_bottom_margin"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="@drawable/shape_squircle_white_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/call_label"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include
layout="@layout/operation_in_progress"
bind:visibility="@{viewModel.operationInProgress}" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>