Disable action buttons & hide numbers & SIP addresses fields if contact doesn't contains any

This commit is contained in:
Sylvain Berfini 2024-07-11 15:46:12 +02:00
parent 11eb0199f8
commit e012d45c10
4 changed files with 23 additions and 1 deletions

View file

@ -44,4 +44,7 @@ hide_empty_chat_rooms=0
[fec]
fec_enabled=1
[magic_search]
return_empty_friends=1
## End of default rc

View file

@ -447,6 +447,9 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
core.isFecEnabled = true
Log.i("$TAG Video FEC has been enabled")
core.config.setBool("magic_search", "return_empty_friends", true)
Log.i("$TAG Showing 'empty' friends enabled")
}
corePreferences.linphoneConfigurationVersion = currentVersion

View file

@ -21,6 +21,7 @@ package org.linphone.ui.main.contacts.viewmodel
import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import java.io.File
@ -64,6 +65,7 @@ class ContactViewModel @UiThread constructor() : GenericViewModel() {
val contact = MutableLiveData<ContactAvatarModel>()
val sipAddressesAndPhoneNumbers = MutableLiveData<ArrayList<ContactNumberOrAddressModel>>()
val atLeastOneSipAddressOrPhoneNumber = MediatorLiveData<Boolean>()
val devices = MutableLiveData<ArrayList<ContactDeviceModel>>()
@ -236,9 +238,15 @@ class ContactViewModel @UiThread constructor() : GenericViewModel() {
init {
isStored.value = false
expandNumbersAndAddresses.value = true
trustedDevicesPercentage.value = 0
atLeastOneSipAddressOrPhoneNumber.value = false
atLeastOneSipAddressOrPhoneNumber.addSource(sipAddressesAndPhoneNumbers) {
atLeastOneSipAddressOrPhoneNumber.value = it.isNotEmpty()
}
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
chatDisabled.postValue(corePreferences.disableChat)

View file

@ -144,6 +144,7 @@
<ImageView
android:id="@+id/call"
android:onClick="@{() -> viewModel.startAudioCall()}"
android:enabled="@{viewModel.atLeastOneSipAddressOrPhoneNumber}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
@ -160,6 +161,7 @@
style="@style/default_text_style"
android:id="@+id/call_label"
android:onClick="@{() -> viewModel.startAudioCall()}"
android:enabled="@{viewModel.atLeastOneSipAddressOrPhoneNumber}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
@ -173,6 +175,7 @@
android:id="@+id/chat"
android:onClick="@{() -> viewModel.goToConversation()}"
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
android:enabled="@{viewModel.atLeastOneSipAddressOrPhoneNumber}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
@ -190,6 +193,7 @@
android:id="@+id/chat_label"
android:onClick="@{() -> viewModel.goToConversation()}"
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
android:enabled="@{viewModel.atLeastOneSipAddressOrPhoneNumber}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
@ -203,6 +207,7 @@
android:id="@+id/video_call"
android:onClick="@{() -> viewModel.startVideoCall()}"
android:visibility="@{viewModel.videoCallDisabled ? View.GONE : View.VISIBLE}"
android:enabled="@{viewModel.atLeastOneSipAddressOrPhoneNumber}"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="20dp"
@ -220,6 +225,7 @@
android:id="@+id/video_call_label"
android:onClick="@{() -> viewModel.startVideoCall()}"
android:visibility="@{viewModel.videoCallDisabled ? View.GONE : View.VISIBLE}"
android:enabled="@{viewModel.atLeastOneSipAddressOrPhoneNumber}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
@ -242,13 +248,14 @@
android:text="@string/contact_details_numbers_and_addresses_title"
android:drawableEnd="@{viewModel.expandNumbersAndAddresses ? @drawable/caret_up : @drawable/caret_down, default=@drawable/caret_up}"
android:drawableTint="?attr/color_main2_600"
android:visibility="@{viewModel.atLeastOneSipAddressOrPhoneNumber ? View.VISIBLE : View.GONE}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/call_label"/>
<LinearLayout
android:id="@+id/numbers_and_addresses"
android:visibility="@{viewModel.expandNumbersAndAddresses ? View.VISIBLE : View.GONE}"
android:visibility="@{viewModel.atLeastOneSipAddressOrPhoneNumber &amp;&amp; viewModel.expandNumbersAndAddresses ? View.VISIBLE : View.GONE}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
@ -488,6 +495,7 @@
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:background="@drawable/shape_squircle_white_background"
app:layout_constraintVertical_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/actions"