mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
split the name at the Contact activity layout too
This commit is contained in:
@ -135,7 +135,9 @@ class ContactActivity : SimpleActivity() {
|
||||
private fun setupEditContact() {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||
supportActionBar?.title = resources.getString(R.string.edit_contact)
|
||||
contact_name.setText(contact!!.firstName)
|
||||
contact_first_name.setText(contact!!.firstName)
|
||||
contact_middle_name.setText(contact!!.middleName)
|
||||
contact_surname.setText(contact!!.surname)
|
||||
contact_number.setText(contact!!.number)
|
||||
contact_email.setText(contact!!.email)
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||
|
||||
private fun setupView(view: View, contact: Contact) {
|
||||
view.apply {
|
||||
contact_name.text = contact.getFullName()
|
||||
contact_name.setTextColor(textColor)
|
||||
contact_first_name.text = contact.getFullName()
|
||||
contact_first_name.setTextColor(textColor)
|
||||
contact_number.text = contact.number
|
||||
contact_number.setTextColor(textColor)
|
||||
|
||||
|
@ -58,15 +58,15 @@ class ContactsHelper(val activity: SimpleActivity) {
|
||||
val id = cursor.getIntValue(ContactsContract.CommonDataKinds.StructuredName.CONTACT_ID)
|
||||
val firstName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME) ?: ""
|
||||
val middleName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME) ?: ""
|
||||
val familyName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
|
||||
if (firstName.isEmpty() && middleName.isEmpty() && familyName.isEmpty())
|
||||
val surname = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
|
||||
if (firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty())
|
||||
continue
|
||||
|
||||
val photoUri = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.PHOTO_URI) ?: ""
|
||||
val number = "" // proper value is obtained below
|
||||
val email = "" // proper value is obtained below
|
||||
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME)
|
||||
val contact = Contact(id, firstName, middleName, familyName, photoUri, number, email, accountName)
|
||||
val contact = Contact(id, firstName, middleName, surname, photoUri, number, email, accountName)
|
||||
contacts.put(id, contact)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
@ -203,12 +203,12 @@ class ContactsHelper(val activity: SimpleActivity) {
|
||||
if (cursor?.moveToFirst() == true) {
|
||||
val firstName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME) ?: ""
|
||||
val middleName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME) ?: ""
|
||||
val familyName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
|
||||
val surname = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
|
||||
val photoUri = cursor.getStringValue(ContactsContract.CommonDataKinds.Phone.PHOTO_URI) ?: ""
|
||||
val number = getContactNumber(id)
|
||||
val email = getContactEmail(id)
|
||||
val accountName = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME)
|
||||
return Contact(id, firstName, middleName, familyName, photoUri, number, email, accountName)
|
||||
return Contact(id, firstName, middleName, surname, photoUri, number, email, accountName)
|
||||
}
|
||||
} finally {
|
||||
cursor?.close()
|
||||
|
@ -3,7 +3,7 @@ package com.simplemobiletools.contacts.models
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_NUMBER
|
||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
||||
|
||||
data class Contact(val id: Int, var firstName: String, var middleName: String, var familyName: String, var photoUri: String, var number: String,
|
||||
data class Contact(val id: Int, var firstName: String, var middleName: String, var surname: String, var photoUri: String, var number: String,
|
||||
var email: String, var source: String) : Comparable<Contact> {
|
||||
companion object {
|
||||
var sorting: Int = 0
|
||||
@ -38,6 +38,6 @@ data class Contact(val id: Int, var firstName: String, var middleName: String, v
|
||||
if (middleName.isNotEmpty()) {
|
||||
name += " $middleName"
|
||||
}
|
||||
return "$name $familyName".trim()
|
||||
return "$name $surname".trim()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user