diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt index 5acf55af..61bca85f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt @@ -150,7 +150,7 @@ class EditContactActivity : ContactActivity() { if (contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && (action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT)) { val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: "" - contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE)) + contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, "")) contact!!.firstName = intent.extras.get(KEY_NAME)?.toString() ?: "" @@ -754,7 +754,7 @@ class EditContactActivity : ContactActivity() { val numberType = getPhoneNumberTypeId(numberHolder.contact_number_type.value) if (number.isNotEmpty()) { - phoneNumbers.add(PhoneNumber(number, numberType)) + phoneNumbers.add(PhoneNumber(number, numberType, "")) } } return phoneNumbers @@ -769,7 +769,7 @@ class EditContactActivity : ContactActivity() { val emailType = getEmailTypeId(emailHolder.contact_email_type.value) if (email.isNotEmpty()) { - emails.add(Email(email, emailType)) + emails.add(Email(email, emailType, "")) } } return emails @@ -784,7 +784,7 @@ class EditContactActivity : ContactActivity() { val addressType = getAddressTypeId(addressHolder.contact_address_type.value) if (address.isNotEmpty()) { - addresses.add(Address(address, addressType)) + addresses.add(Address(address, addressType, "")) } } return addresses @@ -955,7 +955,7 @@ class EditContactActivity : ContactActivity() { private fun parseEmail(contentValues: ContentValues) { val type = contentValues.getAsInteger(CommonDataKinds.Email.DATA2) ?: DEFAULT_EMAIL_TYPE val emailValue = contentValues.getAsString(CommonDataKinds.Email.DATA1) ?: return - val email = Email(emailValue, type) + val email = Email(emailValue, type, "") contact!!.emails.add(email) } @@ -963,7 +963,7 @@ class EditContactActivity : ContactActivity() { val type = contentValues.getAsInteger(CommonDataKinds.StructuredPostal.DATA2) ?: DEFAULT_ADDRESS_TYPE val addressValue = contentValues.getAsString(CommonDataKinds.StructuredPostal.DATA4) ?: contentValues.getAsString(CommonDataKinds.StructuredPostal.DATA1) ?: return - val address = Address(addressValue, type) + val address = Address(addressValue, type, "") contact!!.addresses.add(address) } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt index f4af0e7e..6a27df01 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ViewContactActivity.kt @@ -57,7 +57,6 @@ class ViewContactActivity : ContactActivity() { return true } - override fun onOptionsItemSelected(item: MenuItem): Boolean { if (contact == null) { return true diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 17d26c16..b3d441b6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -202,7 +202,8 @@ class ContactsHelper(val activity: Activity) { val projection = arrayOf( ContactsContract.Data.RAW_CONTACT_ID, CommonDataKinds.Phone.NUMBER, - CommonDataKinds.Phone.TYPE + CommonDataKinds.Phone.TYPE, + CommonDataKinds.Phone.LABEL ) val selection = if (contactId == null) getSourcesSelection() else "${ContactsContract.Data.RAW_CONTACT_ID} = ?" @@ -216,12 +217,13 @@ class ContactsHelper(val activity: Activity) { val id = cursor.getIntValue(ContactsContract.Data.RAW_CONTACT_ID) val number = cursor.getStringValue(CommonDataKinds.Phone.NUMBER) ?: continue val type = cursor.getIntValue(CommonDataKinds.Phone.TYPE) + val label = cursor.getStringValue(CommonDataKinds.Phone.LABEL) ?: "" if (phoneNumbers[id] == null) { phoneNumbers.put(id, ArrayList()) } - val phoneNumber = PhoneNumber(number, type) + val phoneNumber = PhoneNumber(number, type, label) phoneNumbers[id].add(phoneNumber) } while (cursor.moveToNext()) } @@ -270,7 +272,8 @@ class ContactsHelper(val activity: Activity) { val projection = arrayOf( ContactsContract.Data.RAW_CONTACT_ID, CommonDataKinds.Email.DATA, - CommonDataKinds.Email.TYPE + CommonDataKinds.Email.TYPE, + CommonDataKinds.Email.LABEL ) val selection = if (contactId == null) getSourcesSelection() else "${ContactsContract.Data.RAW_CONTACT_ID} = ?" @@ -284,12 +287,13 @@ class ContactsHelper(val activity: Activity) { val id = cursor.getIntValue(ContactsContract.Data.RAW_CONTACT_ID) val email = cursor.getStringValue(CommonDataKinds.Email.DATA) ?: continue val type = cursor.getIntValue(CommonDataKinds.Email.TYPE) + val label = cursor.getStringValue(CommonDataKinds.Email.LABEL) ?: "" if (emails[id] == null) { emails.put(id, ArrayList()) } - emails[id]!!.add(Email(email, type)) + emails[id]!!.add(Email(email, type, label)) } while (cursor.moveToNext()) } } catch (e: Exception) { @@ -307,7 +311,8 @@ class ContactsHelper(val activity: Activity) { val projection = arrayOf( ContactsContract.Data.RAW_CONTACT_ID, CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS, - CommonDataKinds.StructuredPostal.TYPE + CommonDataKinds.StructuredPostal.TYPE, + CommonDataKinds.StructuredPostal.LABEL ) val selection = if (contactId == null) getSourcesSelection() else "${ContactsContract.Data.RAW_CONTACT_ID} = ?" @@ -321,12 +326,13 @@ class ContactsHelper(val activity: Activity) { val id = cursor.getIntValue(ContactsContract.Data.RAW_CONTACT_ID) val address = cursor.getStringValue(CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS) ?: continue val type = cursor.getIntValue(CommonDataKinds.StructuredPostal.TYPE) + val label = cursor.getStringValue(CommonDataKinds.StructuredPostal.LABEL) ?: "" if (addresses[id] == null) { addresses.put(id, ArrayList()) } - addresses[id]!!.add(Address(address, type)) + addresses[id]!!.add(Address(address, type, label)) } while (cursor.moveToNext()) } } catch (e: Exception) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt index d247b0ba..fc21a2e0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt @@ -50,14 +50,14 @@ class VcfImporter(val activity: SimpleActivity) { ezContact.telephoneNumbers.forEach { val type = getPhoneNumberTypeId(it.types.firstOrNull()?.value ?: MOBILE) val number = it.text - phoneNumbers.add(PhoneNumber(number, type)) + phoneNumbers.add(PhoneNumber(number, type, "")) } val emails = ArrayList() ezContact.emails.forEach { val type = getEmailTypeId(it.types.firstOrNull()?.value ?: HOME) val email = it.value - emails.add(Email(email, type)) + emails.add(Email(email, type, "")) } val addresses = ArrayList
() @@ -65,7 +65,7 @@ class VcfImporter(val activity: SimpleActivity) { val type = getAddressTypeId(it.types.firstOrNull()?.value ?: HOME) val address = it.streetAddress if (address?.isNotEmpty() == true) { - addresses.add(Address(address, type)) + addresses.add(Address(address, type, "")) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Address.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Address.kt index 7571a228..cc07321b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Address.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Address.kt @@ -1,3 +1,3 @@ package com.simplemobiletools.contacts.models -data class Address(var value: String, var type: Int) +data class Address(var value: String, var type: Int, var label: String) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt index 6a18a265..ccf31bca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt @@ -94,10 +94,10 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m fun getHashToCompare(): Int { val newPhoneNumbers = ArrayList() - phoneNumbers.mapTo(newPhoneNumbers) { PhoneNumber(it.value.replace(PHONE_NUMBER_PATTERN.toRegex(), ""), 0) } + phoneNumbers.mapTo(newPhoneNumbers) { PhoneNumber(it.value.replace(PHONE_NUMBER_PATTERN.toRegex(), ""), 0, "") } val newEmails = ArrayList() - emails.mapTo(newEmails) { Email(it.value, 0) } + emails.mapTo(newEmails) { Email(it.value, 0, "") } return copy(id = 0, prefix = "", firstName = getFullName().toLowerCase(), middleName = "", surname = "", suffix = "", nickname = "", photoUri = "", phoneNumbers = newPhoneNumbers, events = ArrayList(), addresses = ArrayList(), emails = newEmails, source = "", starred = 0, diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt index 268bf7e9..caeafc0d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt @@ -1,3 +1,3 @@ package com.simplemobiletools.contacts.models -data class Email(var value: String, var type: Int) +data class Email(var value: String, var type: Int, var label: String) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/PhoneNumber.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/PhoneNumber.kt index e1eee4cf..1dd39896 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/PhoneNumber.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/PhoneNumber.kt @@ -1,3 +1,3 @@ package com.simplemobiletools.contacts.models -data class PhoneNumber(var value: String, var type: Int) +data class PhoneNumber(var value: String, var type: Int, var label: String)