allow selecting phoneNumberless private contacts too
This commit is contained in:
parent
64c67c16ca
commit
52f7846867
4 changed files with 11 additions and 9 deletions
|
@ -56,7 +56,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:11624254b2'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:5cec51606a'
|
||||
implementation 'joda-time:joda-time:2.10.3'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:c3de1d040a'
|
||||
|
|
|
@ -34,10 +34,7 @@ import com.simplemobiletools.contacts.pro.extensions.config
|
|||
import com.simplemobiletools.contacts.pro.extensions.getTempFile
|
||||
import com.simplemobiletools.contacts.pro.extensions.handleGenericContactClick
|
||||
import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment
|
||||
import com.simplemobiletools.contacts.pro.helpers.ALL_TABS_MASK
|
||||
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.pro.helpers.VcfExporter
|
||||
import com.simplemobiletools.contacts.pro.helpers.tabsList
|
||||
import com.simplemobiletools.contacts.pro.helpers.*
|
||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
|
|
@ -27,7 +27,10 @@ class MyContactsContentProvider : ContentProvider() {
|
|||
MyContactsContentProvider.COL_ANNIVERSARIES)
|
||||
)
|
||||
|
||||
LocalContactsHelper(context!!).getPrivateSimpleContactsSync(selection == MyContactsContentProvider.FAVORITES_ONLY).forEach {
|
||||
val favoritesOnly = selectionArgs?.getOrNull(0)?.equals("1") ?: false
|
||||
val withPhoneNumbersOnly = selectionArgs?.getOrNull(1)?.equals("1") ?: true
|
||||
|
||||
LocalContactsHelper(context!!).getPrivateSimpleContactsSync(favoritesOnly, withPhoneNumbersOnly).forEach {
|
||||
val phoneNumbers = Gson().toJson(it.phoneNumbers)
|
||||
val birthdays = Gson().toJson(it.birthdays)
|
||||
val anniversaries = Gson().toJson(it.anniversaries)
|
||||
|
|
|
@ -159,8 +159,8 @@ class LocalContactsHelper(val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun convertContactToSimpleContact(contact: Contact?): SimpleContact? {
|
||||
return if (contact == null || contact.phoneNumbers.isEmpty()) {
|
||||
private fun convertContactToSimpleContact(contact: Contact?, withPhoneNumbersOnly: Boolean): SimpleContact? {
|
||||
return if (contact == null || (withPhoneNumbersOnly && contact.phoneNumbers.isEmpty())) {
|
||||
null
|
||||
} else {
|
||||
val phoneNumbers = contact.phoneNumbers.map { it.value }.toMutableList() as ArrayList<String>
|
||||
|
@ -170,5 +170,7 @@ class LocalContactsHelper(val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
fun getPrivateSimpleContactsSync(favoritesOnly: Boolean) = getAllContacts(favoritesOnly).mapNotNull { convertContactToSimpleContact(it) }
|
||||
fun getPrivateSimpleContactsSync(favoritesOnly: Boolean, withPhoneNumbersOnly: Boolean) = getAllContacts(favoritesOnly).mapNotNull {
|
||||
convertContactToSimpleContact(it, withPhoneNumbersOnly)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue