Updated navigation & other views when switching default account

This commit is contained in:
Sylvain Berfini 2023-10-03 16:25:26 +02:00
parent 78dd449baf
commit 528855c5d5
5 changed files with 41 additions and 12 deletions

View file

@ -100,5 +100,10 @@ class BottomNavBarFragment : Fragment() {
viewModel.resetMissedCallsCount()
}
}
sharedViewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
// Do not consume it!
viewModel.updateAvailableMenus()
}
}
}

View file

@ -180,6 +180,11 @@ class StartCallFragment : GenericFragment() {
viewModel.isNumpadVisible.value = false
}
}
sharedViewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
// Do not consume it!
viewModel.updateGroupCallButtonVisibility()
}
}
override fun onPause() {

View file

@ -58,6 +58,8 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
val isNumpadVisible = MutableLiveData<Boolean>()
val isGroupCallAvailable = MutableLiveData<Boolean>()
val appendDigitToSearchBarEvent: MutableLiveData<Event<String>> by lazy {
MutableLiveData<Event<String>>()
}
@ -127,15 +129,12 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
}
)
updateGroupCallButtonVisibility()
coreContext.postOnCoreThread { core ->
val defaultAccount = core.defaultAccount
limitSearchToLinphoneAccounts = defaultAccount?.isInSecureMode() ?: false
val hideGroupCall = corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
core
)
hideGroupCallButton.postValue(hideGroupCall)
coreContext.contactsManager.addListener(contactsListener)
magicSearch = core.createMagicSearch()
magicSearch.limitedSearch = false
@ -159,6 +158,16 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
searchFilter.value = ""
}
@UiThread
fun updateGroupCallButtonVisibility() {
coreContext.postOnCoreThread { core ->
val hideGroupCall = corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
core
)
hideGroupCallButton.postValue(hideGroupCall)
}
}
@UiThread
fun switchBetweenKeyboardAndNumpad() {
val showKeyboard = isNumpadVisible.value == true

View file

@ -92,6 +92,8 @@ open class AbstractTopBarViewModel @UiThread constructor() : ViewModel() {
if (core.accountList.isNotEmpty()) {
Log.i("$TAG Updating displayed default account")
val defaultAccount = core.defaultAccount ?: core.accountList.first()
account.value?.destroy()
account.postValue(AccountModel(defaultAccount))
}
}

View file

@ -68,14 +68,9 @@ class BottomNavBarViewModel @UiThread constructor() : ViewModel() {
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
updateMissedCallsCount()
hideConversations.postValue(corePreferences.disableChat)
val hideGroupCall = corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
core
)
hideMeetings.postValue(hideGroupCall)
}
updateAvailableMenus()
}
@UiThread
@ -106,4 +101,17 @@ class BottomNavBarViewModel @UiThread constructor() : ViewModel() {
updateMissedCallsCount()
}
}
@UiThread
fun updateAvailableMenus() {
coreContext.postOnCoreThread { core ->
hideConversations.postValue(corePreferences.disableChat)
val hideGroupCall =
corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
core
)
hideMeetings.postValue(hideGroupCall)
}
}
}