mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added back config entry to allow disabling native contacts default directory filter
This commit is contained in:
parent
27298639c3
commit
b123082559
3 changed files with 22 additions and 2 deletions
|
|
@ -65,7 +65,14 @@ class ContactLoader : LoaderManager.LoaderCallbacks<Cursor> {
|
|||
val mimeType = ContactsContract.Data.MIMETYPE
|
||||
val mimeSelection = "$mimeType = ? OR $mimeType = ? OR $mimeType = ? OR $mimeType = ?"
|
||||
|
||||
val selection = ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1 AND ($mimeSelection)"
|
||||
val selection = if (args?.getBoolean("defaultDirectory", true) == true) {
|
||||
Log.i("$TAG Only fetching contacts from default directory")
|
||||
ContactsContract.Data.IN_DEFAULT_DIRECTORY + " == 1 AND ($mimeSelection)"
|
||||
} else {
|
||||
Log.i("$TAG Fetching all available contacts")
|
||||
mimeSelection
|
||||
}
|
||||
|
||||
val selectionArgs = arrayOf(
|
||||
ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE,
|
||||
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import android.content.pm.PackageManager
|
|||
import android.database.Cursor
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.ContactsContract
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.annotation.UiThread
|
||||
|
|
@ -42,6 +43,7 @@ import kotlinx.coroutines.cancel
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.core.Account
|
||||
import org.linphone.core.Address
|
||||
import org.linphone.core.ConferenceInfo
|
||||
|
|
@ -85,6 +87,8 @@ class ContactsManager @UiThread constructor() {
|
|||
private val coroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
private var reloadContactsJob: Job? = null
|
||||
|
||||
private var loadContactsOnlyFromDefaultDirectory = true
|
||||
|
||||
private val friendListListener: FriendListListenerStub = object : FriendListListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onNewSipAddressDiscovered(
|
||||
|
|
@ -147,7 +151,9 @@ class ContactsManager @UiThread constructor() {
|
|||
fun loadContacts(activity: MainActivity) {
|
||||
Log.i("$TAG Starting contacts loader")
|
||||
val manager = LoaderManager.getInstance(activity)
|
||||
manager.restartLoader(0, null, ContactLoader())
|
||||
val args = Bundle()
|
||||
args.putBoolean("defaultDirectory", loadContactsOnlyFromDefaultDirectory)
|
||||
manager.restartLoader(0, args, ContactLoader())
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -432,6 +438,8 @@ class ContactsManager @UiThread constructor() {
|
|||
|
||||
@WorkerThread
|
||||
fun onCoreStarted(core: Core) {
|
||||
loadContactsOnlyFromDefaultDirectory = corePreferences.fetchContactsFromDefaultDirectory
|
||||
|
||||
core.addListener(coreListener)
|
||||
for (list in core.friendsLists) {
|
||||
list.addListener(friendListListener)
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
config.setBool("ui", "show_favorites_contacts", value)
|
||||
}
|
||||
|
||||
@get:WorkerThread @set:WorkerThread
|
||||
var friendListInWhichStoreNewlyCreatedFriends: String
|
||||
get() = config.getString(
|
||||
"app",
|
||||
|
|
@ -247,6 +248,10 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
false
|
||||
)
|
||||
|
||||
@get:WorkerThread
|
||||
val fetchContactsFromDefaultDirectory: Boolean
|
||||
get() = config.getBool("app", "fetch_contacts_from_default_directory", true)
|
||||
|
||||
@get:WorkerThread
|
||||
val automaticallyShowDialpad: Boolean
|
||||
get() = config.getBool("ui", "automatically_show_dialpad", false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue