Fixed trusted icon visible in account profile if not in secure mode, hardcoded texts, wrong conference subject displayed in calls history list

This commit is contained in:
Sylvain Berfini 2023-11-06 11:39:48 +01:00
parent 2857378c87
commit af03b30352
9 changed files with 46 additions and 20 deletions

View file

@ -204,6 +204,7 @@ class ContactsManager @UiThread constructor(context: Context) {
ContactAvatarModel(friend)
} else {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = LinphoneUtils.getDisplayName(address)
fakeFriend.address = clone
ContactAvatarModel(fakeFriend)
}

View file

@ -41,7 +41,7 @@ class ContactAvatarModel @WorkerThread constructor(val friend: Friend) : Abstrac
private const val TAG = "[Contact Avatar Model]"
}
val id = friend.refKey
val id = friend.refKey ?: friend.name
val starred = friend.starred

View file

@ -3,9 +3,11 @@ package org.linphone.ui.main.history.model
import androidx.annotation.IntegerRes
import androidx.annotation.WorkerThread
import androidx.lifecycle.MutableLiveData
import org.linphone.R
import org.linphone.core.Call
import org.linphone.core.Call.Dir
import org.linphone.core.CallLog
import org.linphone.utils.AppUtils
import org.linphone.utils.LinphoneUtils
import org.linphone.utils.TimestampUtils
@ -28,9 +30,9 @@ class CallLogHistoryModel @WorkerThread constructor(val callLog: CallLog) {
val startDate = callLog.startDate
val date = if (TimestampUtils.isToday(startDate)) {
"Aujourd'hui"
AppUtils.getString(R.string.today)
} else if (TimestampUtils.isYesterday(startDate)) {
"Hier"
AppUtils.getString(R.string.yesterday)
} else {
TimestampUtils.dateToString(callLog.startDate)
}

View file

@ -5,13 +5,20 @@ import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
import androidx.lifecycle.MutableLiveData
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.Call.Dir
import org.linphone.core.CallLog
import org.linphone.core.tools.Log
import org.linphone.ui.main.contacts.model.ContactAvatarModel
import org.linphone.utils.AppUtils
import org.linphone.utils.LinphoneUtils
import org.linphone.utils.TimestampUtils
class CallLogModel @WorkerThread constructor(private val callLog: CallLog) {
companion object {
private const val TAG = "[CallLog Model]"
}
val id = callLog.callId ?: callLog.refKey
val timestamp = callLog.startDate
@ -34,39 +41,41 @@ 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)
} else if (TimestampUtils.isYesterday(timestamp)) {
"Hier"
AppUtils.getString(R.string.yesterday)
} else {
TimestampUtils.dateToString(timestamp)
}
dateTime.postValue(displayedDate)
val friend = coreContext.contactsManager.findContactByAddress(address)
avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(address)
if (friend != null) {
friendRefKey = friend.refKey
friendExists = true
} else {
if (callLog.wasConference()) {
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)
fakeFriend.name = conferenceInfo.subject
} else {
fakeFriend.name = LinphoneUtils.getDisplayName(address)
Log.w(
"$TAG Call log was conference but failed to find matching conference info from it's URI!"
)
}
avatarModel = ContactAvatarModel(fakeFriend)
avatarModel.showConferenceIcon.postValue(true)
friendRefKey = null
friendExists = false
} else {
avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(address)
val friend = avatarModel.friend
friendRefKey = friend.refKey
friendExists = !friendRefKey.isNullOrEmpty()
}
displayedAddress = avatarModel.friend.address?.asStringUriOnly() ?: address.asStringUriOnly()
iconResId.postValue(LinphoneUtils.getCallIconResId(callLog.status, callLog.dir))
}

View file

@ -345,7 +345,7 @@ private suspend fun loadContactPictureWithCoil(
imageView.load(
ResourcesCompat.getDrawable(
context.resources,
R.drawable.users_three,
R.drawable.inset_users_three,
context.theme
)
)
@ -419,7 +419,7 @@ private suspend fun loadContactPictureWithCoil(
imageView.load(
ResourcesCompat.getDrawable(
context.resources,
R.drawable.user_circle,
R.drawable.inset_user_circle,
context.theme
)
)

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/user_circle"
android:inset="8dp">
</inset>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/users_three"
android:inset="8dp">
</inset>

View file

@ -5,6 +5,7 @@
<data>
<import type="android.view.View" />
<import type="org.linphone.core.ChatRoom.SecurityLevel" />
<variable
name="backClickListener"
type="View.OnClickListener" />
@ -101,7 +102,8 @@
android:layout_width="@dimen/avatar_presence_badge_big_size"
android:layout_height="@dimen/avatar_presence_badge_big_size"
android:layout_marginStart="@dimen/avatar_presence_badge_big_end_margin"
android:src="@drawable/trusted"
android:src="@{viewModel.accountModel.trust == SecurityLevel.Safe ? @drawable/trusted : @drawable/not_trusted, default=@drawable/trusted}"
android:visibility="@{viewModel.accountModel.showTrust ? View.VISIBLE : View.GONE}"
app:layout_constraintStart_toStartOf="@id/avatar"
app:layout_constraintBottom_toBottomOf="@id/avatar"/>

View file

@ -47,6 +47,8 @@
<string name="next">next</string>
<string name="start">Start</string>
<string name="required">Required</string>
<string name="today">Today</string>
<string name="yesterday">Yesterday</string>
<plurals name="selection_count_label">
<item quantity="one">%s selected</item>