Using onlyDisplaySipUriUsername preference

This commit is contained in:
Sylvain Berfini 2024-04-19 12:14:08 +02:00
parent 2d1479a64f
commit b96e5e8121
5 changed files with 23 additions and 6 deletions

View file

@ -140,8 +140,8 @@ class CorePreferences @UiThread constructor(private val context: Context) {
get() = config.getBool("ui", "dark_mode_allowed", true)
@get:WorkerThread
val onlyDisplaySipUriUsername: Boolean // TODO FIXME: use it
get() = config.getBool("ui", "only_display_sip_uri_username", true)
val onlyDisplaySipUriUsername: Boolean
get() = config.getBool("ui", "only_display_sip_uri_username", false)
@get:WorkerThread
val disableChat: Boolean

View file

@ -1002,7 +1002,12 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
canBePaused.postValue(canCallBePaused())
val address = call.remoteAddress
displayedAddress.postValue(LinphoneUtils.getAddressAsCleanStringUriOnly(address))
val uri = if (corePreferences.onlyDisplaySipUriUsername) {
address.username ?: ""
} else {
LinphoneUtils.getAddressAsCleanStringUriOnly(address)
}
displayedAddress.postValue(uri)
val model = if (conferenceInfo != null) {
coreContext.contactsManager.getContactAvatarModelForConferenceInfo(conferenceInfo)

View file

@ -24,6 +24,7 @@ import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
import androidx.lifecycle.MutableLiveData
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.ChatRoom
@ -453,7 +454,13 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
val firstParticipant = chatRoom.participants.firstOrNull()
if (firstParticipant != null) {
val address = firstParticipant.address
sipUri.postValue(LinphoneUtils.getAddressAsCleanStringUriOnly(address))
val uri = if (corePreferences.onlyDisplaySipUriUsername) {
address.username ?: ""
} else {
LinphoneUtils.getAddressAsCleanStringUriOnly(address)
}
sipUri.postValue(uri)
val friend = coreContext.contactsManager.findContactByAddress(address)
oneToOneParticipantRefKey.postValue(friend?.refKey ?: "")
}

View file

@ -142,7 +142,7 @@ class HistoryContactFragment : SlidingPaneChildFragment() {
getString(R.string.toast_call_history_deleted),
R.drawable.check
)
goBack() // TODO FIXME : issue with tablet when pane can't be closed
goBack()
}
}

View file

@ -4,6 +4,7 @@ import androidx.annotation.IntegerRes
import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R
import org.linphone.core.Call.Dir
import org.linphone.core.CallLog
@ -76,7 +77,11 @@ class CallLogModel @WorkerThread constructor(private val callLog: CallLog) {
friendRefKey = friend.refKey
friendExists = !friendRefKey.isNullOrEmpty()
}
displayedAddress = avatarModel.friend.address?.asStringUriOnly() ?: address.asStringUriOnly()
displayedAddress = if (corePreferences.onlyDisplaySipUriUsername) {
avatarModel.friend.address?.username ?: address.username ?: ""
} else {
avatarModel.friend.address?.asStringUriOnly() ?: address.asStringUriOnly()
}
iconResId = LinphoneUtils.getCallIconResId(callLog.status, callLog.dir)
}