Update empty list assets and text.

- Add new assets for empty lists, delete old no favorites banner.
- Adapt phone_no_favorites.xml into generic container shown when
a list is empty.
- Add helper to DialerUtils to configure empty list view with
a provided image and message.
- Configure empty list view in relevant fragments.
- Some text styling/margin/padding to get things to spec. A
minimum height is used on the message so that the icons and text
will be laid out in a consistent manner.

Bug: 15513399
Change-Id: I52337a4544065a991d3b8084d96b01516a458c42
diff --git a/res/drawable-hdpi/empty_call_log.png b/res/drawable-hdpi/empty_call_log.png
new file mode 100644
index 0000000..d6f6daa
--- /dev/null
+++ b/res/drawable-hdpi/empty_call_log.png
Binary files differ
diff --git a/res/drawable-hdpi/empty_contacts.png b/res/drawable-hdpi/empty_contacts.png
new file mode 100644
index 0000000..d3c0378
--- /dev/null
+++ b/res/drawable-hdpi/empty_contacts.png
Binary files differ
diff --git a/res/drawable-hdpi/empty_speed_dial.png b/res/drawable-hdpi/empty_speed_dial.png
new file mode 100644
index 0000000..3e9232f
--- /dev/null
+++ b/res/drawable-hdpi/empty_speed_dial.png
Binary files differ
diff --git a/res/drawable-hdpi/no_favorites_banner.png b/res/drawable-hdpi/no_favorites_banner.png
deleted file mode 100644
index a4b09c0..0000000
--- a/res/drawable-hdpi/no_favorites_banner.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/empty_call_log.png b/res/drawable-mdpi/empty_call_log.png
new file mode 100644
index 0000000..3cd59b3
--- /dev/null
+++ b/res/drawable-mdpi/empty_call_log.png
Binary files differ
diff --git a/res/drawable-mdpi/empty_contacts.png b/res/drawable-mdpi/empty_contacts.png
new file mode 100644
index 0000000..2ce7eae
--- /dev/null
+++ b/res/drawable-mdpi/empty_contacts.png
Binary files differ
diff --git a/res/drawable-mdpi/empty_speed_dial.png b/res/drawable-mdpi/empty_speed_dial.png
new file mode 100644
index 0000000..98152e0
--- /dev/null
+++ b/res/drawable-mdpi/empty_speed_dial.png
Binary files differ
diff --git a/res/drawable-mdpi/no_favorites_banner.png b/res/drawable-mdpi/no_favorites_banner.png
deleted file mode 100644
index ac080b9..0000000
--- a/res/drawable-mdpi/no_favorites_banner.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/empty_call_log.png b/res/drawable-xhdpi/empty_call_log.png
new file mode 100644
index 0000000..14ec04b
--- /dev/null
+++ b/res/drawable-xhdpi/empty_call_log.png
Binary files differ
diff --git a/res/drawable-xhdpi/empty_contacts.png b/res/drawable-xhdpi/empty_contacts.png
new file mode 100644
index 0000000..65b1de3
--- /dev/null
+++ b/res/drawable-xhdpi/empty_contacts.png
Binary files differ
diff --git a/res/drawable-xhdpi/empty_speed_dial.png b/res/drawable-xhdpi/empty_speed_dial.png
new file mode 100644
index 0000000..a3a7675
--- /dev/null
+++ b/res/drawable-xhdpi/empty_speed_dial.png
Binary files differ
diff --git a/res/drawable-xhdpi/no_favorites_banner.png b/res/drawable-xhdpi/no_favorites_banner.png
deleted file mode 100644
index bae4e99..0000000
--- a/res/drawable-xhdpi/no_favorites_banner.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/empty_call_log.png b/res/drawable-xxhdpi/empty_call_log.png
new file mode 100644
index 0000000..501d7f1
--- /dev/null
+++ b/res/drawable-xxhdpi/empty_call_log.png
Binary files differ
diff --git a/res/drawable-xxhdpi/empty_contacts.png b/res/drawable-xxhdpi/empty_contacts.png
new file mode 100644
index 0000000..407d78c
--- /dev/null
+++ b/res/drawable-xxhdpi/empty_contacts.png
Binary files differ
diff --git a/res/drawable-xxhdpi/empty_speed_dial.png b/res/drawable-xxhdpi/empty_speed_dial.png
new file mode 100644
index 0000000..fb2ea5f
--- /dev/null
+++ b/res/drawable-xxhdpi/empty_speed_dial.png
Binary files differ
diff --git a/res/drawable-xxhdpi/no_favorites_banner.png b/res/drawable-xxhdpi/no_favorites_banner.png
deleted file mode 100644
index 0e2a4fa..0000000
--- a/res/drawable-xxhdpi/no_favorites_banner.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/call_log_fragment.xml b/res/layout/call_log_fragment.xml
index fb7ed2a..bb50730 100644
--- a/res/layout/call_log_fragment.xml
+++ b/res/layout/call_log_fragment.xml
@@ -72,14 +72,14 @@
             android:divider="@null"
             android:nestedScrollingEnabled="true"
         />
-        <TextView android:id="@android:id/empty"
+
+        <include
+            android:id="@+id/empty_list_view"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:text="@string/recentCalls_empty"
-            android:gravity="center"
-            android:layout_marginTop="@dimen/empty_message_top_margin"
-            android:textColor="?android:attr/textColorSecondary"
-            android:textAppearance="?android:attr/textAppearanceLarge"
-        />
+            layout="@layout/empty_list_view"
+            android:visibility="gone"/>
+
     </FrameLayout>
+
 </LinearLayout>
diff --git a/res/layout/phone_no_favorites.xml b/res/layout/empty_list_view.xml
similarity index 71%
rename from res/layout/phone_no_favorites.xml
rename to res/layout/empty_list_view.xml
index b95afd1..be4dbf5 100644
--- a/res/layout/phone_no_favorites.xml
+++ b/res/layout/empty_list_view.xml
@@ -30,28 +30,27 @@
         android:layout_alignParentStart="true"/>
 
     <LinearLayout
-        android:id="@+id/nofavorite_frame"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
-        android:gravity="center"
-        android:layout_centerInParent="true">
+        android:paddingBottom="@dimen/actionbar_and_tab_height"
+        android:layout_centerInParent="true" >
+
         <ImageView
-            android:id="@+id/nofavorite_image"
+            android:id="@+id/emptyListViewImage"
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
-            android:gravity="center_horizontal"
-            android:src="@drawable/no_favorites_banner"
-            android:layout_marginBottom="14dp"
-            android:contentDescription="@string/no_favorites"/>
+            android:gravity="center_horizontal" />
+
         <TextView
-            android:id="@+id/title"
+            android:id="@+id/emptyListViewMessage"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:gravity="center_horizontal"
-            android:text="@string/no_favorites"
-            android:textAppearance="?android:attr/textAppearanceLarge"
-            android:textColor="@color/nofavorite_text_color"/>
+            android:minHeight="84dp"
+            android:gravity="center_horizontal|top"
+            android:textSize="@dimen/empty_list_message_text_size"
+            android:textColor="@color/empty_list_text_color" />
+
     </LinearLayout>
 
 </RelativeLayout>
diff --git a/res/layout/show_all_contacts_fragment.xml b/res/layout/show_all_contacts_fragment.xml
index 91fb322..fe188bd 100644
--- a/res/layout/show_all_contacts_fragment.xml
+++ b/res/layout/show_all_contacts_fragment.xml
@@ -46,4 +46,11 @@
             android:nestedScrollingEnabled="true" />
     </FrameLayout>
 
+    <include
+        android:id="@+id/empty_list_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        layout="@layout/empty_list_view"
+        android:visibility="gone"/>
+
 </LinearLayout>
diff --git a/res/layout/speeddial_fragment.xml b/res/layout/speeddial_fragment.xml
index f025e61..58a7b24 100644
--- a/res/layout/speeddial_fragment.xml
+++ b/res/layout/speeddial_fragment.xml
@@ -45,13 +45,10 @@
     </FrameLayout>
 
     <include
-        android:id="@+id/phone_no_favorites_view"
+        android:id="@+id/empty_list_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_below="@id/contact_tile_frame"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true"
-        android:layout_alignParentBottom="true"
-        layout="@layout/phone_no_favorites"
+        layout="@layout/empty_list_view"
         android:visibility="gone"/>
+
 </RelativeLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9264e30..2bc1b57 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -69,8 +69,7 @@
     <!-- Undo dialogue color -->
     <color name="undo_dialogue_text_color">#4d4d4d</color>
 
-    <!-- Text color for no favorites message -->
-    <color name="nofavorite_text_color">#777777</color>
+    <color name="empty_list_text_color">#b2b2b2</color>
 
     <color name="remove_text_color">#ffffff</color>
 
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 3533abd..a01be9c 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -96,6 +96,10 @@
     <!-- Height of the actionBar - this is 8dps bigger than the platform standard to give more
     room to the search box-->
     <dimen name="action_bar_height">64dp</dimen>
+    <dimen name="tab_height">43dp</dimen>
+    <dimen name="tab_elevation">2dp</dimen>
+    <!-- actionbar height + tab height -->
+    <dimen name="actionbar_and_tab_height">107dp</dimen>
 
     <!-- Margin to the left and right of the search box. -->
     <dimen name="search_margin_horizontal">8dp</dimen>
@@ -119,10 +123,6 @@
     <dimen name="search_list_padding_top">8dp</dimen>
     <dimen name="search_box_elevation">2dp</dimen>
 
-    <!-- Size of text in tabs. -->
-    <dimen name="tab_height">43dp</dimen>
-    <dimen name="tab_elevation">2dp</dimen>
-
     <!-- Padding to the left and right of call log action buttons. -->
     <dimen name="call_log_action_horizontal_padding">8dp</dimen>
     <!-- Left-padding for the call log action buttons - ensures the buttons align with the text
@@ -141,4 +141,6 @@
 
     <!-- Size of icon for contacts number shortcuts -->
     <dimen name="search_shortcut_radius">40dp</dimen>
+
+    <dimen name="empty_list_message_text_size">16sp</dimen>
 </resources>
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index ad86e24..4f5c355 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -40,6 +40,7 @@
 import android.view.ViewTreeObserver;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup.LayoutParams;
+import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
 
@@ -50,6 +51,7 @@
 import com.android.contacts.common.util.ViewUtil;
 import com.android.dialer.R;
 import com.android.dialer.list.ListsFragment.HostInterface;
+import com.android.dialer.util.DialerUtils;
 import com.android.dialer.util.EmptyLoader;
 import com.android.dialer.voicemail.VoicemailStatusHelper;
 import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage;
@@ -298,9 +300,11 @@
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
-        updateEmptyMessage(mCallTypeFilter);
+        getListView().setEmptyView(view.findViewById(R.id.empty_list_view));
         getListView().setItemsCanFocus(true);
         maybeAddFooterView();
+
+        updateEmptyMessage(mCallTypeFilter);
     }
 
     /**
@@ -413,22 +417,23 @@
     }
 
     private void updateEmptyMessage(int filterType) {
-        final String message;
+        final int messageId;
         switch (filterType) {
             case Calls.MISSED_TYPE:
-                message = getString(R.string.recentMissed_empty);
+                messageId = R.string.recentMissed_empty;
                 break;
             case Calls.VOICEMAIL_TYPE:
-                message = getString(R.string.recentVoicemails_empty);
+                messageId = R.string.recentVoicemails_empty;
                 break;
             case CallLogQueryHandler.CALL_TYPE_ALL:
-                message = getString(R.string.recentCalls_empty);
+                messageId = R.string.recentCalls_empty;
                 break;
             default:
                 throw new IllegalArgumentException("Unexpected filter type in CallLogFragment: "
                         + filterType);
         }
-        ((TextView) getListView().getEmptyView()).setText(message);
+        DialerUtils.configureEmptyListView(
+                getListView().getEmptyView(), R.drawable.empty_call_log, messageId, getResources());
     }
 
     public void callSelectedEntry() {
diff --git a/src/com/android/dialer/list/AllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java
index a796680..ddcb15d 100644
--- a/src/com/android/dialer/list/AllContactsFragment.java
+++ b/src/com/android/dialer/list/AllContactsFragment.java
@@ -23,8 +23,6 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
-import android.widget.ListView;
-import android.widget.QuickContactBadge;
 
 import com.android.contacts.common.list.ContactEntryListAdapter;
 import com.android.contacts.common.list.ContactEntryListFragment;
@@ -32,6 +30,7 @@
 import com.android.contacts.common.list.DefaultContactListAdapter;
 import com.android.contacts.common.util.ViewUtil;
 import com.android.dialer.R;
+import com.android.dialer.util.DialerUtils;
 
 /**
  * Fragments to show all contacts with phone numbers.
@@ -50,6 +49,12 @@
     @Override
     public void onViewCreated(View view, android.os.Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
+
+        View emptyListView = view.findViewById(R.id.empty_list_view);
+        DialerUtils.configureEmptyListView(emptyListView, R.drawable.empty_contacts,
+                R.string.listFoundAllContactsZero, getResources());
+        getListView().setEmptyView(emptyListView);
+
         ViewUtil.addBottomPaddingToListViewForFab(getListView(), getResources());
     }
 
diff --git a/src/com/android/dialer/list/SpeedDialFragment.java b/src/com/android/dialer/list/SpeedDialFragment.java
index 6e86a3e..c214492 100644
--- a/src/com/android/dialer/list/SpeedDialFragment.java
+++ b/src/com/android/dialer/list/SpeedDialFragment.java
@@ -23,6 +23,7 @@
 import android.app.LoaderManager;
 import android.content.CursorLoader;
 import android.content.Loader;
+import android.content.res.Resources;
 import android.database.Cursor;
 import android.graphics.Rect;
 import android.net.Uri;
@@ -47,6 +48,7 @@
 import com.android.contacts.common.list.ContactTileView;
 import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
 import com.android.dialer.R;
+import com.android.dialer.util.DialerUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -208,7 +210,10 @@
                 (ImageView) getActivity().findViewById(R.id.contact_tile_drag_shadow_overlay);
         mListView.setDragShadowOverlay(dragShadowOverlay);
 
-        mEmptyView = mParentView.findViewById(R.id.phone_no_favorites_view);
+        final Resources resources = getResources();
+        mEmptyView = mParentView.findViewById(R.id.empty_list_view);
+        DialerUtils.configureEmptyListView(
+                mEmptyView, R.drawable.empty_speed_dial, R.string.no_favorites, getResources());
 
         mContactTileFrame = mParentView.findViewById(R.id.contact_tile_frame);
 
diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java
index 584caa9..f1dfe20 100644
--- a/src/com/android/dialer/util/DialerUtils.java
+++ b/src/com/android/dialer/util/DialerUtils.java
@@ -21,8 +21,12 @@
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
 import android.net.Uri;
 import android.provider.Telephony;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.android.contacts.common.CallUtil;
@@ -82,4 +86,25 @@
         }
         return null;
     }
+
+    /**
+     * Sets the image asset and text for an empty list view (see empty_list_view.xml).
+     *
+     * @param emptyListView The empty list view.
+     * @param imageResId The resource id for the drawable to set as the image.
+     * @param strResId The resource id for the string to set as the message.
+     * @param res The resources to obtain the image and string from.
+     */
+    public static void configureEmptyListView(
+            View emptyListView, int imageResId, int strResId, Resources res) {
+        ImageView emptyListViewImage =
+                (ImageView) emptyListView.findViewById(R.id.emptyListViewImage);
+
+        emptyListViewImage.setImageDrawable(res.getDrawable(imageResId));
+        emptyListViewImage.setContentDescription(res.getString(strResId));
+
+        TextView emptyListViewMessage =
+                (TextView) emptyListView.findViewById(R.id.emptyListViewMessage);
+        emptyListViewMessage.setText(res.getString(strResId));
+    }
 }