mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Improved Linphone login adding automatically default domain to username if not entered by user
This commit is contained in:
parent
6ceee7fdb7
commit
9c855ef923
1 changed files with 19 additions and 2 deletions
|
|
@ -132,8 +132,22 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
coreContext.postOnCoreThread { core ->
|
||||
core.loadConfigFromXml(corePreferences.linphoneDefaultValuesPath)
|
||||
|
||||
val identity = sipIdentity.value.orEmpty().trim()
|
||||
val identityAddress = core.interpretUrl(identity, false)
|
||||
val userInput = sipIdentity.value.orEmpty().trim()
|
||||
val defaultDomain = corePreferences.defaultDomain
|
||||
val identity = if (userInput.startsWith("sip:")) {
|
||||
if (userInput.contains("@")) {
|
||||
userInput
|
||||
} else {
|
||||
"$userInput@$defaultDomain"
|
||||
}
|
||||
} else {
|
||||
if (userInput.contains("@")) {
|
||||
"sip:$userInput"
|
||||
} else {
|
||||
"sip:$userInput@$defaultDomain"
|
||||
}
|
||||
}
|
||||
val identityAddress = Factory.instance().createAddress(identity)
|
||||
if (identityAddress == null) {
|
||||
Log.e("$TAG Can't parse [$identity] as Address!")
|
||||
// TODO: show error
|
||||
|
|
@ -185,6 +199,9 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
registrationInProgress.postValue(true)
|
||||
core.addListener(coreListener)
|
||||
Log.i(
|
||||
"$TAG Trying to log in account with SIP identity [${identityAddress.asStringUriOnly()}]"
|
||||
)
|
||||
core.addAccount(newlyCreatedAccount)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue