Various fixes & improvements

This commit is contained in:
Sylvain Berfini 2023-10-26 16:53:17 +02:00
parent 178aae3883
commit 2eb8b496cd
9 changed files with 96 additions and 46 deletions

View file

@ -189,13 +189,24 @@ class ContactsManager @UiThread constructor(context: Context) {
val foundInMap = if (avatarsMap.keys.contains(key)) avatarsMap[key] else null
if (foundInMap != null) return foundInMap
val friend = coreContext.contactsManager.findContactByAddress(clone)
val avatar = if (friend != null) {
ContactAvatarModel(friend)
} else {
val localAccount = coreContext.core.accountList.find {
it.params.identityAddress?.weakEqual(clone) == true
}
val avatar = if (localAccount != null) {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.address = clone
fakeFriend.name = LinphoneUtils.getDisplayName(localAccount.params.identityAddress)
fakeFriend.photo = localAccount.params.pictureUri
ContactAvatarModel(fakeFriend)
} else {
val friend = coreContext.contactsManager.findContactByAddress(clone)
if (friend != null) {
ContactAvatarModel(friend)
} else {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.address = clone
ContactAvatarModel(fakeFriend)
}
}
avatarsMap[key] = avatar

View file

@ -26,6 +26,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import com.google.android.material.bottomsheet.BottomSheetBehavior
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.databinding.CallActiveConferenceFragmentBinding
import org.linphone.ui.call.viewmodel.CallsViewModel
import org.linphone.ui.call.viewmodel.CurrentCallViewModel
@ -85,5 +86,30 @@ class ActiveConferenceCallFragment : GenericCallFragment() {
}
}
}
actionsBottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
when (newState) {
BottomSheetBehavior.STATE_COLLAPSED, BottomSheetBehavior.STATE_HIDDEN -> {
callViewModel.isActionsMenuExpanded.value = false
}
BottomSheetBehavior.STATE_EXPANDED -> {
callViewModel.isActionsMenuExpanded.value = true
}
else -> {}
}
}
override fun onSlide(bottomSheet: View, slideOffset: Float) {}
})
}
override fun onResume() {
super.onResume()
coreContext.postOnCoreThread {
// Need to be done manually
callViewModel.updateCallDuration()
}
}
}

View file

@ -95,6 +95,9 @@ class ConferenceModel {
@WorkerThread
override fun onStateChanged(conference: Conference, state: Conference.State) {
Log.i("$TAG State changed [$state]")
if (conference.state == Conference.State.Created) {
computeParticipantsDevices()
}
}
}
@ -121,7 +124,9 @@ class ConferenceModel {
)
subject.postValue(conference.subject)
computeParticipantsDevices()
if (conference.state == Conference.State.Created) {
computeParticipantsDevices()
}
}
@WorkerThread

View file

@ -783,10 +783,14 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
model.trust.postValue(securityLevel)
contact.postValue(model)
} else {
val conferenceInfo = coreContext.core.findConferenceInformationFromUri(
call.remoteAddress
)
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = LinphoneUtils.getDisplayName(address)
fakeFriend.name = conferenceInfo?.subject ?: LinphoneUtils.getDisplayName(address)
fakeFriend.addAddress(address)
val model = ContactAvatarModel(fakeFriend)
model.showConferenceIcon.postValue(conferenceInfo != null)
model.trust.postValue(securityLevel)
contact.postValue(model)
displayedName.postValue(fakeFriend.name)

View file

@ -32,7 +32,6 @@ import org.linphone.core.Factory
import org.linphone.core.tools.Log
import org.linphone.ui.main.contacts.model.ContactAvatarModel
import org.linphone.utils.Event
import org.linphone.utils.LinphoneUtils
import org.linphone.utils.TimestampUtils
class MeetingWaitingRoomViewModel @UiThread constructor() : ViewModel() {
@ -195,10 +194,9 @@ class MeetingWaitingRoomViewModel @UiThread constructor() : ViewModel() {
dateTime.postValue("$date | $startTime - $endTime")
val localAddress = coreContext.core.defaultAccount?.params?.identityAddress
val fakeFriend = coreContext.core.createFriend()
fakeFriend.address = localAddress
fakeFriend.name = LinphoneUtils.getDisplayName(localAddress)
val avatarModel = ContactAvatarModel(fakeFriend)
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(
localAddress
)
selfAvatar.postValue(avatarModel)
}
}

View file

@ -186,26 +186,26 @@ class MainViewModel @UiThread constructor() : ViewModel() {
private fun updateCurrentCallInfo() {
val core = coreContext.core
if (core.callsNb == 1) {
val currentCall = core.currentCall
val currentCall = core.currentCall ?: core.calls.firstOrNull()
if (currentCall != null) {
val contact = coreContext.contactsManager.findContactByAddress(
currentCall.remoteAddress
)
callLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(currentCall.remoteAddress)
)
callsStatus.postValue(LinphoneUtils.callStateToString(currentCall.state))
} else {
val firstCall = core.calls.firstOrNull()
if (firstCall != null) {
val contact = coreContext.contactsManager.findContactByAddress(
firstCall.remoteAddress
if (contact != null) {
callLabel.postValue(
contact.name ?: LinphoneUtils.getDisplayName(currentCall.remoteAddress)
)
} else {
val conferenceInfo = coreContext.core.findConferenceInformationFromUri(
currentCall.remoteAddress
)
callLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(firstCall.remoteAddress)
conferenceInfo?.subject ?: LinphoneUtils.getDisplayName(
currentCall.remoteAddress
)
)
callsStatus.postValue(LinphoneUtils.callStateToString(firstCall.state))
}
callsStatus.postValue(LinphoneUtils.callStateToString(currentCall.state))
}
} else {
callLabel.postValue(

View file

@ -36,20 +36,6 @@
android:layout_height="match_parent"
android:background="@color/gray_900">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/hinge_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/hinge_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="1" />
<ImageView
android:id="@+id/background"
android:src="@drawable/shape_round_in_call_gray_background"
@ -57,8 +43,9 @@
android:layout_height="0dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="@dimen/call_main_actions_menu_height"
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.GONE : View.VISIBLE}"
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.GONE : View.VISIBLE, default=gone}"
app:layout_constraintTop_toBottomOf="@id/call_direction_label"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -73,6 +60,7 @@
android:text="@string/conference_call_empty"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.GONE : View.VISIBLE, default=gone}"
app:layout_constraintTop_toTopOf="@id/background"
app:layout_constraintBottom_toBottomOf="@id/background"
app:layout_constraintStart_toStartOf="parent"
@ -93,6 +81,7 @@
android:text="@string/conference_share_link_title"
android:textSize="18sp"
android:textColor="@color/gray_main2_400"
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.GONE : View.VISIBLE, default=gone}"
android:drawableStart="@drawable/share_network"
android:drawablePadding="8dp"
app:drawableTint="@color/gray_main2_400"
@ -106,6 +95,7 @@
android:layout_height="0dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="@dimen/call_main_actions_menu_height"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE}"
@ -142,11 +132,9 @@
android:layout_height="@dimen/call_top_bar_text_height"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="@{conferenceViewModel.subject, default=`Meeting with John Doe`}"
app:layout_constraintStart_toEndOf="@id/call_direction_icon"
app:layout_constraintTop_toTopOf="@id/hinge_top"
app:layout_constraintBottom_toTopOf="@id/background"/>
app:layout_constraintTop_toTopOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/call_header_style"

View file

@ -13,10 +13,15 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:background="@drawable/shape_round_in_call_gray_background"
android:padding="8dp"
app:layout_constraintDimensionRatio="1:1">
<ImageView
android:id="@+id/participant_device_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_round_in_call_gray_background" />
<com.google.android.material.imageview.ShapeableImageView
style="@style/avatar_imageview"
android:id="@+id/avatar"
@ -57,8 +62,8 @@
android:id="@+id/muted"
android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:padding="2dp"
android:src="@drawable/microphone_slash"
android:background="@drawable/circle_white_button_background"
@ -75,7 +80,7 @@
android:layout_marginBottom="8dp"
android:text="@{model.avatarModel.name, default=`John Doe`}"
android:textColor="@color/white"
android:textSize="12sp"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />

View file

@ -92,6 +92,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/back"
app:layout_constraintBottom_toTopOf="@id/toggle_mute_mic"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_500"
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginBottom="8dp"
android:text="@{viewModel.selfAvatar.name, default=`John Doe`}"
android:textColor="@color/white"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="@id/no_video_background"
app:layout_constraintStart_toStartOf="@id/no_video_background" />
<ImageView
android:id="@+id/switch_camera"