Improved conference call log display in history (avatar to improve)

This commit is contained in:
Sylvain Berfini 2023-10-26 16:09:49 +02:00
parent 17a4e546a5
commit 178aae3883
7 changed files with 45 additions and 3 deletions

View file

@ -11,4 +11,6 @@ abstract class AbstractAvatarModel {
val initials = MutableLiveData<String>()
val images = MutableLiveData<ArrayList<String>>()
val showConferenceIcon = MutableLiveData<Boolean>()
}

View file

@ -112,7 +112,7 @@ class HistoryListFragment : AbstractTopBarFragment() {
}
},
{ // onCopyNumberOrAddressToClipboard
val addressToCopy = model.displayedAddress
val addressToCopy = model.sipUri
Log.i("$TAG Copying number [$addressToCopy] to clipboard")
copyNumberOrAddressToClipboard(addressToCopy)
},

View file

@ -18,7 +18,9 @@ class CallLogModel @WorkerThread constructor(private val callLog: CallLog) {
val address = if (callLog.dir == Dir.Outgoing) callLog.toAddress else callLog.fromAddress
val displayedAddress = address.asStringUriOnly()
val sipUri = address.asStringUriOnly()
val displayedAddress: String
val avatarModel: ContactAvatarModel
@ -32,6 +34,10 @@ class CallLogModel @WorkerThread constructor(private val callLog: CallLog) {
var friendExists: Boolean = false
init {
val clone = address.clone()
clone.clean()
displayedAddress = clone.asStringUriOnly()
val timestamp = timestamp
val displayedDate = if (TimestampUtils.isToday(timestamp)) {
TimestampUtils.timeToString(timestamp)
@ -50,6 +56,14 @@ class CallLogModel @WorkerThread constructor(private val callLog: CallLog) {
} else {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.address = address
// Check if it is a conference
val conferenceInfo = coreContext.core.findConferenceInformationFromUri(address)
if (conferenceInfo != null) {
avatarModel.name.postValue(conferenceInfo.subject)
avatarModel.showConferenceIcon.postValue(true)
}
friendRefKey = null
friendExists = false
}

View file

@ -93,6 +93,14 @@ class ContactHistoryViewModel @UiThread constructor() : ViewModel() {
if (callLog != null) {
val model = CallLogModel(callLog)
address = model.address
// Check if it is a conference
val conferenceInfo = coreContext.core.findConferenceInformationFromUri(address)
if (conferenceInfo != null) {
model.avatarModel.name.postValue(conferenceInfo.subject)
model.avatarModel.showConferenceIcon.postValue(true)
}
callLogModel.postValue(model)
val peerAddress = if (callLog.dir == Call.Dir.Outgoing) callLog.toAddress else callLog.fromAddress

View file

@ -112,7 +112,6 @@ class HistoryListViewModel @UiThread constructor() : AbstractTopBarViewModel() {
val list = arrayListOf<CallLogModel>()
var count = 0
// TODO? : Add support for call logs in magic search
val account = LinphoneUtils.getDefaultAccount()
val logs = account?.callLogs ?: coreContext.core.callLogs
for (callLog in logs) {

View file

@ -290,6 +290,17 @@ private suspend fun loadContactPictureWithCoil(
val context = imageView.context
if (model != null) {
if (model.showConferenceIcon.value == true) {
imageView.load(
ResourcesCompat.getDrawable(
context.resources,
R.drawable.users_three,
context.theme
)
)
return@withContext
}
if (!skipTrust) {
if (model.showTrust.value == true) {
when (model.trust.value) {

View file

@ -114,9 +114,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{viewModel.callLogModel.avatarModel.name, default=`John Doe`}"
android:textColor="@color/gray_main2_700"
android:textSize="14sp"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/avatar" />
@ -126,9 +130,13 @@
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{viewModel.callLogModel.displayedAddress, default=`+33601020304`}"
android:textColor="@color/gray_main2_700"
android:textSize="14sp"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/name" />