Merge "Fix a rare null reference exception"
diff --git a/src/com/android/contacts/detail/ContactDetailHeaderView.java b/src/com/android/contacts/detail/ContactDetailHeaderView.java
index b88b43e..795ed62 100644
--- a/src/com/android/contacts/detail/ContactDetailHeaderView.java
+++ b/src/com/android/contacts/detail/ContactDetailHeaderView.java
@@ -200,26 +200,28 @@
// Check the preference for display name ordering, and bold the contact's first name if
// possible.
ContactsPreferences prefs = new ContactsPreferences(getContext());
- CharSequence styledName;
- if (prefs.getDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
- int overlapPoint = FormatUtils.overlapPoint(
- displayName.toString(), altDisplayName.toString());
- if (overlapPoint > 0) {
- styledName = FormatUtils.applyStyleToSpan(Typeface.BOLD,
- displayName, 0, overlapPoint, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ CharSequence styledName = "";
+ if (!TextUtils.isEmpty(displayName) && !TextUtils.isEmpty(altDisplayName)) {
+ if (prefs.getDisplayOrder() == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) {
+ int overlapPoint = FormatUtils.overlapPoint(
+ displayName.toString(), altDisplayName.toString());
+ if (overlapPoint > 0) {
+ styledName = FormatUtils.applyStyleToSpan(Typeface.BOLD,
+ displayName, 0, overlapPoint, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ } else {
+ styledName = displayName;
+ }
} else {
- styledName = displayName;
- }
- } else {
- // Displaying alternate display name.
- int overlapPoint = FormatUtils.overlapPoint(
- altDisplayName.toString(), displayName.toString());
- if (overlapPoint > 0) {
- styledName = FormatUtils.applyStyleToSpan(Typeface.BOLD,
- altDisplayName, overlapPoint, altDisplayName.length(),
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- } else {
- styledName = altDisplayName;
+ // Displaying alternate display name.
+ int overlapPoint = FormatUtils.overlapPoint(
+ altDisplayName.toString(), displayName.toString());
+ if (overlapPoint > 0) {
+ styledName = FormatUtils.applyStyleToSpan(Typeface.BOLD,
+ altDisplayName, overlapPoint, altDisplayName.length(),
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ } else {
+ styledName = altDisplayName;
+ }
}
}
mDisplayNameView.setText(styledName);
diff --git a/tests/src/com/android/contacts/ContactLoaderTest.java b/tests/src/com/android/contacts/ContactLoaderTest.java
index 503fc64..0e0e2b0 100644
--- a/tests/src/com/android/contacts/ContactLoaderTest.java
+++ b/tests/src/com/android/contacts/ContactLoaderTest.java
@@ -29,10 +29,12 @@
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.StatusUpdates;
import android.test.LoaderTestCase;
+import android.test.suitebuilder.annotation.LargeTest;
/**
* Runs ContactLoader tests for the the contact-detail and editor view.
*/
+@LargeTest
public class ContactLoaderTest extends LoaderTestCase {
ContactsMockContext mMockContext;
MockContentProvider mContactsProvider;
@@ -265,7 +267,8 @@
mContactsProvider.expectQuery(baseUri)
.withProjection(new String[] {
Contacts.NAME_RAW_CONTACT_ID, Contacts.DISPLAY_NAME_SOURCE,
- Contacts.LOOKUP_KEY, Contacts.DISPLAY_NAME, Contacts.PHONETIC_NAME,
+ Contacts.LOOKUP_KEY, Contacts.DISPLAY_NAME,
+ Contacts.DISPLAY_NAME_ALTERNATIVE, Contacts.PHONETIC_NAME,
Contacts.PHOTO_ID, Contacts.STARRED, Contacts.CONTACT_PRESENCE,
Contacts.CONTACT_STATUS, Contacts.CONTACT_STATUS_TIMESTAMP,
Contacts.CONTACT_STATUS_RES_PACKAGE, Contacts.CONTACT_STATUS_LABEL,
@@ -299,7 +302,7 @@
.withSortOrder(Contacts.Entity.RAW_CONTACT_ID)
.returnRow(
rawContactId, 40,
- "aa%12%@!", "John Doe", "jdo",
+ "aa%12%@!", "John Doe", "Doe, John", "jdo",
0, 0, StatusUpdates.AVAILABLE,
"Having lunch", 0,
"mockPkg1", 10,
diff --git a/tests/src/com/android/contacts/activities/CallLogActivityTests.java b/tests/src/com/android/contacts/activities/CallLogActivityTests.java
index 3eedef0..ef1afd0 100644
--- a/tests/src/com/android/contacts/activities/CallLogActivityTests.java
+++ b/tests/src/com/android/contacts/activities/CallLogActivityTests.java
@@ -25,6 +25,7 @@
import android.graphics.drawable.BitmapDrawable;
import android.provider.CallLog.Calls;
import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.view.View;
import android.widget.FrameLayout;
@@ -44,7 +45,7 @@
* adb shell am instrument \
* -w com.android.contacts.tests/android.test.InstrumentationTestRunner
*/
-
+@LargeTest
public class CallLogActivityTests
extends ActivityInstrumentationTestCase2<CallLogActivity> {
static private final String TAG = "CallLogActivityTests";