diff --git a/app/src/main/java/org/linphone/activities/main/contact/viewmodels/ContactEditorViewModel.kt b/app/src/main/java/org/linphone/activities/main/contact/viewmodels/ContactEditorViewModel.kt index 439b4c355..8eb621982 100644 --- a/app/src/main/java/org/linphone/activities/main/contact/viewmodels/ContactEditorViewModel.kt +++ b/app/src/main/java/org/linphone/activities/main/contact/viewmodels/ContactEditorViewModel.kt @@ -99,7 +99,31 @@ class ContactEditorViewModel(val c: Contact?) : ViewModel(), ContactViewModelInt val friend = contact.friend ?: coreContext.core.createFriend() if (friend != null) { friend.edit() - // TODO edit friend + friend.name = "${firstName.value.orEmpty()} ${lastName.value.orEmpty()}" + + for (address in friend.addresses) { + friend.removeAddress(address) + } + for (address in addresses.value.orEmpty()) { + val parsed = coreContext.core.interpretUrl(address.newValue.value.orEmpty()) + if (parsed != null) friend.addAddress(parsed) + } + + for (phone in friend.phoneNumbers) { + friend.removePhoneNumber(phone) + } + for (phone in numbers.value.orEmpty()) { + if (phone.newValue.value?.isNotEmpty() == true) { + friend.addPhoneNumber(phone.newValue.value) + } + } + + val vCard = friend.vcard + if (vCard != null) { + vCard.organization = organization.value.orEmpty() + vCard.familyName = lastName.value.orEmpty() + vCard.givenName = firstName.value.orEmpty() + } friend.done() if (contact.friend == null) { diff --git a/app/src/main/res/layout/settings_chat_fragment.xml b/app/src/main/res/layout/settings_chat_fragment.xml index c6c431058..2ea011553 100644 --- a/app/src/main/res/layout/settings_chat_fragment.xml +++ b/app/src/main/res/layout/settings_chat_fragment.xml @@ -88,7 +88,8 @@ linphone:listener="@{viewModel.autoDownloadMaxSizeListener}" linphone:defaultValue="@{viewModel.autoDownloadMaxSize.toString()}" linphone:inputType="@{InputType.TYPE_CLASS_NUMBER}" - linphone:enabled="@{viewModel.autoDownloadIndex == 2}"/> + linphone:enabled="@{viewModel.autoDownloadIndex == 2}" + android:visibility="@{viewModel.autoDownloadIndex == 2 ? View.VISIBLE : View.GONE}"/>