mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-03 09:17:34 +01:00
do not fill out Contact emails at the initial screen, they arent used
This commit is contained in:
parent
9f90b35750
commit
896acbbc0b
@ -58,8 +58,8 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||||||
|
|
||||||
val photoUri = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.PHOTO_URI) ?: ""
|
val photoUri = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.PHOTO_URI) ?: ""
|
||||||
val number = ArrayList<PhoneNumber>() // proper value is obtained below
|
val number = ArrayList<PhoneNumber>() // proper value is obtained below
|
||||||
val emails = ArrayList<Email>() // proper value is obtained below
|
val emails = ArrayList<Email>()
|
||||||
val events = ArrayList<Event>() // proper value is obtained below
|
val events = ArrayList<Event>()
|
||||||
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME)
|
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME)
|
||||||
val contact = Contact(id, firstName, middleName, surname, photoUri, number, emails, events, accountName)
|
val contact = Contact(id, firstName, middleName, surname, photoUri, number, emails, events, accountName)
|
||||||
contacts.put(id, contact)
|
contacts.put(id, contact)
|
||||||
@ -71,15 +71,8 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
val emails = getEmails()
|
|
||||||
var size = emails.size()
|
|
||||||
for (i in 0 until size) {
|
|
||||||
val key = emails.keyAt(i)
|
|
||||||
contacts[key]?.emails = emails.valueAt(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
val phoneNumbers = getPhoneNumbers()
|
val phoneNumbers = getPhoneNumbers()
|
||||||
size = phoneNumbers.size()
|
val size = phoneNumbers.size()
|
||||||
for (i in 0 until size) {
|
for (i in 0 until size) {
|
||||||
val key = phoneNumbers.keyAt(i)
|
val key = phoneNumbers.keyAt(i)
|
||||||
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
||||||
@ -126,32 +119,30 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||||||
return phoneNumbers
|
return phoneNumbers
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getEmails(contactId: Int? = null): SparseArray<ArrayList<Email>> {
|
private fun getEmails(contactId: Int): SparseArray<ArrayList<Email>> {
|
||||||
val emails = SparseArray<ArrayList<Email>>()
|
val emails = SparseArray<ArrayList<Email>>()
|
||||||
val uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI
|
val uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
ContactsContract.Data.RAW_CONTACT_ID,
|
|
||||||
ContactsContract.CommonDataKinds.Email.DATA,
|
ContactsContract.CommonDataKinds.Email.DATA,
|
||||||
ContactsContract.CommonDataKinds.Email.TYPE
|
ContactsContract.CommonDataKinds.Email.TYPE
|
||||||
)
|
)
|
||||||
|
|
||||||
val selection = if (contactId == null) null else "${ContactsContract.Data.RAW_CONTACT_ID} = ?"
|
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ?"
|
||||||
val selectionArgs = if (contactId == null) null else arrayOf(contactId.toString())
|
val selectionArgs = arrayOf(contactId.toString())
|
||||||
|
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
try {
|
||||||
cursor = activity.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
cursor = activity.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||||
if (cursor?.moveToFirst() == true) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
do {
|
do {
|
||||||
val id = cursor.getIntValue(ContactsContract.Data.RAW_CONTACT_ID)
|
|
||||||
val email = cursor.getStringValue(ContactsContract.CommonDataKinds.Email.DATA)
|
val email = cursor.getStringValue(ContactsContract.CommonDataKinds.Email.DATA)
|
||||||
val type = cursor.getIntValue(ContactsContract.CommonDataKinds.Email.TYPE)
|
val type = cursor.getIntValue(ContactsContract.CommonDataKinds.Email.TYPE)
|
||||||
|
|
||||||
if (emails[id] == null) {
|
if (emails[contactId] == null) {
|
||||||
emails.put(id, ArrayList())
|
emails.put(contactId, ArrayList())
|
||||||
}
|
}
|
||||||
|
|
||||||
emails[id]!!.add(Email(email, type))
|
emails[contactId]!!.add(Email(email, type))
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user