Merge pull request #590 from ismailnurudeen/fix/contacts-without-num

fix: prevent showing of contacts without phone numbers.
This commit is contained in:
Tibor Kaputa 2023-04-19 16:05:47 +02:00 committed by GitHub
commit 08d09bc18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 11 deletions

View File

@ -140,9 +140,8 @@ class DialpadActivity : SimpleActivity() {
dialpad_input.requestFocus()
dialpad_input.disableKeyboard()
ContactsHelper(this).getContacts { allContacts ->
val contactsWithNumber = allContacts.filter { it.phoneNumbers.isNotEmpty() }.toMutableList() as ArrayList<Contact>
gotContacts(contactsWithNumber)
ContactsHelper(this).getContacts(showOnlyContactsWithNumbers = true) { allContacts ->
gotContacts(allContacts)
}

View File

@ -28,7 +28,7 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
speedDialValues = config.getSpeedDialValues()
updateAdapter()
ContactsHelper(this).getContacts(false) { contacts ->
ContactsHelper(this).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
allContacts = contacts
}

View File

@ -31,7 +31,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
processDataIfReady()
}
contactHelper.getContacts(getAll = true) {
contactHelper.getContacts(getAll = true, showOnlyContactsWithNumbers = true) {
it.mapTo(contacts) { contact -> contact.copy() }
val privateCursor = activity.getMyContactsCursor(false, true)
val privateContacts = MyContactsContentProvider.getContacts(activity, privateCursor)

View File

@ -62,7 +62,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
override fun refreshItems(callback: (() -> Unit)?) {
val privateCursor = context?.getMyContactsCursor(false, true)
ContactsHelper(context).getContacts { contacts ->
ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
allContacts = contacts
if (SMT_PRIVATE !in context.baseConfig.ignoredContactSources) {
@ -159,7 +159,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
if (it) {
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
fragment_placeholder_2.text = context.getString(R.string.create_new_contact)
ContactsHelper(context).getContacts(false) { contacts ->
ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
activity?.runOnUiThread {
gotContacts(contacts)
}

View File

@ -49,7 +49,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
}
override fun refreshItems(callback: (() -> Unit)?) {
ContactsHelper(context).getContacts { contacts ->
ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
allContacts = contacts
if (SMT_PRIVATE !in context.baseConfig.ignoredContactSources) {

View File

@ -50,7 +50,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
val privateCursor = context?.getMyContactsCursor(false, true)
val groupSubsequentCalls = context?.config?.groupSubsequentCalls ?: false
RecentsHelper(context).getRecentCalls(groupSubsequentCalls) { recents ->
ContactsHelper(context).getContacts { contacts ->
ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
recents.filter { it.phoneNumber == it.name }.forEach { recent ->

View File

@ -35,7 +35,7 @@ fun getCallContact(context: Context, call: Call?, callback: (CallContact) -> Uni
val uri = Uri.decode(handle)
if (uri.startsWith("tel:")) {
val number = uri.substringAfter("tel:")
ContactsHelper(context).getContacts{ contacts ->
ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
if (privateContacts.isNotEmpty()) {
contacts.addAll(privateContacts)

View File

@ -24,7 +24,7 @@ class RecentsHelper(private val context: Context) {
return@ensureBackgroundThread
}
ContactsHelper(context).getContacts(false) { contacts ->
ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts ->
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
if (privateContacts.isNotEmpty()) {
contacts.addAll(privateContacts)