mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Finished LDAP settings using newly added APIs
This commit is contained in:
parent
4b6607c234
commit
3e23545ec0
6 changed files with 45 additions and 4 deletions
|
|
@ -36,6 +36,7 @@ import com.google.android.material.transition.MaterialSharedAxis
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.SnackBarActivity
|
||||
import org.linphone.activities.clearDisplayedContact
|
||||
import org.linphone.activities.main.MainActivity
|
||||
import org.linphone.activities.main.contact.adapters.ContactsListAdapter
|
||||
|
|
@ -247,6 +248,14 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
adapter.submitList(it)
|
||||
}
|
||||
|
||||
listViewModel.moreResultsAvailableEvent.observe(
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
(requireActivity() as SnackBarActivity).showSnackBar(R.string.contacts_ldap_query_more_results_available)
|
||||
}
|
||||
}
|
||||
|
||||
binding.setAllContactsToggleClickListener {
|
||||
listViewModel.sipContactsSelected.value = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,9 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
|||
import org.linphone.contact.Contact
|
||||
import org.linphone.contact.ContactsUpdatedListenerStub
|
||||
import org.linphone.contact.NativeContact
|
||||
import org.linphone.core.MagicSearch
|
||||
import org.linphone.core.MagicSearchListenerStub
|
||||
import org.linphone.core.MagicSearchSource
|
||||
import org.linphone.core.SearchResult
|
||||
import org.linphone.core.*
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ContactsListViewModel : ViewModel() {
|
||||
val sipContactsSelected = MutableLiveData<Boolean>()
|
||||
|
|
@ -44,6 +42,10 @@ class ContactsListViewModel : ViewModel() {
|
|||
val filter = MutableLiveData<String>()
|
||||
private var previousFilter = "NotSet"
|
||||
|
||||
val moreResultsAvailableEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
private val contactsUpdatedListener = object : ContactsUpdatedListenerStub() {
|
||||
override fun onContactsUpdated() {
|
||||
Log.i("[Contacts] Contacts have changed")
|
||||
|
|
@ -56,6 +58,10 @@ class ContactsListViewModel : ViewModel() {
|
|||
processMagicSearchResults(magicSearch.lastSearch)
|
||||
fetchInProgress.value = false
|
||||
}
|
||||
|
||||
override fun onLdapHaveMoreResults(magicSearch: MagicSearch, ldap: Ldap) {
|
||||
moreResultsAvailableEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
|
|
|
|||
|
|
@ -192,6 +192,20 @@ class LdapSettingsViewModel(private val ldap: Ldap, val index: String) : Generic
|
|||
}
|
||||
val ldapRequestDelay = MutableLiveData<Int>()
|
||||
|
||||
val ldapMinimumCharactersListener = object : SettingListenerStub() {
|
||||
override fun onTextValueChanged(newValue: String) {
|
||||
try {
|
||||
val intValue = newValue.toInt()
|
||||
val params = ldap.params.clone()
|
||||
params.minChars = intValue
|
||||
ldap.params = params
|
||||
} catch (nfe: NumberFormatException) {
|
||||
Log.e("[LDAP Settings] Failed to set minimum characters ($newValue): $nfe")
|
||||
}
|
||||
}
|
||||
}
|
||||
val ldapMinimumCharacters = MutableLiveData<Int>()
|
||||
|
||||
val ldapNameAttributeListener = object : SettingListenerStub() {
|
||||
override fun onTextValueChanged(newValue: String) {
|
||||
val params = ldap.params.clone()
|
||||
|
|
@ -241,6 +255,7 @@ class LdapSettingsViewModel(private val ldap: Ldap, val index: String) : Generic
|
|||
ldapSearchMaxResults.value = params.maxResults
|
||||
ldapSearchTimeout.value = params.timeout
|
||||
ldapRequestDelay.value = params.delay
|
||||
ldapMinimumCharacters.value = params.minChars
|
||||
ldapNameAttribute.value = params.nameAttribute
|
||||
ldapSipAttribute.value = params.sipAttribute
|
||||
ldapSipDomain.value = params.sipDomain
|
||||
|
|
|
|||
|
|
@ -177,6 +177,13 @@
|
|||
linphone:defaultValue="@{viewModel.ldapRequestDelay.toString()}"
|
||||
linphone:inputType="@{InputType.TYPE_CLASS_NUMBER}"/>
|
||||
|
||||
<include
|
||||
layout="@layout/settings_widget_text"
|
||||
linphone:title="@{@string/contacts_settings_ldap_minimum_characters_title}"
|
||||
linphone:listener="@{viewModel.ldapMinimumCharactersListener}"
|
||||
linphone:defaultValue="@{viewModel.ldapMinimumCharacters.toString()}"
|
||||
linphone:inputType="@{InputType.TYPE_CLASS_NUMBER}"/>
|
||||
|
||||
<TextView
|
||||
style="@style/settings_category_font"
|
||||
android:text="@string/contacts_settings_ldap_parsing_title"
|
||||
|
|
|
|||
|
|
@ -649,6 +649,7 @@
|
|||
<string name="contacts_settings_ldap_search_timeout_subtitle">En secondes</string>
|
||||
<string name="contacts_settings_ldap_request_delay_title">Délai entre 2 requêtes</string>
|
||||
<string name="contacts_settings_ldap_request_delay_subtitle">En millisecondes</string>
|
||||
<string name="contacts_settings_ldap_minimum_characters_title">Nombre minimum de caractères pour lancer la requête</string>
|
||||
<string name="contacts_settings_ldap_parsing_title">Analyse</string>
|
||||
<string name="contacts_settings_ldap_name_attribute_title">Attributs de nom</string>
|
||||
<string name="contacts_settings_ldap_sip_attribute_title">Attributs SIP</string>
|
||||
|
|
@ -656,4 +657,5 @@
|
|||
<string name="contacts_settings_ldap_misc_title">Divers</string>
|
||||
<string name="contacts_settings_ldap_debug_title">Débogage</string>
|
||||
<string name="contact_cant_be_deleted">Ce contact ne peut être supprimé</string>
|
||||
<string name="contacts_ldap_query_more_results_available">Plus de résultats sont disponibles, affinez votre recherche</string>
|
||||
</resources>
|
||||
|
|
@ -115,6 +115,7 @@
|
|||
<string name="contact_new_choose_sync_account">Choose where to save the contact</string>
|
||||
<string name="contact_local_sync_account">Store locally</string>
|
||||
<string name="contact_cant_be_deleted">This contact can\'t be deleted</string>
|
||||
<string name="contacts_ldap_query_more_results_available">More results are available, refine your search</string>
|
||||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer_address_bar_hint">Enter a number or an address</string>
|
||||
|
|
@ -511,6 +512,7 @@
|
|||
<string name="contacts_settings_ldap_search_timeout_subtitle">In seconds</string>
|
||||
<string name="contacts_settings_ldap_request_delay_title">Delay between two requests</string>
|
||||
<string name="contacts_settings_ldap_request_delay_subtitle">In milliseconds</string>
|
||||
<string name="contacts_settings_ldap_minimum_characters_title">Minimum characters to start query</string>
|
||||
<string name="contacts_settings_ldap_parsing_title">Parsing</string>
|
||||
<string name="contacts_settings_ldap_name_attribute_title">Name attributes</string>
|
||||
<string name="contacts_settings_ldap_sip_attribute_title">SIP attributes</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue