diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt index 43052f0fd..cd1f14594 100644 --- a/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/LandingFragment.kt @@ -86,8 +86,11 @@ class LandingFragment : GenericFragment() { } binding.setQrCodeClickListener { - val action = LandingFragmentDirections.actionLandingFragmentToQrCodeScannerFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.landingFragment) { + val action = + LandingFragmentDirections.actionLandingFragmentToQrCodeScannerFragment() + findNavController().navigate(action) + } } binding.setThirdPartySipAccountLoginClickListener { @@ -151,17 +154,21 @@ class LandingFragment : GenericFragment() { } private fun goToRegisterFragment() { - val action = LandingFragmentDirections.actionLandingFragmentToRegisterFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.landingFragment) { + val action = LandingFragmentDirections.actionLandingFragmentToRegisterFragment() + findNavController().navigate(action) + } } private fun goToLoginThirdPartySipAccountFragment(skipWarning: Boolean) { - val action = if (skipWarning) { - LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountLoginFragment() - } else { - LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountWarningFragment() + if (findNavController().currentDestination?.id == R.id.landingFragment) { + val action = if (skipWarning) { + LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountLoginFragment() + } else { + LandingFragmentDirections.actionLandingFragmentToThirdPartySipAccountWarningFragment() + } + findNavController().navigate(action) } - findNavController().navigate(action) } private fun showAcceptConditionsAndPrivacyDialog( diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/RegisterFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/RegisterFragment.kt index 6682821e6..13e3def7e 100644 --- a/app/src/main/java/org/linphone/ui/assistant/fragment/RegisterFragment.kt +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/RegisterFragment.kt @@ -156,8 +156,11 @@ class RegisterFragment : GenericFragment() { viewModel.goToSmsCodeConfirmationViewEvent.observe(viewLifecycleOwner) { it.consume { Log.i("$TAG Going to SMS code confirmation fragment") - val action = RegisterFragmentDirections.actionRegisterFragmentToRegisterCodeConfirmationFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.registerFragment) { + val action = + RegisterFragmentDirections.actionRegisterFragmentToRegisterCodeConfirmationFragment() + findNavController().navigate(action) + } } } diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountLoginFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountLoginFragment.kt index 09c90c40d..72cb21e99 100644 --- a/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountLoginFragment.kt +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountLoginFragment.kt @@ -135,11 +135,13 @@ class ThirdPartySipAccountLoginFragment : GenericFragment() { Log.i( "$TAG Navigating to Single Sign On Fragment with server URL [$serverUrl] and username [$username]" ) - val action = SingleSignOnFragmentDirections.actionGlobalSingleSignOnFragment( - serverUrl, - username - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.thirdPartySipAccountLoginFragment) { + val action = SingleSignOnFragmentDirections.actionGlobalSingleSignOnFragment( + serverUrl, + username + ) + findNavController().navigate(action) + } } } diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt index b14aae62c..e5c958320 100644 --- a/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt @@ -71,13 +71,19 @@ class ThirdPartySipAccountWarningFragment : GenericFragment() { } binding.setCreateAccountClickListener { - val action = ThirdPartySipAccountWarningFragmentDirections.actionThirdPartySipAccountWarningFragmentToRegisterFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.thirdPartySipAccountWarningFragment) { + val action = + ThirdPartySipAccountWarningFragmentDirections.actionThirdPartySipAccountWarningFragmentToRegisterFragment() + findNavController().navigate(action) + } } binding.setLoginClickListener { - val action = ThirdPartySipAccountWarningFragmentDirections.actionThirdPartySipAccountWarningFragmentToThirdPartySipAccountLoginFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.thirdPartySipAccountWarningFragment) { + val action = + ThirdPartySipAccountWarningFragmentDirections.actionThirdPartySipAccountWarningFragmentToThirdPartySipAccountLoginFragment() + findNavController().navigate(action) + } } } diff --git a/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt b/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt index e024a2634..78dbd249d 100644 --- a/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt @@ -284,14 +284,20 @@ class ActiveConferenceCallFragment : GenericCallFragment() { binding.setCallsListClickListener { Log.i("$TAG Going to calls list fragment") - val action = ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToCallsListFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.activeConferenceCallFragment) { + val action = + ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToCallsListFragment() + findNavController().navigate(action) + } } binding.setParticipantsListClickListener { Log.i("$TAG Going to conference participants list fragment") - val action = ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToConferenceParticipantsListFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.activeConferenceCallFragment) { + val action = + ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToConferenceParticipantsListFragment() + findNavController().navigate(action) + } } binding.setShareConferenceClickListener { diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt index 33e3ee2df..460a512d8 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/ActiveCallFragment.kt @@ -214,18 +214,27 @@ class ActiveCallFragment : GenericCallFragment() { } binding.setTransferCallClickListener { - val action = ActiveCallFragmentDirections.actionActiveCallFragmentToTransferCallFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.activeCallFragment) { + val action = + ActiveCallFragmentDirections.actionActiveCallFragmentToTransferCallFragment() + findNavController().navigate(action) + } } binding.setNewCallClickListener { - val action = ActiveCallFragmentDirections.actionActiveCallFragmentToNewCallFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.activeCallFragment) { + val action = + ActiveCallFragmentDirections.actionActiveCallFragmentToNewCallFragment() + findNavController().navigate(action) + } } binding.setCallsListClickListener { - val action = ActiveCallFragmentDirections.actionActiveCallFragmentToCallsListFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.activeCallFragment) { + val action = + ActiveCallFragmentDirections.actionActiveCallFragmentToCallsListFragment() + findNavController().navigate(action) + } } binding.setCallStatisticsClickListener { diff --git a/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt b/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt index 5080f47a7..41daac90b 100644 --- a/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/help/fragment/HelpFragment.kt @@ -69,8 +69,10 @@ class HelpFragment : GenericMainFragment() { } binding.setDebugClickListener { - val action = HelpFragmentDirections.actionHelpFragmentToDebugFragment() - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.helpFragment) { + val action = HelpFragmentDirections.actionHelpFragmentToDebugFragment() + findNavController().navigate(action) + } } binding.setPrivacyPolicyClickListener { diff --git a/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingFragment.kt b/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingFragment.kt index 0e176bea0..cf7000753 100644 --- a/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingFragment.kt @@ -127,10 +127,13 @@ class MeetingFragment : SlidingPaneChildFragment() { Log.i( "$TAG Navigating to meeting edit fragment with conference URI [$conferenceUri]" ) - val action = MeetingFragmentDirections.actionMeetingFragmentToEditMeetingFragment( - conferenceUri - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.meetingFragment) { + val action = + MeetingFragmentDirections.actionMeetingFragmentToEditMeetingFragment( + conferenceUri + ) + findNavController().navigate(action) + } } } diff --git a/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingsListFragment.kt b/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingsListFragment.kt index 1b3c07408..f591e3637 100644 --- a/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingsListFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/meetings/fragment/MeetingsListFragment.kt @@ -143,9 +143,11 @@ class MeetingsListFragment : AbstractMainFragment() { Log.w("$TAG Meeting with ID [${model.id}] is cancelled, can't show the details") } else { Log.i("$TAG Show meeting with ID [${model.id}]") - sharedViewModel.displayedMeeting = model.conferenceInfo - val action = MeetingFragmentDirections.actionGlobalMeetingFragment(model.id) - binding.meetingsNavContainer.findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.meetingsListFragment) { + sharedViewModel.displayedMeeting = model.conferenceInfo + val action = MeetingFragmentDirections.actionGlobalMeetingFragment(model.id) + binding.meetingsNavContainer.findNavController().navigate(action) + } } } } diff --git a/app/src/main/java/org/linphone/ui/main/settings/fragment/SettingsFragment.kt b/app/src/main/java/org/linphone/ui/main/settings/fragment/SettingsFragment.kt index e363b3b55..812c420d4 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/fragment/SettingsFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/fragment/SettingsFragment.kt @@ -155,37 +155,49 @@ class SettingsFragment : GenericMainFragment() { viewModel.addLdapServerEvent.observe(viewLifecycleOwner) { it.consume { - val action = SettingsFragmentDirections.actionSettingsFragmentToLdapServerConfigurationFragment( - null - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.settingsFragment) { + val action = + SettingsFragmentDirections.actionSettingsFragmentToLdapServerConfigurationFragment( + null + ) + findNavController().navigate(action) + } } } viewModel.editLdapServerEvent.observe(viewLifecycleOwner) { it.consume { name -> - val action = SettingsFragmentDirections.actionSettingsFragmentToLdapServerConfigurationFragment( - name - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.settingsFragment) { + val action = + SettingsFragmentDirections.actionSettingsFragmentToLdapServerConfigurationFragment( + name + ) + findNavController().navigate(action) + } } } viewModel.addCardDavServerEvent.observe(viewLifecycleOwner) { it.consume { - val action = SettingsFragmentDirections.actionSettingsFragmentToCardDavAddressBookConfigurationFragment( - null - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.settingsFragment) { + val action = + SettingsFragmentDirections.actionSettingsFragmentToCardDavAddressBookConfigurationFragment( + null + ) + findNavController().navigate(action) + } } } viewModel.editCardDavServerEvent.observe(viewLifecycleOwner) { it.consume { name -> - val action = SettingsFragmentDirections.actionSettingsFragmentToCardDavAddressBookConfigurationFragment( - name - ) - findNavController().navigate(action) + if (findNavController().currentDestination?.id == R.id.settingsFragment) { + val action = + SettingsFragmentDirections.actionSettingsFragmentToCardDavAddressBookConfigurationFragment( + name + ) + findNavController().navigate(action) + } } }