Fixed auth info requested dialog showing up after wrong password input in assistant + fixed default account not set in same scenario
This commit is contained in:
parent
ba1708beaa
commit
8df1d2218d
4 changed files with 42 additions and 16 deletions
|
@ -161,10 +161,19 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
||||||
fun removeInvalidProxyConfig() {
|
fun removeInvalidProxyConfig() {
|
||||||
val account = accountToCheck
|
val account = accountToCheck
|
||||||
account ?: return
|
account ?: return
|
||||||
|
|
||||||
|
val core = coreContext.core
|
||||||
val authInfo = account.findAuthInfo()
|
val authInfo = account.findAuthInfo()
|
||||||
if (authInfo != null) coreContext.core.removeAuthInfo(authInfo)
|
if (authInfo != null) core.removeAuthInfo(authInfo)
|
||||||
coreContext.core.removeAccount(account)
|
core.removeAccount(account)
|
||||||
accountToCheck = null
|
accountToCheck = null
|
||||||
|
|
||||||
|
// Make sure there is a valid default account
|
||||||
|
val accounts = core.accountList
|
||||||
|
if (accounts.isNotEmpty() && core.defaultAccount == null) {
|
||||||
|
core.defaultAccount = accounts.first()
|
||||||
|
core.refreshRegisters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun continueEvenIfInvalidCredentials() {
|
fun continueEvenIfInvalidCredentials() {
|
||||||
|
|
|
@ -108,10 +108,19 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
|
||||||
fun removeInvalidProxyConfig() {
|
fun removeInvalidProxyConfig() {
|
||||||
val account = accountToCheck
|
val account = accountToCheck
|
||||||
account ?: return
|
account ?: return
|
||||||
|
|
||||||
|
val core = coreContext.core
|
||||||
val authInfo = account.findAuthInfo()
|
val authInfo = account.findAuthInfo()
|
||||||
if (authInfo != null) coreContext.core.removeAuthInfo(authInfo)
|
if (authInfo != null) core.removeAuthInfo(authInfo)
|
||||||
coreContext.core.removeAccount(account)
|
core.removeAccount(account)
|
||||||
accountToCheck = null
|
accountToCheck = null
|
||||||
|
|
||||||
|
// Make sure there is a valid default account
|
||||||
|
val accounts = core.accountList
|
||||||
|
if (accounts.isNotEmpty() && core.defaultAccount == null) {
|
||||||
|
core.defaultAccount = accounts.first()
|
||||||
|
core.refreshRegisters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun continueEvenIfInvalidCredentials() {
|
fun continueEvenIfInvalidCredentials() {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import androidx.core.view.doOnAttach
|
import androidx.core.view.doOnAttach
|
||||||
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.DataBindingUtil
|
||||||
import androidx.fragment.app.FragmentContainerView
|
import androidx.fragment.app.FragmentContainerView
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
|
@ -59,6 +60,9 @@ import org.linphone.activities.navigateToDialer
|
||||||
import org.linphone.compatibility.Compatibility
|
import org.linphone.compatibility.Compatibility
|
||||||
import org.linphone.contact.ContactsUpdatedListenerStub
|
import org.linphone.contact.ContactsUpdatedListenerStub
|
||||||
import org.linphone.core.AuthInfo
|
import org.linphone.core.AuthInfo
|
||||||
|
import org.linphone.core.AuthMethod
|
||||||
|
import org.linphone.core.Core
|
||||||
|
import org.linphone.core.CoreListenerStub
|
||||||
import org.linphone.core.CorePreferences
|
import org.linphone.core.CorePreferences
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.databinding.MainActivityBinding
|
import org.linphone.databinding.MainActivityBinding
|
||||||
|
@ -109,6 +113,19 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
||||||
private var shouldTabsBeVisibleDependingOnDestination = true
|
private var shouldTabsBeVisibleDependingOnDestination = true
|
||||||
private var shouldTabsBeVisibleDueToOrientationAndKeyboard = true
|
private var shouldTabsBeVisibleDueToOrientationAndKeyboard = true
|
||||||
|
|
||||||
|
private val authenticationRequestedEvent: MutableLiveData<Event<AuthInfo>> by lazy {
|
||||||
|
MutableLiveData<Event<AuthInfo>>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val coreListener: CoreListenerStub = object : CoreListenerStub() {
|
||||||
|
override fun onAuthenticationRequested(core: Core, authInfo: AuthInfo, method: AuthMethod) {
|
||||||
|
Log.w(
|
||||||
|
"[Main Activity] Authentication requested for account [${authInfo.username}@${authInfo.domain}] with realm [${authInfo.realm}] using method [$method]"
|
||||||
|
)
|
||||||
|
authenticationRequestedEvent.value = Event(authInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -144,7 +161,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coreContext.authenticationRequestedEvent.observe(
|
authenticationRequestedEvent.observe(
|
||||||
this
|
this
|
||||||
) {
|
) {
|
||||||
it.consume { authInfo ->
|
it.consume { authInfo ->
|
||||||
|
@ -183,9 +200,11 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
coreContext.contactsManager.addListener(listener)
|
coreContext.contactsManager.addListener(listener)
|
||||||
|
coreContext.core.addListener(coreListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
coreContext.core.removeListener(coreListener)
|
||||||
coreContext.contactsManager.removeListener(listener)
|
coreContext.contactsManager.removeListener(listener)
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,10 +117,6 @@ class CoreContext(
|
||||||
MutableLiveData<Event<String>>()
|
MutableLiveData<Event<String>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
val authenticationRequestedEvent: MutableLiveData<Event<AuthInfo>> by lazy {
|
|
||||||
MutableLiveData<Event<AuthInfo>>()
|
|
||||||
}
|
|
||||||
|
|
||||||
val coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
val coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
||||||
|
|
||||||
private val loggingService = Factory.instance().loggingService
|
private val loggingService = Factory.instance().loggingService
|
||||||
|
@ -169,13 +165,6 @@ class CoreContext(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAuthenticationRequested(core: Core, authInfo: AuthInfo, method: AuthMethod) {
|
|
||||||
Log.w(
|
|
||||||
"[Context] Authentication requested for account [${authInfo.username}@${authInfo.domain}] with realm [${authInfo.realm}] using method [$method]"
|
|
||||||
)
|
|
||||||
authenticationRequestedEvent.value = Event(authInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPushNotificationReceived(core: Core, payload: String?) {
|
override fun onPushNotificationReceived(core: Core, payload: String?) {
|
||||||
Log.i("[Context] Push notification received: $payload")
|
Log.i("[Context] Push notification received: $payload")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue