Pixel-perfect fixes for the call details.

- Fix spacing when voicemail or call/SMS are not available.
- Fix font sizes and use textAppearance wherever possible.
- Fix bug with label not appearing in call/SMS.
- Do not show the label if the name is not present.
- Remove dedicated field for phone number in call/SMS (it is not used).

Bug: 5157649
Change-Id: I32b78236b3f85e4a087545ec993f9794093e48b1
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index 714bbd8..157c761 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -83,6 +83,7 @@
             android:id="@+id/voicemail_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:paddingBottom="@dimen/call_log_icon_margin"
             android:layout_below="@id/blue_separator"
             android:background="@android:color/black"
         >
@@ -118,7 +119,7 @@
             android:layout_marginLeft="@dimen/call_detail_contact_name_margin"
             android:gravity="center_vertical"
             android:textColor="?attr/call_log_primary_text_color"
-            android:textSize="18sp"
+            android:textAppearance="?android:attr/textAppearanceMedium"
             android:singleLine="true"
         />
         <ImageButton
@@ -134,6 +135,7 @@
         <FrameLayout android:id="@+id/call_and_sms_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginBottom="@dimen/call_log_icon_margin"
             android:layout_below="@id/voicemail_container"
             android:background="@android:color/black"
         >
@@ -142,7 +144,6 @@
                 android:layout_width="match_parent"
                 android:layout_height="@dimen/call_log_list_item_height"
                 android:orientation="horizontal"
-                android:layout_marginTop="@dimen/call_log_icon_margin"
                 android:gravity="center_vertical"
                 android:background="@drawable/dialpad_background"
             >
@@ -158,31 +159,18 @@
                     android:background="@drawable/btn_dial"
                 >
 
-                    <TextView android:id="@+id/call_and_sms_text1"
+                    <TextView android:id="@+id/call_and_sms_text"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:textAppearance="?android:attr/textAppearanceLarge"
+                        android:textAppearance="?android:attr/textAppearanceMedium"
                     />
 
-                    <LinearLayout android:id="@+id/call_and_sms_line2"
+                    <TextView android:id="@+id/call_and_sms_label"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:orientation="horizontal"
-                    >
-                        <TextView android:id="@+id/call_and_sms_label"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="5dip"
-                            android:textAppearance="?android:attr/textAppearanceSmall"
-                            android:textStyle="bold"
-                        />
-
-                        <TextView android:id="@+id/call_and_sms_number"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:textAppearance="?android:attr/textAppearanceSmall"
-                        />
-                    </LinearLayout>
+                        android:textAppearance="?android:attr/textAppearanceSmall"
+                        android:textAllCaps="true"
+                    />
 
                 </LinearLayout>
 
diff --git a/res/layout/call_detail_history_item.xml b/res/layout/call_detail_history_item.xml
index 674b034..fa5bc28 100644
--- a/res/layout/call_detail_history_item.xml
+++ b/res/layout/call_detail_history_item.xml
@@ -41,6 +41,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginLeft="@dimen/call_log_icon_margin"
+            android:textAppearance="?android:attr/textAppearanceSmall"
             android:textColor="@color/secondary_text_color"
         />
     </LinearLayout>
@@ -48,12 +49,14 @@
         android:id="@+id/date"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceSmall"
         android:textColor="@color/secondary_text_color"
     />
     <TextView
         android:id="@+id/duration"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceSmall"
         android:textColor="@color/secondary_text_color"
     />
 </LinearLayout>
diff --git a/res/layout/playback_layout.xml b/res/layout/playback_layout.xml
index bb32014..161c5bd 100644
--- a/res/layout/playback_layout.xml
+++ b/res/layout/playback_layout.xml
@@ -1,125 +1,119 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:background="@color/voicemail_playback_ui_background"
 >
-    <RelativeLayout
+    <!-- Mute, playback, trash buttons. -->
+    <LinearLayout
+        android:id="@+id/buttons_linear_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:orientation="vertical"
-        android:background="@color/voicemail_playback_ui_background"
+        android:orientation="horizontal"
+        android:layout_alignParentTop="true"
     >
-        <!-- Mute, playback, trash buttons. -->
         <LinearLayout
-            android:id="@+id/buttons_linear_layout"
+            android:layout_width="match_parent"
+            android:layout_height="58dip"
+            android:layout_marginRight="2dip"
+            android:background="@drawable/dialpad_background"
+            android:layout_weight="1"
+        >
+            <ImageButton
+                android:id="@+id/playback_start_stop"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/btn_dial"
+                android:src="@drawable/ic_hold_pause_holo_dark"
+            />
+        </LinearLayout>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="58dip"
+            android:layout_marginLeft="2dip"
+            android:background="@drawable/dialpad_background"
+            android:layout_weight="1"
+        >
+            <ImageButton
+                android:id="@+id/playback_speakerphone"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/btn_dial"
+                android:src="@drawable/ic_sound_holo_dark"
+            />
+        </LinearLayout>
+    </LinearLayout>
+    <RelativeLayout
+        android:id="@+id/seek_container"
+        android:layout_width="match_parent"
+        android:layout_height="80dip"
+        android:background="@drawable/dialpad_background"
+        android:layout_below="@id/buttons_linear_layout"
+        android:layout_marginTop="4dip"
+    >
+        <!-- SeekBar left-right margin decreased from redlines 72dip by 8dip to account for
+             half thumb width (thumb is 16dip).
+             Vertically, SeekBar and rate buttons should be below centre, position achieved by
+             making them centred but giving a difference between top and bottom padding,
+             difference is currently 10dip. -->
+        <SeekBar
+            android:id="@+id/playback_seek"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:orientation="horizontal"
+            android:progressDrawable="@drawable/seekbar_drawable"
+            android:thumb="@drawable/seek_bar_thumb"
+            android:thumbOffset="8dip"
+            android:progress="0"
+            android:paddingLeft="8dip"
+            android:paddingRight="8dip"
+            android:paddingTop="30dip"
+            android:paddingBottom="20dip"
+            android:layout_marginRight="64dip"
+            android:layout_marginLeft="64dip"
+            android:max="0"
+            android:layout_centerVertical="true"
+        />
+        <TextView
+            android:id="@+id/playback_position_text"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:textSize="14sp"
             android:layout_alignParentTop="true"
-        >
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="58dip"
-                android:layout_marginRight="2dip"
-                android:background="@drawable/dialpad_background"
-                android:layout_weight="1"
-            >
-                <ImageButton
-                    android:id="@+id/playback_start_stop"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:background="@drawable/btn_dial"
-                    android:src="@drawable/ic_hold_pause_holo_dark"
-                />
-            </LinearLayout>
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="58dip"
-                android:layout_marginLeft="2dip"
-                android:background="@drawable/dialpad_background"
-                android:layout_weight="1"
-            >
-                <ImageButton
-                    android:id="@+id/playback_speakerphone"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:background="@drawable/btn_dial"
-                    android:src="@drawable/ic_sound_holo_dark"
-                />
-            </LinearLayout>
-        </LinearLayout>
-        <RelativeLayout
-            android:id="@+id/seek_container"
-            android:layout_width="match_parent"
-            android:layout_height="80dip"
-            android:background="@drawable/dialpad_background"
-            android:layout_below="@id/buttons_linear_layout"
-            android:layout_marginTop="4dip"
-        >
-            <!-- SeekBar left-right margin decreased from redlines 72dip by 8dip to account for
-                 half thumb width (thumb is 16dip).
-                 Vertically, SeekBar and rate buttons should be below centre, position achieved by
-                 making them centred but giving a difference between top and bottom padding,
-                 difference is currently 10dip. -->
-            <SeekBar
-                android:id="@+id/playback_seek"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:progressDrawable="@drawable/seekbar_drawable"
-                android:thumb="@drawable/seek_bar_thumb"
-                android:thumbOffset="8dip"
-                android:progress="0"
-                android:paddingLeft="8dip"
-                android:paddingRight="8dip"
-                android:paddingTop="30dip"
-                android:paddingBottom="20dip"
-                android:layout_marginRight="64dip"
-                android:layout_marginLeft="64dip"
-                android:max="0"
-                android:layout_centerVertical="true"
-            />
-            <TextView
-                android:id="@+id/playback_position_text"
-                android:layout_height="wrap_content"
-                android:layout_width="wrap_content"
-                android:textSize="14sp"
-                android:layout_alignParentTop="true"
-                android:layout_centerHorizontal="true"
-                android:layout_marginTop="10dip"
-            />
-            <TextView
-                android:id="@+id/playback_speed_text"
-                android:layout_height="wrap_content"
-                android:layout_width="wrap_content"
-                android:textSize="14sp"
-                android:layout_alignParentTop="true"
-                android:layout_centerHorizontal="true"
-                android:layout_marginTop="10dip"
-                android:alpha="0"
-            />
-            <ImageButton
-                android:id="@+id/rate_decrease_button"
-                android:src="@drawable/ic_minus_holo_dark"
-                android:layout_width="64dip"
-                android:layout_height="wrap_content"
-                android:background="@drawable/btn_dial"
-                android:paddingBottom="19dip"
-                android:paddingTop="29dip"
-                android:layout_alignParentLeft="true"
-                android:layout_centerVertical="true"
-            />
-            <ImageButton
-                android:id="@+id/rate_increase_button"
-                android:src="@drawable/ic_plus_holo_dark"
-                android:layout_width="64dip"
-                android:layout_height="wrap_content"
-                android:background="@drawable/btn_dial"
-                android:paddingBottom="19dip"
-                android:paddingTop="29dip"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-            />
-        </RelativeLayout>
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="10dip"
+        />
+        <TextView
+            android:id="@+id/playback_speed_text"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:textSize="14sp"
+            android:layout_alignParentTop="true"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="10dip"
+            android:alpha="0"
+        />
+        <ImageButton
+            android:id="@+id/rate_decrease_button"
+            android:src="@drawable/ic_minus_holo_dark"
+            android:layout_width="64dip"
+            android:layout_height="wrap_content"
+            android:background="@drawable/btn_dial"
+            android:paddingBottom="19dip"
+            android:paddingTop="29dip"
+            android:layout_alignParentLeft="true"
+            android:layout_centerVertical="true"
+        />
+        <ImageButton
+            android:id="@+id/rate_increase_button"
+            android:src="@drawable/ic_plus_holo_dark"
+            android:layout_width="64dip"
+            android:layout_height="wrap_content"
+            android:background="@drawable/btn_dial"
+            android:paddingBottom="19dip"
+            android:paddingTop="29dip"
+            android:layout_alignParentRight="true"
+            android:layout_centerVertical="true"
+        />
     </RelativeLayout>
-</LinearLayout>
+</RelativeLayout>
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index aa52d91..85e0ff7 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -198,6 +198,7 @@
      * playback.  If it doesn't, then hide the voicemail ui.
      */
     private void optionallyHandleVoicemail() {
+        View voicemailContainer = findViewById(R.id.voicemail_container);
         if (hasVoicemail()) {
             // Has voicemail: add the voicemail fragment.  Add suitable arguments to set the uri
             // to play and optionally start the playback.
@@ -209,6 +210,7 @@
                 fragmentArguments.putBoolean(EXTRA_VOICEMAIL_START_PLAYBACK, true);
             }
             playbackFragment.setArguments(fragmentArguments);
+            voicemailContainer.setVisibility(View.VISIBLE);
             getFragmentManager().beginTransaction()
                     .add(R.id.voicemail_container, playbackFragment).commit();
             mAsyncQueryHandler.startVoicemailStatusQuery(getVoicemailUri());
@@ -216,6 +218,7 @@
         } else {
             // No voicemail uri: hide the status view.
             mStatusMessageView.setVisibility(View.GONE);
+            voicemailContainer.setVisibility(View.GONE);
         }
     }
 
@@ -409,7 +412,8 @@
                             getString(R.string.description_call, nameOrNumber));
 
                     // Only show a label if the number is shown and it is not a SIP address.
-                    if (!TextUtils.isEmpty(firstDetails.number)
+                    if (!TextUtils.isEmpty(firstDetails.name)
+                            && !TextUtils.isEmpty(firstDetails.number)
                             && !PhoneNumberUtils.isUriNumber(firstDetails.number.toString())) {
                         entry.label = Phone.getTypeLabel(mResources, firstDetails.numberType,
                                 firstDetails.numberLabel);
@@ -550,7 +554,6 @@
         public final String primaryDescription;
 
         public CharSequence label = null;
-        public String number = null;
         /** Icon for the secondary action. */
         public int secondaryIcon = 0;
         /** Intent for the secondary action. If not null, an icon must be defined. */
@@ -583,7 +586,7 @@
 
         ImageView icon = (ImageView) convertView.findViewById(R.id.call_and_sms_icon);
         View divider = convertView.findViewById(R.id.call_and_sms_divider);
-        TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text1);
+        TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text);
 
         View mainAction = convertView.findViewById(R.id.call_and_sms_main_action);
         mainAction.setOnClickListener(mPrimaryActionListener);
@@ -603,24 +606,12 @@
         }
         text.setText(entry.text);
 
-        View line2 = convertView.findViewById(R.id.call_and_sms_line2);
-        boolean numberEmpty = TextUtils.isEmpty(entry.number);
-        boolean labelEmpty = TextUtils.isEmpty(entry.label) || numberEmpty;
-        if (labelEmpty && numberEmpty) {
-            line2.setVisibility(View.GONE);
+        TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
+        if (TextUtils.isEmpty(entry.label)) {
+            label.setVisibility(View.GONE);
         } else {
-            line2.setVisibility(View.VISIBLE);
-
-            TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
-            if (labelEmpty) {
-                label.setVisibility(View.GONE);
-            } else {
-                label.setText(entry.label);
-                label.setVisibility(View.VISIBLE);
-            }
-
-            TextView number = (TextView) convertView.findViewById(R.id.call_and_sms_number);
-            number.setText(entry.number);
+            label.setText(entry.label);
+            label.setVisibility(View.VISIBLE);
         }
     }