Should fix quit button visibility in drawer menu

This commit is contained in:
Sylvain Berfini 2025-03-17 16:09:23 +01:00
parent 9837a834d4
commit b5a1e21f40
5 changed files with 35 additions and 1 deletions

View file

@ -170,6 +170,14 @@ class DrawerMenuFragment : GenericMainFragment() {
}
}
}
sharedViewModel.refreshDrawerMenuQuitButtonEvent.observe(viewLifecycleOwner) {
it.consume {
coreContext.postOnCoreThread {
viewModel.checkIfKeepAliveServiceIsEnabled()
}
}
}
}
private fun showAccountPopupMenu(view: View, account: Account) {

View file

@ -32,6 +32,7 @@ import org.linphone.databinding.SettingsAdvancedFragmentBinding
import org.linphone.ui.GenericActivity
import org.linphone.ui.main.fragment.GenericMainFragment
import org.linphone.ui.main.settings.viewmodel.SettingsViewModel
import org.linphone.utils.Event
@UiThread
class SettingsAdvancedFragment : GenericMainFragment() {
@ -105,6 +106,12 @@ class SettingsAdvancedFragment : GenericMainFragment() {
setupOutputAudioDevicePicker()
}
viewModel.keepAliveServiceSettingChangedEvent.observe(viewLifecycleOwner) {
it.consume {
sharedViewModel.refreshDrawerMenuQuitButtonEvent.postValue(Event(true))
}
}
startPostponedEnterTransition()
}

View file

@ -64,6 +64,10 @@ class SettingsViewModel
MutableLiveData<Event<Boolean>>()
}
val keepAliveServiceSettingChangedEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
// Security settings
val isVfsEnabled = MutableLiveData<Boolean>()
@ -689,6 +693,7 @@ class SettingsViewModel
} else {
coreContext.stopKeepAliveService()
}
keepAliveServiceSettingChangedEvent.postValue(Event(true))
}
}

View file

@ -126,7 +126,8 @@ class DrawerMenuViewModel
hideRecordings.postValue(corePreferences.disableCallRecordings)
hideSettings.postValue(corePreferences.hideSettings)
hideQuitButton.postValue(!corePreferences.keepServiceAlive)
checkIfKeepAliveServiceIsEnabled()
computeAccountsList()
computeShortcuts()
@ -169,6 +170,15 @@ class DrawerMenuViewModel
}
}
@WorkerThread
fun checkIfKeepAliveServiceIsEnabled() {
val useKeepAliveService = corePreferences.keepServiceAlive
hideQuitButton.postValue(!useKeepAliveService)
if (useKeepAliveService) {
Log.i("$TAG Keep alive service is enabled, do not hide quit button")
}
}
@WorkerThread
private fun computeAccountsList() {
accounts.value.orEmpty().forEach(AccountModel::destroy)

View file

@ -74,6 +74,10 @@ class SharedMainViewModel
MutableLiveData<Event<Boolean>>()
}
val refreshDrawerMenuQuitButtonEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
val forceUpdateAvailableNavigationItems: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}