fix #235, rely on both account name and type at filtering
This commit is contained in:
parent
cfa9bdaf7a
commit
aeed7e2456
|
@ -41,12 +41,12 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
|||
|
||||
private fun confirmEventTypes() {
|
||||
val selectedContactSources = (view.filter_contact_sources_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
||||
val ignoredContactSourceNames = contactSources.filter { !selectedContactSources.contains(it) }.map {
|
||||
if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.name
|
||||
val ignoredContactSources = contactSources.filter { !selectedContactSources.contains(it) }.map {
|
||||
if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.getFullIdentifier()
|
||||
}.toHashSet()
|
||||
|
||||
if (activity.getVisibleContactSources() != ignoredContactSourceNames) {
|
||||
activity.config.ignoredContactSources = ignoredContactSourceNames
|
||||
if (activity.getVisibleContactSources() != ignoredContactSources) {
|
||||
activity.config.ignoredContactSources = ignoredContactSources
|
||||
callback()
|
||||
}
|
||||
dialog?.dismiss()
|
||||
|
|
|
@ -308,8 +308,9 @@ fun Context.getVisibleContactSources(): ArrayList<String> {
|
|||
val sources = ContactsHelper(this).getDeviceContactSources()
|
||||
val phoneSecret = getString(R.string.phone_storage_hidden)
|
||||
sources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
|
||||
val sourceNames = ArrayList(sources).map { if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.name }.toMutableList() as ArrayList<String>
|
||||
sourceNames.removeAll(config.ignoredContactSources)
|
||||
val ignoredContactSources = config.ignoredContactSources
|
||||
val sourceNames = ArrayList(sources).filter { !ignoredContactSources.contains(it.getFullIdentifier()) }
|
||||
.map { if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.name }.toMutableList() as ArrayList<String>
|
||||
return sourceNames
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,8 @@ class ContactsHelper(val context: Context) {
|
|||
if (cursor?.moveToFirst() == true) {
|
||||
do {
|
||||
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: ""
|
||||
if (ignoredSources.contains(accountName)) {
|
||||
val accountType = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_TYPE) ?: ""
|
||||
if (ignoredSources.contains("$accountName:$accountType")) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -884,7 +885,8 @@ class ContactsHelper(val context: Context) {
|
|||
CommonDataKinds.StructuredName.PHOTO_URI,
|
||||
CommonDataKinds.StructuredName.PHOTO_THUMBNAIL_URI,
|
||||
CommonDataKinds.StructuredName.STARRED,
|
||||
ContactsContract.RawContacts.ACCOUNT_NAME
|
||||
ContactsContract.RawContacts.ACCOUNT_NAME,
|
||||
ContactsContract.RawContacts.ACCOUNT_TYPE
|
||||
)
|
||||
|
||||
private fun getSortString(): String {
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package com.simplemobiletools.contacts.pro.models
|
||||
|
||||
data class ContactSource(var name: String, var type: String, var publicName: String)
|
||||
import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE
|
||||
|
||||
data class ContactSource(var name: String, var type: String, var publicName: String) {
|
||||
fun getFullIdentifier(): String {
|
||||
return if (type == SMT_PRIVATE) {
|
||||
type
|
||||
} else {
|
||||
"$name:$type"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue