mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
fix #582, allow disabling duplicate contact merging
This commit is contained in:
parent
faf6a8597a
commit
ef10ce088f
@ -34,6 +34,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupShowPhoneNumbers()
|
setupShowPhoneNumbers()
|
||||||
setupShowContactsWithNumbers()
|
setupShowContactsWithNumbers()
|
||||||
setupStartNameWithSurname()
|
setupStartNameWithSurname()
|
||||||
|
setupMergeDuplicateContacts()
|
||||||
setupShowCallConfirmation()
|
setupShowCallConfirmation()
|
||||||
setupShowDialpadButton()
|
setupShowDialpadButton()
|
||||||
setupShowPrivateContacts()
|
setupShowPrivateContacts()
|
||||||
@ -216,4 +217,12 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
config.showCallConfirmation = settings_show_call_confirmation.isChecked
|
config.showCallConfirmation = settings_show_call_confirmation.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupMergeDuplicateContacts() {
|
||||||
|
settings_merge_duplicate_contacts.isChecked = config.mergeDuplicateContacts
|
||||||
|
settings_merge_duplicate_contacts_holder.setOnClickListener {
|
||||||
|
settings_merge_duplicate_contacts.toggle()
|
||||||
|
config.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,9 +245,11 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
contactSources = it
|
contactSources = it
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
setupContactDetails()
|
setupContactDetails()
|
||||||
getDuplicateContacts {
|
if (config.mergeDuplicateContacts) {
|
||||||
if (duplicateContacts.isNotEmpty()) {
|
getDuplicateContacts {
|
||||||
setupContactDetails()
|
if (duplicateContacts.isNotEmpty()) {
|
||||||
|
setupContactDetails()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
set(onContactClick) = prefs.edit().putInt(ON_CONTACT_CLICK, onContactClick).apply()
|
set(onContactClick) = prefs.edit().putInt(ON_CONTACT_CLICK, onContactClick).apply()
|
||||||
|
|
||||||
var showContactFields: Int
|
var showContactFields: Int
|
||||||
get() = prefs.getInt(SHOW_CONTACT_FIELDS, SHOW_FIRST_NAME_FIELD or SHOW_SURNAME_FIELD or SHOW_PHONE_NUMBERS_FIELD or SHOW_EMAILS_FIELD or
|
get() = prefs.getInt(
|
||||||
SHOW_ADDRESSES_FIELD or SHOW_EVENTS_FIELD or SHOW_NOTES_FIELD or SHOW_GROUPS_FIELD or SHOW_CONTACT_SOURCE_FIELD)
|
SHOW_CONTACT_FIELDS, SHOW_FIRST_NAME_FIELD or SHOW_SURNAME_FIELD or SHOW_PHONE_NUMBERS_FIELD or SHOW_EMAILS_FIELD or
|
||||||
|
SHOW_ADDRESSES_FIELD or SHOW_EVENTS_FIELD or SHOW_NOTES_FIELD or SHOW_GROUPS_FIELD or SHOW_CONTACT_SOURCE_FIELD
|
||||||
|
)
|
||||||
set(showContactFields) = prefs.edit().putInt(SHOW_CONTACT_FIELDS, showContactFields).apply()
|
set(showContactFields) = prefs.edit().putInt(SHOW_CONTACT_FIELDS, showContactFields).apply()
|
||||||
|
|
||||||
var showTabs: Int
|
var showTabs: Int
|
||||||
@ -60,4 +62,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var showPrivateContacts: Boolean
|
var showPrivateContacts: Boolean
|
||||||
get() = prefs.getBoolean(SHOW_PRIVATE_CONTACTS, true)
|
get() = prefs.getBoolean(SHOW_PRIVATE_CONTACTS, true)
|
||||||
set(showPrivateContacts) = prefs.edit().putBoolean(SHOW_PRIVATE_CONTACTS, showPrivateContacts).apply()
|
set(showPrivateContacts) = prefs.edit().putBoolean(SHOW_PRIVATE_CONTACTS, showPrivateContacts).apply()
|
||||||
|
|
||||||
|
var mergeDuplicateContacts: Boolean
|
||||||
|
get() = prefs.getBoolean(MERGE_DUPLICATE_CONTACTS, true)
|
||||||
|
set(mergeDuplicateContacts) = prefs.edit().putBoolean(MERGE_DUPLICATE_CONTACTS, mergeDuplicateContacts).apply()
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ const val SPEED_DIAL = "speed_dial"
|
|||||||
const val LAST_EXPORT_PATH = "last_export_path"
|
const val LAST_EXPORT_PATH = "last_export_path"
|
||||||
const val WAS_LOCAL_ACCOUNT_INITIALIZED = "was_local_account_initialized"
|
const val WAS_LOCAL_ACCOUNT_INITIALIZED = "was_local_account_initialized"
|
||||||
const val SHOW_PRIVATE_CONTACTS = "show_private_contacts"
|
const val SHOW_PRIVATE_CONTACTS = "show_private_contacts"
|
||||||
|
const val MERGE_DUPLICATE_CONTACTS = "merge_duplicate_contacts"
|
||||||
|
|
||||||
const val SMT_PRIVATE = "smt_private" // used at the contact source of local contacts hidden from other apps
|
const val SMT_PRIVATE = "smt_private" // used at the contact source of local contacts hidden from other apps
|
||||||
const val GROUP = "group"
|
const val GROUP = "group"
|
||||||
|
@ -72,7 +72,7 @@ class ContactsHelper(val context: Context) {
|
|||||||
contacts.valueAt(it)
|
contacts.valueAt(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoredContactSources.isEmpty() && !getAll) {
|
if (context.config.mergeDuplicateContacts && ignoredContactSources.isEmpty() && !getAll) {
|
||||||
tempContacts.filter { displayContactSources.contains(it.source) }.groupBy { it.getNameToDisplay().toLowerCase() }.values.forEach { it ->
|
tempContacts.filter { displayContactSources.contains(it.source) }.groupBy { it.getNameToDisplay().toLowerCase() }.values.forEach { it ->
|
||||||
if (it.size == 1) {
|
if (it.size == 1) {
|
||||||
resultContacts.add(it.first())
|
resultContacts.add(it.first())
|
||||||
|
@ -114,6 +114,22 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_merge_duplicate_contacts_holder"
|
||||||
|
style="@style/SettingsHolderCheckboxStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/ripple_background">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
|
android:id="@+id/settings_merge_duplicate_contacts"
|
||||||
|
style="@style/SettingsCheckboxStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/merge_duplicate_contacts" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_show_call_confirmation_holder"
|
android:id="@+id/settings_show_call_confirmation_holder"
|
||||||
style="@style/SettingsHolderCheckboxStyle"
|
style="@style/SettingsHolderCheckboxStyle"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user