Added setting to replace SIP URIs by username
This commit is contained in:
parent
b236c627b7
commit
5321918b2d
13 changed files with 33 additions and 10 deletions
|
@ -33,6 +33,7 @@ import org.linphone.core.Call
|
|||
import org.linphone.core.CallListenerStub
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class CallViewModelFactory(private val call: Call) :
|
||||
ViewModelProvider.NewInstanceFactory() {
|
||||
|
@ -46,7 +47,7 @@ class CallViewModelFactory(private val call: Call) :
|
|||
open class CallViewModel(val call: Call) : GenericContactViewModel(call.remoteAddress) {
|
||||
val address: String by lazy {
|
||||
call.remoteAddress.clean() // To remove gruu if any
|
||||
call.remoteAddress.asStringUriOnly()
|
||||
LinphoneUtils.getDisplayableAddress(call.remoteAddress)
|
||||
}
|
||||
|
||||
val isPaused = MutableLiveData<Boolean>()
|
||||
|
|
|
@ -48,7 +48,7 @@ class ChatRoomCreationContactViewModel(private val searchResult: SearchResult) :
|
|||
}
|
||||
|
||||
val sipUri: String by lazy {
|
||||
searchResult.phoneNumber ?: searchResult.address?.asStringUriOnly() ?: ""
|
||||
searchResult.phoneNumber ?: LinphoneUtils.getDisplayableAddress(searchResult.address)
|
||||
}
|
||||
|
||||
val address: Address? by lazy {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.linphone.R
|
|||
import org.linphone.contact.GenericContactViewModel
|
||||
import org.linphone.core.ChatRoomSecurityLevel
|
||||
import org.linphone.core.Participant
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class DevicesListGroupViewModel(private val participant: Participant) : GenericContactViewModel(participant.address) {
|
||||
override val securityLevel: ChatRoomSecurityLevel
|
||||
|
@ -48,7 +49,7 @@ class DevicesListGroupViewModel(private val participant: Participant) : GenericC
|
|||
}
|
||||
}
|
||||
|
||||
val sipUri: String = participant.address.asStringUriOnly()
|
||||
val sipUri: String get() = LinphoneUtils.getDisplayableAddress(participant.address)
|
||||
|
||||
val isExpanded = MutableLiveData<Boolean>()
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@ import androidx.lifecycle.MutableLiveData
|
|||
import org.linphone.activities.main.chat.GroupChatRoomMember
|
||||
import org.linphone.contact.GenericContactViewModel
|
||||
import org.linphone.core.ChatRoomSecurityLevel
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class GroupInfoParticipantViewModel(private val participant: GroupChatRoomMember) : GenericContactViewModel(participant.address) {
|
||||
override val securityLevel: ChatRoomSecurityLevel
|
||||
get() = participant.securityLevel
|
||||
|
||||
val sipUri: String = participant.address.asStringUriOnly()
|
||||
val sipUri: String get() = LinphoneUtils.getDisplayableAddress(participant.address)
|
||||
|
||||
val isAdmin = MutableLiveData<Boolean>()
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.linphone.activities.main.dialer.NumpadDigitListener
|
|||
import org.linphone.core.*
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.LogsUploadViewModel
|
||||
|
||||
class DialerViewModel : LogsUploadViewModel() {
|
||||
|
@ -183,7 +184,7 @@ class DialerViewModel : LogsUploadViewModel() {
|
|||
private fun setLastOutgoingCallAddress() {
|
||||
val callLog = coreContext.core.lastOutgoingCallLog
|
||||
if (callLog != null) {
|
||||
enteredUri.value = callLog.remoteAddress.asStringUriOnly()
|
||||
enteredUri.value = LinphoneUtils.getDisplayableAddress(callLog.remoteAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class CallLogViewModelFactory(private val callLog: CallLog) :
|
|||
class CallLogViewModel(val callLog: CallLog) : GenericContactViewModel(callLog.remoteAddress) {
|
||||
val peerSipUri: String by lazy {
|
||||
callLog.remoteAddress.clean() // To remove gruu if any
|
||||
callLog.remoteAddress.asStringUriOnly()
|
||||
LinphoneUtils.getDisplayableAddress(callLog.remoteAddress)
|
||||
}
|
||||
|
||||
val statusIconResource: Int by lazy {
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.lang.NumberFormatException
|
|||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.main.settings.SettingListenerStub
|
||||
import org.linphone.core.*
|
||||
|
@ -65,6 +66,8 @@ class AccountSettingsViewModel(val proxyConfig: ProxyConfig) : GenericSettingsVi
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val displayUsernameInsteadOfIdentity = corePreferences.replaceSipUriByUsername
|
||||
|
||||
private var proxyConfigToDelete: ProxyConfig? = null
|
||||
|
||||
val listener: CoreListenerStub = object : CoreListenerStub() {
|
||||
|
|
|
@ -68,6 +68,12 @@ class CorePreferences constructor(private val context: Context) {
|
|||
config.setBool("app", "full_screen_activities", value)
|
||||
}
|
||||
|
||||
var replaceSipUriByUsername: Boolean
|
||||
get() = config.getBool("app", "replace_sip_uri_by_username", false)
|
||||
set(value) {
|
||||
config.setBool("app", "replace_sip_uri_by_username", value)
|
||||
}
|
||||
|
||||
/** -1 means auto, 0 no, 1 yes */
|
||||
var darkMode: Int
|
||||
get() {
|
||||
|
|
|
@ -342,7 +342,7 @@ class NotificationsManager(private val context: Context) {
|
|||
}
|
||||
|
||||
private fun displayIncomingCallNotification(call: Call, useAsForeground: Boolean = false) {
|
||||
val address = call.remoteAddress.asStringUriOnly()
|
||||
val address = LinphoneUtils.getDisplayableAddress(call.remoteAddress)
|
||||
val notifiable = getNotifiableForCall(call)
|
||||
|
||||
if (notifiable.notificationId == currentForegroundServiceNotificationId) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.text.DateFormat
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.core.*
|
||||
import org.linphone.core.tools.Log
|
||||
|
@ -43,6 +44,15 @@ class LinphoneUtils {
|
|||
return address.displayName ?: address.username ?: ""
|
||||
}
|
||||
|
||||
fun getDisplayableAddress(address: Address?): String {
|
||||
if (address == null) return "[null]"
|
||||
return if (corePreferences.replaceSipUriByUsername) {
|
||||
address.username ?: address.asStringUriOnly()
|
||||
} else {
|
||||
address.asStringUriOnly()
|
||||
}
|
||||
}
|
||||
|
||||
fun isLimeAvailable(): Boolean {
|
||||
val core = coreContext.core
|
||||
return core.limeX3DhAvailable() && core.limeX3DhEnabled() &&
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
<org.linphone.views.MarqueeTextView
|
||||
android:id="@+id/settings_title"
|
||||
android:text="@{data.identity}"
|
||||
android:text="@{data.displayUsernameInsteadOfIdentity ? data.userName : data.identity}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:text="@{data.identity}"
|
||||
android:text="@{data.displayUsernameInsteadOfIdentity ? data.userName : data.identity}"
|
||||
style="@style/assistant_input_field_header_font"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
|
||||
<TextView
|
||||
android:visibility="@{viewModel.defaultAccountFound ? View.VISIBLE : View.GONE}"
|
||||
android:text="@{viewModel.defaultAccount.identity}"
|
||||
android:text="@{viewModel.defaultAccount.displayUsernameInsteadOfIdentity ? viewModel.defaultAccount.userName : viewModel.defaultAccount.identity}"
|
||||
style="@style/sip_uri_small_font"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
|
Loading…
Reference in a new issue