Only go to choose secure/interop mode after successfully connecting first sip.linphone.org account

This commit is contained in:
Sylvain Berfini 2024-05-17 16:51:23 +02:00
parent 7cff514c3a
commit fc8ac5fc56
6 changed files with 22 additions and 24 deletions

View file

@ -116,10 +116,16 @@ class LandingFragment : GenericFragment() {
}
viewModel.accountLoggedInEvent.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Account successfully logged-in, go to profile mode fragment")
val action = LandingFragmentDirections.actionLandingFragmentToProfileModeFragment()
findNavController().navigate(action)
it.consume { firstAccount ->
Log.i("$TAG Account successfully logged-in")
if (firstAccount) {
Log.i("$TAG First account, going to secure/interop mode chooser")
val action = LandingFragmentDirections.actionLandingFragmentToProfileModeFragment()
findNavController().navigate(action)
} else {
Log.i("$TAG Not first account, leaving assistant")
requireActivity().finish()
}
}
}

View file

@ -98,10 +98,16 @@ class LoginFragment : GenericFragment() {
}
viewModel.accountLoggedInEvent.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Account successfully logged-in, go to profile mode fragment")
val action = LoginFragmentDirections.actionLoginFragmentToProfileModeFragment()
findNavController().navigate(action)
it.consume { firstAccount ->
Log.i("$TAG Account successfully logged-in")
if (firstAccount) {
Log.i("$TAG First account, going to secure/interop mode chooser")
val action = LoginFragmentDirections.actionLoginFragmentToProfileModeFragment()
findNavController().navigate(action)
} else {
Log.i("$TAG Not first account, leaving assistant")
requireActivity().finish()
}
}
}

View file

@ -89,7 +89,7 @@ open class AccountLoginViewModel @UiThread constructor() : GenericViewModel() {
// Set new account as default
core.defaultAccount = newlyCreatedAccount
accountLoggedInEvent.postValue(Event(true))
accountLoggedInEvent.postValue(Event(core.accountList.size == 1))
} else if (state == RegistrationState.Failed) {
registrationInProgress.postValue(false)
core.removeListener(this)

View file

@ -568,8 +568,7 @@ class ConversationFragment : SlidingPaneChildFragment() {
Log.i(
"$TAG Navigating to account profile mode fragment to let user change mode to interop"
)
sharedViewModel.goToAccountProfileModeEvent.value = Event(true)
sharedViewModel.goToAccountProfileEvent.value = Event(true)
// TODO FIXME: show bottom dialog like for encrypted conversation
}
sendMessageViewModel.emojiToAddEvent.observe(viewLifecycleOwner) {

View file

@ -186,15 +186,6 @@ class AccountProfileFragment : GenericMainFragment() {
(view.parent as? ViewGroup)?.doOnPreDraw {
startPostponedEnterTransition()
setupDialPlanPicker()
sharedViewModel.goToAccountProfileModeEvent.observe(viewLifecycleOwner) { event ->
event.consume {
Log.i(
"$TAG Account was found, going directly to AccountProfileMode fragment"
)
goToAccountProfileModeFragment()
}
}
}
} else {
Log.e(

View file

@ -81,10 +81,6 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<Boolean>>()
}
val goToAccountProfileModeEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
/* Contacts related */
var displayedFriend: Friend? = null // Prevents the need to go look for the friend