CallDetailActivity respect display name order
- Updated the CallDetailActivity to choose whether to show last name first
or first name first based on user preferences.
- Modified callLog code to behave in a similar fashion
- Fixed bug in ContactInfoHelperTests
- Rename PhoneCallDetails.name -> PhoneCallDetails.namePrimary
Bug: 19364093
Change-Id: I50971ad0f26f6ede49f1c82965d1b00ce0cba4d3
diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java
index 403c4e8..fb1827d 100644
--- a/src/com/android/dialer/PhoneCallDetails.java
+++ b/src/com/android/dialer/PhoneCallDetails.java
@@ -16,12 +16,14 @@
package com.android.dialer;
+import com.android.contacts.common.preference.ContactsPreferences;
import com.android.dialer.calllog.PhoneNumberDisplayUtil;
import android.content.Context;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.telecom.PhoneAccountHandle;
+import android.text.TextUtils;
/**
* The details of a phone call to be shown in the UI.
@@ -50,7 +52,14 @@
// The duration of the call in milliseconds, or 0 for missed calls.
public long duration;
// The name of the contact, or the empty string.
- public CharSequence name;
+ public CharSequence namePrimary;
+ // The alternative name of the contact, e.g. last name first, or the empty string
+ public CharSequence nameAlternative;
+ /**
+ * The user's preference on name display order, last name first or first time first.
+ * {@see ContactsPreferences}
+ */
+ public int nameDisplayOrder;
// The type of phone, e.g., {@link Phone#TYPE_HOME}, 0 if not available.
public int numberType;
// The custom label associated with the phone number in the contact, or the empty string.
@@ -117,4 +126,18 @@
this.formattedNumber,
this.isVoicemail).toString();
}
+
+ /**
+ * Returns the preferred name for the call details as specified by the
+ * {@link #nameDisplayOrder}
+ *
+ * @return the preferred name
+ */
+ public CharSequence getPreferredName() {
+ if (nameDisplayOrder == ContactsPreferences.DISPLAY_ORDER_PRIMARY
+ || TextUtils.isEmpty(nameAlternative)) {
+ return namePrimary;
+ }
+ return nameAlternative;
+ }
}