show the contact nickname at the View screen if available

This commit is contained in:
tibbi 2018-08-12 21:08:09 +02:00
parent 49a4ffe9b5
commit 0335bdf10d
4 changed files with 23 additions and 3 deletions

View File

@ -198,7 +198,11 @@ class ViewContactActivity : ContactActivity() {
contact_suffix.text = suffix
contact_suffix.beVisibleIf(suffix.isNotEmpty() && showFields and SHOW_SUFFIX_FIELD != 0)
if (contact_prefix.isGone() && contact_first_name.isGone() && contact_middle_name.isGone() && contact_surname.isGone() && contact_suffix.isGone()) {
contact_nickname.text = nickname
contact_nickname.beVisibleIf(nickname.isNotEmpty() && showFields and SHOW_NICKNAME_FIELD != 0)
if (contact_prefix.isGone() && contact_first_name.isGone() && contact_middle_name.isGone() && contact_surname.isGone() && contact_suffix.isGone()
&& contact_nickname.isGone()) {
contact_name_image.beInvisible()
(contact_photo.layoutParams as RelativeLayout.LayoutParams).bottomMargin = resources.getDimension(R.dimen.medium_margin).toInt()
}

View File

@ -240,6 +240,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
(fragment_list.adapter as? ContactsAdapter)?.apply {
val filtered = contactsIgnoringSearch.filter {
getProperText(it.getFullName(), shouldNormalize).contains(text, true) ||
getProperText(it.nickname, shouldNormalize).contains(text, true) ||
it.phoneNumbers.any { it.value.contains(text, true) } ||
it.emails.any { it.value.contains(text, true) } ||
it.addresses.any { getProperText(it.value, shouldNormalize).contains(text, true) } ||

View File

@ -99,7 +99,7 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m
val newEmails = ArrayList<Email>()
emails.mapTo(newEmails) { Email(it.value, 0) }
return copy(id = 0, prefix = "", firstName = getFullName().toLowerCase(), middleName = "", surname = "", suffix = "", photoUri = "",
return copy(id = 0, prefix = "", firstName = getFullName().toLowerCase(), middleName = "", surname = "", suffix = "", nickname = "", photoUri = "",
phoneNumbers = newPhoneNumbers, events = ArrayList(), addresses = ArrayList(), emails = newEmails, source = "", starred = 0,
contactId = 0, thumbnailUri = "", notes = "", groups = ArrayList(), websites = ArrayList(), organization = Organization("", "")).hashCode()
}

View File

@ -166,6 +166,21 @@
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/contact_nickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_suffix"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/contact_name_image"
android:lines="1"
android:maxLines="1"
android:paddingBottom="@dimen/normal_margin"
android:paddingLeft="@dimen/small_margin"
android:paddingTop="@dimen/normal_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"/>
<ImageView
android:id="@+id/contact_numbers_image"
android:layout_width="@dimen/contact_icons_size"
@ -181,7 +196,7 @@
android:id="@+id/contact_numbers_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_suffix"
android:layout_below="@+id/contact_nickname"
android:layout_toRightOf="@+id/contact_numbers_image"
android:orientation="vertical"
android:paddingLeft="@dimen/small_margin"/>