mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed issues when switching default account
This commit is contained in:
parent
8d05d786ce
commit
b113e2b729
5 changed files with 35 additions and 28 deletions
|
|
@ -392,9 +392,9 @@ class ConversationFragment : GenericFragment() {
|
|||
try {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivity(browserIntent)
|
||||
} catch (ise: IllegalStateException) {
|
||||
} catch (e: Exception) {
|
||||
Log.e(
|
||||
"$TAG Can't start ACTION_VIEW intent for URL [$url], IllegalStateException: $ise"
|
||||
"$TAG Can't start ACTION_VIEW intent for URL [$url]: $e"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,15 +181,13 @@ class ConversationsListFragment : AbstractTopBarFragment() {
|
|||
val localSipUri = pair.first
|
||||
val remoteSipUri = pair.second
|
||||
Log.i(
|
||||
"${ConversationsListFragment.TAG} Navigating to conversation fragment with local SIP URI [$localSipUri] and remote SIP URI [$remoteSipUri]"
|
||||
"$TAG Navigating to conversation fragment with local SIP URI [$localSipUri] and remote SIP URI [$remoteSipUri]"
|
||||
)
|
||||
if (findNavController().currentDestination?.id == R.id.conversationsListFragment) {
|
||||
val action = ConversationFragmentDirections.actionGlobalConversationFragment(
|
||||
localSipUri,
|
||||
remoteSipUri
|
||||
)
|
||||
binding.chatNavContainer.findNavController().navigate(action)
|
||||
}
|
||||
val action = ConversationFragmentDirections.actionGlobalConversationFragment(
|
||||
localSipUri,
|
||||
remoteSipUri
|
||||
)
|
||||
binding.chatNavContainer.findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ abstract class AbstractTopBarFragment : GenericFragment() {
|
|||
sharedViewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
Log.i("$TAG Default account changed")
|
||||
viewModel.updateAvailableMenus()
|
||||
viewModel.update()
|
||||
onDefaultAccountChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ import android.widget.PopupWindow
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Account
|
||||
import org.linphone.core.tools.Log
|
||||
|
|
@ -111,8 +116,17 @@ class DrawerMenuFragment : GenericFragment() {
|
|||
|
||||
viewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { identity ->
|
||||
Log.w("$TAG Default account has changed, now is [$identity]")
|
||||
Log.w("$TAG Default account has changed, now is [$identity], closing side menu in 500ms")
|
||||
sharedViewModel.defaultAccountChangedEvent.value = Event(true)
|
||||
|
||||
lifecycleScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
delay(500)
|
||||
withContext(Dispatchers.Main) {
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,13 +121,6 @@ open class AbstractTopBarViewModel @UiThread constructor() : ViewModel() {
|
|||
init {
|
||||
searchBarVisible.value = false
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
core.addListener(coreListener)
|
||||
updateMissedCallsCount()
|
||||
updateUnreadMessagesCount()
|
||||
}
|
||||
|
||||
updateAvailableMenus()
|
||||
update()
|
||||
}
|
||||
|
||||
|
|
@ -184,6 +177,10 @@ open class AbstractTopBarViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
account.value?.destroy()
|
||||
account.postValue(AccountModel(defaultAccount))
|
||||
|
||||
updateUnreadMessagesCount()
|
||||
updateMissedCallsCount()
|
||||
updateAvailableMenus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,16 +236,14 @@ open class AbstractTopBarViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@WorkerThread
|
||||
fun updateAvailableMenus() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
hideConversations.postValue(corePreferences.disableChat)
|
||||
hideConversations.postValue(corePreferences.disableChat)
|
||||
|
||||
val hideGroupCall =
|
||||
corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
|
||||
core
|
||||
)
|
||||
hideMeetings.postValue(hideGroupCall)
|
||||
}
|
||||
val hideGroupCall =
|
||||
corePreferences.disableMeetings || !LinphoneUtils.isRemoteConferencingAvailable(
|
||||
coreContext.core
|
||||
)
|
||||
hideMeetings.postValue(hideGroupCall)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue