mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-28 00:59:19 +00:00
Fixed some scenario where account(s) reload isn't done
This commit is contained in:
parent
8c1889b181
commit
e292b0d7e8
3 changed files with 29 additions and 17 deletions
|
|
@ -28,9 +28,9 @@ import org.linphone.core.Account
|
||||||
import org.linphone.core.Call
|
import org.linphone.core.Call
|
||||||
import org.linphone.core.ChatMessage
|
import org.linphone.core.ChatMessage
|
||||||
import org.linphone.core.ChatRoom
|
import org.linphone.core.ChatRoom
|
||||||
import org.linphone.core.ConfiguringState
|
|
||||||
import org.linphone.core.Core
|
import org.linphone.core.Core
|
||||||
import org.linphone.core.CoreListenerStub
|
import org.linphone.core.CoreListenerStub
|
||||||
|
import org.linphone.core.GlobalState
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.GenericViewModel
|
import org.linphone.ui.GenericViewModel
|
||||||
import org.linphone.ui.main.model.AccountModel
|
import org.linphone.ui.main.model.AccountModel
|
||||||
|
|
@ -139,18 +139,10 @@ open class AbstractMainViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
override fun onConfiguringStatus(core: Core, status: ConfiguringState?, message: String?) {
|
override fun onGlobalStateChanged(core: Core, state: GlobalState?, message: String) {
|
||||||
if (status != ConfiguringState.Skipped) {
|
if (core.globalState == GlobalState.On) {
|
||||||
account.value?.destroy()
|
Log.i("$TAG Global state is [${core.globalState}], reload account info")
|
||||||
|
configure()
|
||||||
val defaultAccount = core.defaultAccount
|
|
||||||
if (defaultAccount != null) {
|
|
||||||
Log.i("$TAG Configuring status is [$status], reload default account")
|
|
||||||
account.postValue(AccountModel(defaultAccount))
|
|
||||||
defaultAccountChangedEvent.postValue(Event(true))
|
|
||||||
} else {
|
|
||||||
Log.w("$TAG Configuring status is [$status] but no default account was found!")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,16 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.core.Account
|
import org.linphone.core.Account
|
||||||
import org.linphone.core.Core
|
import org.linphone.core.Core
|
||||||
import org.linphone.core.CoreListenerStub
|
import org.linphone.core.CoreListenerStub
|
||||||
|
import org.linphone.core.GlobalState
|
||||||
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.GenericViewModel
|
import org.linphone.ui.GenericViewModel
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
|
||||||
open class DefaultAccountChangedViewModel : GenericViewModel() {
|
open class DefaultAccountChangedViewModel : GenericViewModel() {
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "[Default Account Changed ViewModel]"
|
||||||
|
}
|
||||||
|
|
||||||
val defaultAccountChangedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
val defaultAccountChangedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||||
MutableLiveData<Event<Boolean>>()
|
MutableLiveData<Event<Boolean>>()
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +44,14 @@ open class DefaultAccountChangedViewModel : GenericViewModel() {
|
||||||
override fun onDefaultAccountChanged(core: Core, account: Account?) {
|
override fun onDefaultAccountChanged(core: Core, account: Account?) {
|
||||||
defaultAccountChangedEvent.postValue(Event(true))
|
defaultAccountChangedEvent.postValue(Event(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
override fun onGlobalStateChanged(core: Core, state: GlobalState?, message: String) {
|
||||||
|
if (core.globalState == GlobalState.On) {
|
||||||
|
Log.i("$TAG Global state is [${core.globalState}], reload default account")
|
||||||
|
defaultAccountChangedEvent.postValue(Event(true))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.core.Account
|
import org.linphone.core.Account
|
||||||
import org.linphone.core.ConfiguringState
|
|
||||||
import org.linphone.core.Core
|
import org.linphone.core.Core
|
||||||
import org.linphone.core.CoreListenerStub
|
import org.linphone.core.CoreListenerStub
|
||||||
|
import org.linphone.core.GlobalState
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.ui.GenericViewModel
|
import org.linphone.ui.GenericViewModel
|
||||||
import org.linphone.ui.main.model.AccountModel
|
import org.linphone.ui.main.model.AccountModel
|
||||||
|
|
@ -109,11 +109,11 @@ class DrawerMenuViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
override fun onConfiguringStatus(core: Core, status: ConfiguringState?, message: String?) {
|
override fun onGlobalStateChanged(core: Core, state: GlobalState?, message: String) {
|
||||||
if (status != ConfiguringState.Skipped) {
|
if (core.globalState == GlobalState.On) {
|
||||||
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
||||||
|
|
||||||
Log.i("$TAG Configuring status is [$status], reload accounts & shortcuts")
|
Log.i("$TAG Global state is [${core.globalState}], reload accounts & shortcuts")
|
||||||
computeAccountsList()
|
computeAccountsList()
|
||||||
computeShortcuts()
|
computeShortcuts()
|
||||||
}
|
}
|
||||||
|
|
@ -180,6 +180,12 @@ class DrawerMenuViewModel
|
||||||
showAccountPopupMenuEvent.postValue(Event(Pair(view, account)))
|
showAccountPopupMenuEvent.postValue(Event(Pair(view, account)))
|
||||||
}
|
}
|
||||||
list.add(model)
|
list.add(model)
|
||||||
|
|
||||||
|
if (account == coreContext.core.defaultAccount) {
|
||||||
|
defaultAccountChangedEvent.postValue(
|
||||||
|
Event(account.params.identityAddress?.asStringUriOnly() ?: "")
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
accounts.postValue(list)
|
accounts.postValue(list)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue