Add the option to disable the contact details header

An OEM is trying to remove the contact details header by
making all the views in it have visibility GONE, but
there is currently a bug in recyclerview (b/165334939)
where doing that causes the scrollbar to not go all the
way up to the top of the screen.

As a workaround, add a boolean to disable the header.

Fixes: 164160249
Test: Manually
Change-Id: Ifb51aa9282f2346c074a3d7ecb6ac327d8b5e13e
diff --git a/res/values/configs.xml b/res/values/configs.xml
index 123b867..8ff5979 100644
--- a/res/values/configs.xml
+++ b/res/values/configs.xml
@@ -34,6 +34,8 @@
     will make divider and button invisible for empty contacts. -->
     <bool name="config_show_contact_detail_button_for_empty_contact">false</bool>
 
+    <!-- A config determines whether to show the header with an avatar and contact name in the contact details page. -->
+    <bool name="config_show_contact_details_header">true</bool>
     <!-- A config determines whether to show postal address in contact details page. -->
     <bool name="config_show_postal_address">true</bool>
     <!-- A config determines whether to show the action bar view in the contact details page.-->
diff --git a/src/com/android/car/dialer/ui/contact/ContactDetailsAdapter.java b/src/com/android/car/dialer/ui/contact/ContactDetailsAdapter.java
index bd3fe20..19deb38 100644
--- a/src/com/android/car/dialer/ui/contact/ContactDetailsAdapter.java
+++ b/src/com/android/car/dialer/ui/contact/ContactDetailsAdapter.java
@@ -64,7 +64,14 @@
         L.d(TAG, "setContact %s", contact);
         mContact = contact;
         mItems.clear();
-        mItems.add(contact);
+
+        boolean showHeader = mContext.getResources()
+                .getBoolean(R.bool.config_show_contact_details_header);
+
+        if (showHeader || contact == null) {
+            // We add null contacts to display an error message
+            mItems.add(contact);
+        }
         if (contact != null) {
             mItems.addAll(contact.getNumbers());
             if (mContext.getResources().getBoolean(R.bool.config_show_postal_address)) {