mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed drawer menu accounts list not refreshing avatar
This commit is contained in:
parent
29a47b87cd
commit
643a2be9a2
5 changed files with 51 additions and 28 deletions
|
|
@ -72,6 +72,24 @@ class DrawerMenuFragment : GenericFragment() {
|
|||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.setSettingsClickedListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_settingsFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
binding.setRecordingsClickListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_recordingsFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
binding.setHelpClickedListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_helpFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
viewModel.startAssistantEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
startActivity(Intent(requireContext(), AssistantActivity::class.java))
|
||||
|
|
@ -98,22 +116,10 @@ class DrawerMenuFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
binding.setSettingsClickedListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_settingsFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
binding.setRecordingsClickListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_recordingsFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
}
|
||||
|
||||
binding.setHelpClickedListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
navController.navigate(R.id.action_global_helpFragment)
|
||||
(requireActivity() as MainActivity).closeDrawerMenu()
|
||||
sharedViewModel.refreshDrawerMenuAccountsListEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
viewModel.updateAccountsList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,4 +154,9 @@ class DrawerMenuFragment : GenericFragment() {
|
|||
popupWindow.elevation = 20f
|
||||
popupWindow.showAsDropDown(view, 0, 0, Gravity.BOTTOM)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.updateAccountsList()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,10 +62,12 @@ class AccountModel @WorkerThread constructor(
|
|||
state: RegistrationState?,
|
||||
message: String
|
||||
) {
|
||||
Log.i(
|
||||
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] registration state changed: [$state]($message)"
|
||||
)
|
||||
update()
|
||||
if (account == this@AccountModel.account) {
|
||||
Log.i(
|
||||
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] registration state changed: [$state]($message)"
|
||||
)
|
||||
update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +118,7 @@ class AccountModel @WorkerThread constructor(
|
|||
|
||||
val pictureUri = account.params.pictureUri.orEmpty()
|
||||
avatar.postValue(pictureUri)
|
||||
Log.i("$TAG Account picture URI is [$pictureUri]")
|
||||
Log.d("$TAG Account picture URI is [$pictureUri]")
|
||||
|
||||
isDefault.postValue(coreContext.core.defaultAccount == account)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import org.linphone.core.tools.Log
|
|||
import org.linphone.databinding.AccountProfileFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
@UiThread
|
||||
|
|
@ -107,6 +108,7 @@ class AccountProfileFragment : GenericFragment() {
|
|||
|
||||
Log.i("$TAG Leaving account profile, saving changes")
|
||||
viewModel.saveChangesWhenLeaving()
|
||||
sharedViewModel.refreshDrawerMenuAccountsListEvent.value = Event(true)
|
||||
}
|
||||
|
||||
private fun pickImage() {
|
||||
|
|
|
|||
|
|
@ -54,16 +54,14 @@ class DrawerMenuViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
init {
|
||||
// TODO FIXME: update accounts list when a new account is added or when removing one
|
||||
coreContext.postOnCoreThread {
|
||||
computeAccountsList()
|
||||
}
|
||||
|
||||
// TODO FIXME: account avatar not refreshed...
|
||||
}
|
||||
|
||||
@UiThread
|
||||
override fun onCleared() {
|
||||
coreContext.postOnCoreThread {
|
||||
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
||||
}
|
||||
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
|
|
@ -77,9 +75,15 @@ class DrawerMenuViewModel @UiThread constructor() : ViewModel() {
|
|||
startAssistantEvent.value = Event(true)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun updateAccountsList() {
|
||||
coreContext.postOnCoreThread {
|
||||
computeAccountsList()
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun computeAccountsList() {
|
||||
Log.i("$TAG Updating accounts list")
|
||||
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
||||
|
||||
val list = arrayListOf<AccountModel>()
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val refreshDrawerMenuAccountsListEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
/* Contacts related */
|
||||
|
||||
val contactsListReadyToBeDisplayedEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue