mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Hide suggestions SIP address domain if it matches default account SIP identity one + fixed suggestion avatar for phone numbers
This commit is contained in:
parent
df09bcad76
commit
f8556aa46b
3 changed files with 30 additions and 12 deletions
|
|
@ -36,6 +36,7 @@ class ConversationContactOrSuggestionModel
|
|||
val conversationId: String = "",
|
||||
conversationSubject: String? = null,
|
||||
val friend: Friend? = null,
|
||||
val defaultAccountDomain: String? = null,
|
||||
private val onClicked: ((Address) -> Unit)? = null
|
||||
) {
|
||||
val id = friend?.refKey ?: address.asStringUriOnly().hashCode()
|
||||
|
|
@ -50,7 +51,13 @@ class ConversationContactOrSuggestionModel
|
|||
}
|
||||
|
||||
val sipUri = if (!corePreferences.hideSipAddresses) {
|
||||
address.asStringUriOnly()
|
||||
// Hide SIP address and only show username for suggestions
|
||||
// on the same domain as the currently selected account
|
||||
if (!defaultAccountDomain.isNullOrEmpty() && defaultAccountDomain == address.domain) {
|
||||
address.username
|
||||
} else {
|
||||
address.asStringUriOnly()
|
||||
}
|
||||
} else {
|
||||
address.username
|
||||
}
|
||||
|
|
|
|||
|
|
@ -316,6 +316,7 @@ abstract class AddressSelectionViewModel
|
|||
arrayListOf()
|
||||
}
|
||||
|
||||
val defaultAccountDomain = LinphoneUtils.getDefaultAccount()?.params?.domain
|
||||
val favoritesList = arrayListOf<ConversationContactOrSuggestionModel>()
|
||||
val domain = corePreferences.contactsFilter
|
||||
// Make a quick synchronous search for favorites (in case of total results exceed magic search limit to prevent missing ones)
|
||||
|
|
@ -370,6 +371,8 @@ abstract class AddressSelectionViewModel
|
|||
val model = ConversationContactOrSuggestionModel(address) {
|
||||
coreContext.startAudioCall(address)
|
||||
}
|
||||
val avatarModel = getContactAvatarModelForAddress(address)
|
||||
model.avatarModel.postValue(avatarModel)
|
||||
suggestionsList.add(model)
|
||||
continue
|
||||
}
|
||||
|
|
@ -380,10 +383,11 @@ abstract class AddressSelectionViewModel
|
|||
continue
|
||||
}
|
||||
|
||||
val model = ConversationContactOrSuggestionModel(address) {
|
||||
val model = ConversationContactOrSuggestionModel(address, defaultAccountDomain = defaultAccountDomain) {
|
||||
coreContext.startAudioCall(address)
|
||||
}
|
||||
|
||||
val avatarModel = getContactAvatarModelForAddress(address)
|
||||
model.avatarModel.postValue(avatarModel)
|
||||
suggestionsList.add(model)
|
||||
}
|
||||
}
|
||||
|
|
@ -573,4 +577,12 @@ abstract class AddressSelectionViewModel
|
|||
clearFilter()
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun getContactAvatarModelForAddress(address: Address): ContactAvatarModel {
|
||||
val fakeFriend = coreContext.core.createFriend()
|
||||
fakeFriend.name = LinphoneUtils.getDisplayName(address)
|
||||
fakeFriend.address = address
|
||||
return ContactAvatarModel(fakeFriend)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +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">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
|
|
@ -23,15 +23,14 @@
|
|||
android:paddingBottom="5dp"
|
||||
android:background="@drawable/primary_cell_background">
|
||||
|
||||
<ImageView
|
||||
style="@style/avatar_imageview"
|
||||
<include
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="@dimen/avatar_list_cell_size"
|
||||
android:layout_height="@dimen/avatar_list_cell_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:contentDescription="@null"
|
||||
coilInitials="@{model.initials, default=`JD`}"
|
||||
layout="@layout/contact_avatar"
|
||||
bind:model="@{model.avatarModel}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue