Hide size setting if auto download policy is never or always + finished friend edition

This commit is contained in:
Sylvain Berfini 2020-06-08 13:07:52 +02:00
parent 1f3321967f
commit bf024abdb9
2 changed files with 27 additions and 2 deletions

View file

@ -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) {

View file

@ -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}"/>
<include
layout="@layout/settings_widget_switch"