mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-23 06:38:09 +00:00
Prevent staying in assistant when logging in if login was denied once due to invalid password
This commit is contained in:
parent
b301a5227a
commit
fb9d1c5c0d
2 changed files with 26 additions and 0 deletions
|
|
@ -317,6 +317,8 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
|
||||
override fun onPause() {
|
||||
viewModel.enableAccountMonitoring(false)
|
||||
|
||||
currentlyDisplayedAuthDialog?.dismiss()
|
||||
currentlyDisplayedAuthDialog = null
|
||||
|
||||
|
|
@ -349,6 +351,7 @@ class MainActivity : GenericActivity() {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
viewModel.enableAccountMonitoring(true)
|
||||
viewModel.checkForNewAccount()
|
||||
viewModel.updateNetworkReachability()
|
||||
viewModel.updatePostNotificationsPermission()
|
||||
|
|
|
|||
|
|
@ -118,6 +118,8 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
private var firstAccountRegistered: Boolean = false
|
||||
|
||||
private var monitorAccount = false
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onGlobalStateChanged(core: Core, state: GlobalState?, message: String) {
|
||||
|
|
@ -192,6 +194,8 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
state: RegistrationState?,
|
||||
message: String
|
||||
) {
|
||||
if (!monitorAccount) return
|
||||
|
||||
when (state) {
|
||||
RegistrationState.Failed -> {
|
||||
if (account == core.defaultAccount) {
|
||||
|
|
@ -244,6 +248,8 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
@WorkerThread
|
||||
override fun onDefaultAccountChanged(core: Core, account: Account?) {
|
||||
if (!monitorAccount) return
|
||||
|
||||
if (account == null) {
|
||||
Log.w("$TAG Default account is now null!")
|
||||
} else {
|
||||
|
|
@ -262,6 +268,8 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
@WorkerThread
|
||||
override fun onAccountRemoved(core: Core, account: Account) {
|
||||
if (!monitorAccount) return
|
||||
|
||||
Log.w(
|
||||
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] has been removed!"
|
||||
)
|
||||
|
|
@ -280,6 +288,7 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
defaultAccountRegistrationFailed = false
|
||||
showAlert.value = false
|
||||
maxAlertLevel.value = NONE
|
||||
enableAccountMonitoring(true)
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
accountsFound = core.accountList.size
|
||||
|
|
@ -377,6 +386,20 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun enableAccountMonitoring(enable: Boolean) {
|
||||
if (enable != monitorAccount) {
|
||||
monitorAccount = enable
|
||||
Log.i(
|
||||
"$TAG Account monitoring is now [${if (monitorAccount) "enabled" else "disabled"}]"
|
||||
)
|
||||
} else {
|
||||
Log.i(
|
||||
"$TAG Account monitoring is already [${if (monitorAccount) "enabled" else "disabled"}], nothing to do"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun computeNonDefaultAccountNotificationsCount() {
|
||||
var count = 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue