Improved parsing of account settings + navigate out of resuming fragment if no longer available due to config changes

This commit is contained in:
Sylvain Berfini 2024-02-26 15:58:15 +01:00
parent dce27530e0
commit 7ba19364b9
6 changed files with 39 additions and 6 deletions

View file

@ -309,6 +309,13 @@ class ConversationsListFragment : AbstractTopBarFragment() {
override fun onResume() {
super.onResume()
if (listViewModel.hideMeetings.value == true) {
Log.w(
"$TAG Resuming fragment that should no longer be accessible, going to contacts list instead"
)
sharedViewModel.navigateToContactsEvent.value = Event(true)
}
try {
adapter.registerAdapterDataObserver(dataObserver)
} catch (e: IllegalStateException) {

View file

@ -167,6 +167,12 @@ abstract class AbstractTopBarFragment : GenericFragment() {
viewModel.resetMissedCallsCount()
}
}
sharedViewModel.forceUpdateAvailableNavigationItems.observe(viewLifecycleOwner) {
it.consume {
viewModel.updateAvailableMenus()
}
}
}
fun initBottomNavBar(navBar: View) {

View file

@ -39,6 +39,7 @@ import org.linphone.ui.main.fragment.AbstractTopBarFragment
import org.linphone.ui.main.meetings.adapter.MeetingsListAdapter
import org.linphone.ui.main.meetings.viewmodel.MeetingsListViewModel
import org.linphone.utils.AppUtils
import org.linphone.utils.Event
import org.linphone.utils.RecyclerViewHeaderDecoration
@UiThread
@ -219,6 +220,17 @@ class MeetingsListFragment : AbstractTopBarFragment() {
bottomSheetDialog = null
}
override fun onResume() {
super.onResume()
if (listViewModel.hideMeetings.value == true) {
Log.w(
"$TAG Resuming fragment that should no longer be accessible, going to contacts list instead"
)
sharedViewModel.navigateToContactsEvent.value = Event(true)
}
}
private fun scrollToToday() {
val todayMeeting = listViewModel.meetings.value.orEmpty().find {
it.isToday

View file

@ -18,6 +18,7 @@ import org.linphone.core.tools.Log
import org.linphone.databinding.AccountSettingsFragmentBinding
import org.linphone.ui.main.fragment.GenericFragment
import org.linphone.ui.main.settings.viewmodel.AccountSettingsViewModel
import org.linphone.utils.Event
@UiThread
class AccountSettingsFragment : GenericFragment() {
@ -113,5 +114,7 @@ class AccountSettingsFragment : GenericFragment() {
super.onPause()
viewModel.saveChanges()
// It is possible some value have changed, causing some menu to appear or disappear
sharedViewModel.forceUpdateAvailableNavigationItems.value = Event(true)
}
}

View file

@ -26,7 +26,6 @@ import java.util.Locale
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.AVPFMode
import org.linphone.core.Account
import org.linphone.core.Factory
import org.linphone.core.NatPolicy
import org.linphone.core.TransportType
import org.linphone.core.tools.Log
@ -122,7 +121,7 @@ class AccountSettingsViewModel @UiThread constructor() : ViewModel() {
val server = sipProxyServer.value.orEmpty()
if (server.isNotEmpty()) {
val serverAddress = Factory.instance().createAddress(server)
val serverAddress = core.interpretUrl(server, false)
if (serverAddress != null) {
serverAddress.transport = selectedTransport.value
newParams.serverAddress = serverAddress
@ -142,13 +141,15 @@ class AccountSettingsViewModel @UiThread constructor() : ViewModel() {
newParams.expires = expire.value?.toInt() ?: 31536000
val conferenceFactoryAddress = Factory.instance().createAddress(
conferenceFactoryUri.value.orEmpty()
val conferenceFactoryAddress = core.interpretUrl(
conferenceFactoryUri.value.orEmpty(),
false
)
newParams.conferenceFactoryAddress = conferenceFactoryAddress
val audioVideoConferenceFactoryAddress = Factory.instance().createAddress(
audioVideoConferenceFactoryUri.value.orEmpty()
val audioVideoConferenceFactoryAddress = core.interpretUrl(
audioVideoConferenceFactoryUri.value.orEmpty(),
false
)
newParams.audioVideoConferenceFactoryAddress = audioVideoConferenceFactoryAddress

View file

@ -69,6 +69,10 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<Boolean>>()
}
val forceUpdateAvailableNavigationItems: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
/* Contacts related */
val showContactEvent: MutableLiveData<Event<String>> by lazy {