Merge "Disable first name bolding"
diff --git a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
index 94150b3..eeafdda 100644
--- a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
+++ b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
@@ -67,9 +67,8 @@
     }
 
     /**
-     * Returns the display name of the contact. Depending on the preference for
-     * display name ordering, the contact's first name may be bolded if
-     * possible. Returns empty string if there is no display name.
+     * Returns the display name of the contact, using the current display order setting.
+     * Returns res/string/missing_name if there is no display name.
      */
     public static CharSequence getDisplayName(Context context, Result contactData) {
         CharSequence displayName = contactData.getDisplayName();
@@ -78,25 +77,9 @@
         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;
-                }
+                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;
-                }
+                styledName = altDisplayName;
             }
         } else {
             styledName = context.getResources().getString(R.string.missing_name);
diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java
index c48e3c9..a448f4e 100644
--- a/src/com/android/contacts/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/editor/TextFieldsEditorView.java
@@ -184,9 +184,6 @@
             }
             int inputType = field.inputType;
             fieldView.setInputType(inputType);
-            if (field.isFullName) {
-                fieldView.addTextChangedListener(new NameFormattingTextWatcher());
-            }
             if (inputType == InputType.TYPE_CLASS_PHONE) {
                 fieldView.addTextChangedListener(new PhoneNumberFormattingTextWatcher(
                         ContactsUtils.getCurrentCountryIso(mContext)));
@@ -353,62 +350,6 @@
         };
     }
 
-    private class NameFormattingTextWatcher implements TextWatcher {
-
-
-        @Override
-        public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
-
-        @Override
-        public void onTextChanged(CharSequence s, int start, int before, int count) {}
-
-        @Override
-        public void afterTextChanged(Editable s) {
-            String displayName = s.toString();
-            Map<String, String> structuredName = NameConverter.displayNameToStructuredName(
-                    getContext(), displayName);
-            String givenName = structuredName.get(StructuredName.GIVEN_NAME);
-            if (!TextUtils.isEmpty(givenName)) {
-                int spanStart = -1;
-                int spanEnd = -1;
-                if (displayName.startsWith(givenName + " ")) {
-                    spanStart = 0;
-                    spanEnd = givenName.length();
-                } else {
-                    spanStart = displayName.lastIndexOf(" " + givenName);
-                    if (spanStart > -1) {
-                        spanStart++;
-                        spanEnd = spanStart + givenName.length();
-                    }
-                }
-
-                // If the requested range is already bolded, don't make any changes.
-                if (spanStart > -1) {
-                    StyleSpan[] existingSpans = s.getSpans(0, s.length(), StyleSpan.class);
-                    for (StyleSpan span : existingSpans) {
-                        if (span.getStyle() == Typeface.BOLD
-                                && s.getSpanStart(span.getUnderlying()) == spanStart
-                                && s.getSpanEnd(span.getUnderlying()) == spanEnd) {
-                            // Nothing to do - the correct portion is already bolded.
-                            return;
-                        }
-                    }
-
-                    // Clear any existing bold style spans.
-                    for (StyleSpan span : existingSpans) {
-                        if (span.getStyle() == Typeface.BOLD) {
-                            s.removeSpan(span);
-                        }
-                    }
-
-                    // Set the new bold span.
-                    s.setSpan(new StyleSpan(Typeface.BOLD), spanStart, spanEnd,
-                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-                }
-            }
-        }
-    }
-
     @Override
     public void clearAllFields() {
         if (mFieldEditTexts != null) {
diff --git a/src/com/android/contacts/format/DisplayNameFormatter.java b/src/com/android/contacts/format/DisplayNameFormatter.java
index 07577f2..e525217 100644
--- a/src/com/android/contacts/format/DisplayNameFormatter.java
+++ b/src/com/android/contacts/format/DisplayNameFormatter.java
@@ -65,15 +65,6 @@
 
     public CharSequence getDisplayName(int displayOrder, boolean highlightingEnabled,
             char[] highlightedPrefix) {
-        // Compute the point at which name and alternate name overlap (for bolding).
-        int overlapPoint = FormatUtils.overlapPoint(mNameBuffer, mAlternateNameBuffer);
-        int boldStart = 0;
-        int boldEnd = overlapPoint;
-        if (displayOrder == ContactsContract.Preferences.DISPLAY_ORDER_ALTERNATIVE) {
-            boldStart = overlapPoint;
-            boldEnd = mNameBuffer.sizeCopied;
-        }
-
         int size = mNameBuffer.sizeCopied;
         if (size == 0) {
             return mUnknownNameText;
@@ -93,11 +84,6 @@
         if (highlightedPrefix != null) {
             text = mPrefixHighlighter.apply(text, highlightedPrefix);
         }
-        if (overlapPoint > 0) {
-            // Bold the first or last name.
-            text = FormatUtils.applyStyleToSpan(Typeface.BOLD, text, boldStart, boldEnd,
-                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-        }
         return text;
     }
 }