Make delay before showing contacts operation in progress spinner configurable

This commit is contained in:
Sylvain Berfini 2022-03-03 11:50:07 +01:00
parent 2c846f6727
commit cc632d89f3
2 changed files with 6 additions and 1 deletions

View file

@ -27,6 +27,7 @@ import androidx.lifecycle.viewModelScope
import java.util.*
import kotlinx.coroutines.*
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.contact.Contact
import org.linphone.contact.ContactsUpdatedListenerStub
import org.linphone.contact.NativeContact
@ -106,9 +107,10 @@ class ContactsListViewModel : ViewModel() {
fastFetchJob?.cancel()
coreContext.contactsManager.magicSearch.getContactsAsync(filterValue, domain, filter)
val spinnerDelay = corePreferences.delayBeforeShowingContactsSearchSpinner.toLong()
fastFetchJob = viewModelScope.launch {
withContext(Dispatchers.IO) {
delay(200)
delay(spinnerDelay)
withContext(Dispatchers.Main) {
if (searchResultsPending) {
fetchInProgress.value = true

View file

@ -431,6 +431,9 @@ class CorePreferences constructor(private val context: Context) {
val fetchContactsFromDefaultDirectory: Boolean
get() = config.getBool("app", "fetch_contacts_from_default_directory", true)
val delayBeforeShowingContactsSearchSpinner: Int
get() = config.getInt("app", "delay_before_showing_contacts_search_spinner", 200)
// From Android Contact APIs we can also retrieve the internationalized phone number
// By default we display the same value as the native address book app
val preferNormalizedPhoneNumbersFromAddressBook: Boolean