mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-27 19:36:21 +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.lifecycleOwner = viewLifecycleOwner
|
||||||
binding.viewModel = viewModel
|
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) {
|
viewModel.startAssistantEvent.observe(viewLifecycleOwner) {
|
||||||
it.consume {
|
it.consume {
|
||||||
startActivity(Intent(requireContext(), AssistantActivity::class.java))
|
startActivity(Intent(requireContext(), AssistantActivity::class.java))
|
||||||
|
|
@ -98,22 +116,10 @@ class DrawerMenuFragment : GenericFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.setSettingsClickedListener {
|
sharedViewModel.refreshDrawerMenuAccountsListEvent.observe(viewLifecycleOwner) {
|
||||||
val navController = (requireActivity() as MainActivity).findNavController()
|
it.consume {
|
||||||
navController.navigate(R.id.action_global_settingsFragment)
|
viewModel.updateAccountsList()
|
||||||
(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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,4 +154,9 @@ class DrawerMenuFragment : GenericFragment() {
|
||||||
popupWindow.elevation = 20f
|
popupWindow.elevation = 20f
|
||||||
popupWindow.showAsDropDown(view, 0, 0, Gravity.BOTTOM)
|
popupWindow.showAsDropDown(view, 0, 0, Gravity.BOTTOM)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
viewModel.updateAccountsList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,12 @@ class AccountModel @WorkerThread constructor(
|
||||||
state: RegistrationState?,
|
state: RegistrationState?,
|
||||||
message: String
|
message: String
|
||||||
) {
|
) {
|
||||||
Log.i(
|
if (account == this@AccountModel.account) {
|
||||||
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] registration state changed: [$state]($message)"
|
Log.i(
|
||||||
)
|
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] registration state changed: [$state]($message)"
|
||||||
update()
|
)
|
||||||
|
update()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,7 +118,7 @@ class AccountModel @WorkerThread constructor(
|
||||||
|
|
||||||
val pictureUri = account.params.pictureUri.orEmpty()
|
val pictureUri = account.params.pictureUri.orEmpty()
|
||||||
avatar.postValue(pictureUri)
|
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)
|
isDefault.postValue(coreContext.core.defaultAccount == account)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import org.linphone.core.tools.Log
|
||||||
import org.linphone.databinding.AccountProfileFragmentBinding
|
import org.linphone.databinding.AccountProfileFragmentBinding
|
||||||
import org.linphone.ui.main.fragment.GenericFragment
|
import org.linphone.ui.main.fragment.GenericFragment
|
||||||
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
||||||
|
import org.linphone.utils.Event
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
|
@ -107,6 +108,7 @@ class AccountProfileFragment : GenericFragment() {
|
||||||
|
|
||||||
Log.i("$TAG Leaving account profile, saving changes")
|
Log.i("$TAG Leaving account profile, saving changes")
|
||||||
viewModel.saveChangesWhenLeaving()
|
viewModel.saveChangesWhenLeaving()
|
||||||
|
sharedViewModel.refreshDrawerMenuAccountsListEvent.value = Event(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pickImage() {
|
private fun pickImage() {
|
||||||
|
|
|
||||||
|
|
@ -54,16 +54,14 @@ class DrawerMenuViewModel @UiThread constructor() : ViewModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
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
|
@UiThread
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
coreContext.postOnCoreThread {
|
||||||
|
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
||||||
|
}
|
||||||
|
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,9 +75,15 @@ class DrawerMenuViewModel @UiThread constructor() : ViewModel() {
|
||||||
startAssistantEvent.value = Event(true)
|
startAssistantEvent.value = Event(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
|
fun updateAccountsList() {
|
||||||
|
coreContext.postOnCoreThread {
|
||||||
|
computeAccountsList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private fun computeAccountsList() {
|
private fun computeAccountsList() {
|
||||||
Log.i("$TAG Updating accounts list")
|
|
||||||
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
accounts.value.orEmpty().forEach(AccountModel::destroy)
|
||||||
|
|
||||||
val list = arrayListOf<AccountModel>()
|
val list = arrayListOf<AccountModel>()
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,10 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
||||||
MutableLiveData<Event<Boolean>>()
|
MutableLiveData<Event<Boolean>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val refreshDrawerMenuAccountsListEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||||
|
MutableLiveData<Event<Boolean>>()
|
||||||
|
}
|
||||||
|
|
||||||
/* Contacts related */
|
/* Contacts related */
|
||||||
|
|
||||||
val contactsListReadyToBeDisplayedEvent = MutableLiveData<Event<Boolean>>()
|
val contactsListReadyToBeDisplayedEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue