Added a hidden setting to disable prefering normalized phone numbes when importing contacts from native address book

This commit is contained in:
Sylvain Berfini 2021-11-05 16:27:22 +01:00
parent 06e07518bb
commit 4a4d5f5d74
2 changed files with 10 additions and 1 deletions

View file

@ -118,7 +118,13 @@ class NativeContact(val nativeId: String, private val lookupKey: String? = null)
label label
).toString() ).toString()
val number = data4 ?: data1 // data4 = ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER
// data1 = ContactsContract.CommonDataKinds.Phone.NUMBER
val number = if (corePreferences.preferNormalizedPhoneNumbersFromAddressBook) {
data4 ?: data1
} else {
data1 ?: data4
}
if (number != null && number.isNotEmpty()) { if (number != null && number.isNotEmpty()) {
Log.d("[Native Contact] Found phone number $data1 ($data4), type label is $typeLabel") Log.d("[Native Contact] Found phone number $data1 ($data4), type label is $typeLabel")
if (!rawPhoneNumbers.contains(number)) { if (!rawPhoneNumbers.contains(number)) {

View file

@ -424,6 +424,9 @@ class CorePreferences constructor(private val context: Context) {
val fetchContactsFromDefaultDirectory: Boolean val fetchContactsFromDefaultDirectory: Boolean
get() = config.getBool("app", "fetch_contacts_from_default_directory", true) get() = config.getBool("app", "fetch_contacts_from_default_directory", true)
val preferNormalizedPhoneNumbersFromAddressBook: Boolean
get() = config.getBool("app", "prefer_normalized_phone_numbers_from_address_book", true)
val hideStaticImageCamera: Boolean val hideStaticImageCamera: Boolean
get() = config.getBool("app", "hide_static_image_camera", true) get() = config.getBool("app", "hide_static_image_camera", true)