From 3cfbe5f776d589e25631758777676917d7422e9a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Apr 2018 17:45:38 +0200 Subject: [PATCH] allow modifying contact prefix and suffix --- .../activities/EditContactActivity.kt | 4 ++ .../contacts/helpers/ContactsHelper.kt | 4 ++ .../main/res/layout/activity_edit_contact.xml | 41 +++++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) 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 cdd0895f..e0a9d5d5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/EditContactActivity.kt @@ -242,9 +242,11 @@ class EditContactActivity : ContactActivity() { private fun setupEditContact() { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) supportActionBar?.title = resources.getString(R.string.edit_contact) + contact_prefix.setText(contact!!.prefix) contact_first_name.setText(contact!!.firstName) contact_middle_name.setText(contact!!.middleName) contact_surname.setText(contact!!.surname) + contact_suffix.setText(contact!!.suffix) contact_source.text = getPublicContactSource(contact!!.source) setupPhoneNumbers() @@ -599,9 +601,11 @@ class EditContactActivity : ContactActivity() { contact!!.apply { val oldPhotoUri = photoUri + prefix = contact_prefix.value firstName = contact_first_name.value middleName = contact_middle_name.value surname = contact_surname.value + suffix = contact_suffix.value photoUri = currentContactPhotoPath phoneNumbers = getFilledPhoneNumbers() emails = getFilledEmails() 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 8054745b..6c393f7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -690,9 +690,11 @@ class ContactsHelper(val activity: BaseSimpleActivity) { val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = ?" val selectionArgs = arrayOf(contact.id.toString(), CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) withSelection(selection, selectionArgs) + withValue(CommonDataKinds.StructuredName.PREFIX, contact.prefix) withValue(CommonDataKinds.StructuredName.GIVEN_NAME, contact.firstName) withValue(CommonDataKinds.StructuredName.MIDDLE_NAME, contact.middleName) withValue(CommonDataKinds.StructuredName.FAMILY_NAME, contact.surname) + withValue(CommonDataKinds.StructuredName.SUFFIX, contact.suffix) operations.add(build()) } @@ -918,9 +920,11 @@ class ContactsHelper(val activity: BaseSimpleActivity) { ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).apply { withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) + withValue(CommonDataKinds.StructuredName.PREFIX, contact.prefix) withValue(CommonDataKinds.StructuredName.GIVEN_NAME, contact.firstName) withValue(CommonDataKinds.StructuredName.MIDDLE_NAME, contact.middleName) withValue(CommonDataKinds.StructuredName.FAMILY_NAME, contact.surname) + withValue(CommonDataKinds.StructuredName.SUFFIX, contact.suffix) operations.add(build()) } diff --git a/app/src/main/res/layout/activity_edit_contact.xml b/app/src/main/res/layout/activity_edit_contact.xml index d6b7e5ad..7b70f9be 100644 --- a/app/src/main/res/layout/activity_edit_contact.xml +++ b/app/src/main/res/layout/activity_edit_contact.xml @@ -18,7 +18,8 @@ + android:layout_height="@dimen/contact_photo_size" + android:layout_marginBottom="@dimen/normal_margin"/> + + + +