Clean up contact details page.

No short screen any more. Always use the specs for standard screen.
Keep the action bar view for Volvo's customization where Volvo needs to
override the config value to be true.

Fixes: 138733336
Test: manually
Change-Id: I9d368246569cae5589842b02736c3b42aa4c91fa
diff --git a/res/layout-h610dp/contact_details_action_bar.xml b/res/layout-h610dp/contact_details_action_bar.xml
deleted file mode 100644
index d077bbe..0000000
--- a/res/layout-h610dp/contact_details_action_bar.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<Space
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content">
-</Space>
\ No newline at end of file
diff --git a/res/layout-h610dp/contact_details_name_image.xml b/res/layout-h610dp/contact_details_name_image.xml
deleted file mode 100644
index 970faad..0000000
--- a/res/layout-h610dp/contact_details_name_image.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2019 The Android Open Source Project
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-<androidx.constraintlayout.widget.ConstraintLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
-    <com.android.car.apps.common.BackgroundImageView
-        android:id="@+id/background_image"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:visibility="gone"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintBottom_toBottomOf="parent"/>
-
-    <ImageView
-        android:id="@+id/avatar"
-        android:layout_width="@dimen/contact_details_avatar_size"
-        android:layout_height="@dimen/contact_details_avatar_size"
-        android:layout_marginTop="@dimen/contact_details_avatar_margin_top"
-        app:layout_constraintVertical_chainStyle="packed"
-        app:layout_constraintBottom_toTopOf="@+id/title"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="parent"/>
-
-    <TextView
-        android:id="@id/title"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:singleLine="true"
-        android:layout_marginTop="@dimen/contact_details_title_margin_top"
-        android:layout_marginBottom="@dimen/contact_details_title_margin_bottom"
-        android:textAppearance="@style/TextAppearance.ContactDetailsTitle"
-        app:layout_constraintTop_toBottomOf="@id/avatar"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"/>
-</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/contact_details_action_bar.xml b/res/layout/contact_details_action_bar.xml
index 59ad063..c874913 100644
--- a/res/layout/contact_details_action_bar.xml
+++ b/res/layout/contact_details_action_bar.xml
@@ -23,8 +23,8 @@
 
     <ImageView
         android:id="@+id/contact_details_action_bar_avatar"
-        android:layout_height="@dimen/contact_details_avatar_size"
-        android:layout_width="@dimen/contact_details_avatar_size"/>
+        android:layout_height="@dimen/contact_details_action_bar_avatar_size"
+        android:layout_width="@dimen/contact_details_action_bar_avatar_size"/>
 
     <TextView
         android:id="@+id/contact_details_action_bar_name"
diff --git a/res/layout/contact_details_name_image.xml b/res/layout/contact_details_name_image.xml
index f03f093..970faad 100644
--- a/res/layout/contact_details_name_image.xml
+++ b/res/layout/contact_details_name_image.xml
@@ -14,8 +14,41 @@
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
-
-<Space
+<androidx.constraintlayout.widget.ConstraintLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"/>
+    android:layout_height="wrap_content">
+
+    <com.android.car.apps.common.BackgroundImageView
+        android:id="@+id/background_image"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:visibility="gone"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"/>
+
+    <ImageView
+        android:id="@+id/avatar"
+        android:layout_width="@dimen/contact_details_avatar_size"
+        android:layout_height="@dimen/contact_details_avatar_size"
+        android:layout_marginTop="@dimen/contact_details_avatar_margin_top"
+        app:layout_constraintVertical_chainStyle="packed"
+        app:layout_constraintBottom_toTopOf="@+id/title"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"/>
+
+    <TextView
+        android:id="@id/title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:singleLine="true"
+        android:layout_marginTop="@dimen/contact_details_title_margin_top"
+        android:layout_marginBottom="@dimen/contact_details_title_margin_bottom"
+        android:textAppearance="@style/TextAppearance.ContactDetailsTitle"
+        app:layout_constraintTop_toBottomOf="@id/avatar"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"/>
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/values-h1200dp/bools.xml b/res/values-h1200dp/bools.xml
deleted file mode 100644
index b737bbc..0000000
--- a/res/values-h1200dp/bools.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2019 The Android Open Source Project
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-
-<resources>
-    <bool name="screen_size_tall">true</bool>
-</resources>
diff --git a/res/values-h1200dp/dimens.xml b/res/values-h1200dp/dimens.xml
index 9842357..b4b512f 100644
--- a/res/values-h1200dp/dimens.xml
+++ b/res/values-h1200dp/dimens.xml
@@ -20,6 +20,4 @@
     <dimen name="keypad_margin_x">48dp</dimen>
     <dimen name="keypad_margin_y">@*android:dimen/car_padding_4</dimen>
     <dimen name="keypad_margin">@*android:dimen/car_padding_6</dimen>
-
-    <dimen name="contact_details_title_margin_bottom">@*android:dimen/car_padding_5</dimen>
 </resources>
diff --git a/res/values-h610dp/bools.xml b/res/values-h610dp/bools.xml
deleted file mode 100644
index ab691bc..0000000
--- a/res/values-h610dp/bools.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2019 The Android Open Source Project
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-
-<resources>
-    <bool name="screen_size_short">false</bool>
-</resources>
diff --git a/res/values-h610dp/dimens.xml b/res/values-h610dp/dimens.xml
index 9dba83d..23a9548 100644
--- a/res/values-h610dp/dimens.xml
+++ b/res/values-h610dp/dimens.xml
@@ -27,8 +27,6 @@
     <dimen name="fab_outline_size">104dp</dimen>
     <dimen name="fab_ripple_radius">52dp</dimen>
 
-    <dimen name="contact_details_avatar_size">126dp</dimen>
-
     <!-- Components -->
     <dimen name="control_bar_height">128dp</dimen>
 </resources>
diff --git a/res/values/bools.xml b/res/values/bools.xml
deleted file mode 100644
index 6cc068d..0000000
--- a/res/values/bools.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<resources>
-    <bool name="screen_size_short">true</bool>
-    <bool name="screen_size_tall">false</bool>
-</resources>
\ No newline at end of file
diff --git a/res/values/configs.xml b/res/values/configs.xml
index 204437b..531b0fd 100644
--- a/res/values/configs.xml
+++ b/res/values/configs.xml
@@ -30,4 +30,7 @@
     that are not stored as contacts. "true" will show divider and button as disable state and
     "false" will make divider and button invisible for non contacts. -->
     <bool name="config_show_calllog_action_button_for_non_contact">false</bool>
+
+    <!-- A config determines if to show the action bar view in the contact details page.-->
+    <bool name="config_show_contact_details_action_bar_view">false</bool>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 3bf7713..83da788 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -37,12 +37,13 @@
     <!-- Contact details dimensions -->
     <dimen name="contact_details_avatar_margin_top">@*android:dimen/car_padding_4</dimen>
     <dimen name="contact_details_title_margin_top">@*android:dimen/car_padding_4</dimen>
-    <dimen name="contact_details_title_margin_bottom">48dp</dimen>
-    <dimen name="contact_details_avatar_size">@dimen/primary_icon_size</dimen>
+    <dimen name="contact_details_title_margin_bottom">@*android:dimen/car_padding_5</dimen>
+    <dimen name="contact_details_avatar_size">126dp</dimen>
     <dimen name="contact_details_item_height">@dimen/list_item_height</dimen>
     <dimen name="contact_details_number_padding_start">@*android:dimen/car_keyline_1</dimen>
     <dimen name="contact_details_number_padding_end">@*android:dimen/car_padding_2</dimen>
     <dimen name="contact_details_text_button_guideline">@*android:dimen/car_keyline_3</dimen>
+    <dimen name="contact_details_action_bar_avatar_size">@dimen/primary_icon_size</dimen>
     <dimen name="contact_details_action_bar_name_margin">@*android:dimen/car_padding_2</dimen>
 
     <!-- Contact list dimensions -->
diff --git a/src/com/android/car/dialer/ui/common/DialerUtils.java b/src/com/android/car/dialer/ui/common/DialerUtils.java
index c4c191e..c6cc857 100644
--- a/src/com/android/car/dialer/ui/common/DialerUtils.java
+++ b/src/com/android/car/dialer/ui/common/DialerUtils.java
@@ -18,7 +18,6 @@
 
 import android.app.AlertDialog;
 import android.content.Context;
-import android.content.res.Resources;
 
 import com.android.car.dialer.R;
 import com.android.car.dialer.log.L;
@@ -107,16 +106,4 @@
             L.w(TAG, "contact %s doesn't have any phone number", contact.getDisplayName());
         }
     }
-
-    /** Returns true if this a short height screen */
-    public static boolean isShortScreen(Context context) {
-        Resources resources = context.getResources();
-        return resources.getBoolean(R.bool.screen_size_short);
-    }
-
-    /** Returns true if this a tall height screen */
-    public static boolean isTallScreen(Context context) {
-        Resources resources = context.getResources();
-        return resources.getBoolean(R.bool.screen_size_tall);
-    }
 }
diff --git a/src/com/android/car/dialer/ui/contact/ContactDetailsFragment.java b/src/com/android/car/dialer/ui/contact/ContactDetailsFragment.java
index e6b7101..a1f1ad5 100644
--- a/src/com/android/car/dialer/ui/contact/ContactDetailsFragment.java
+++ b/src/com/android/car/dialer/ui/contact/ContactDetailsFragment.java
@@ -31,7 +31,6 @@
 import com.android.car.arch.common.FutureData;
 import com.android.car.dialer.R;
 import com.android.car.dialer.ui.common.DialerListBaseFragment;
-import com.android.car.dialer.ui.common.DialerUtils;
 import com.android.car.dialer.ui.view.ContactAvatarOutputlineProvider;
 import com.android.car.telephony.common.Contact;
 import com.android.car.telephony.common.PhoneNumber;
@@ -52,10 +51,12 @@
 
     private Contact mContact;
     private LiveData<FutureData<Contact>> mContactDetailsLiveData;
+    private ContactDetailsViewModel mContactDetailsViewModel;
+
+    private boolean mShowActionBarView;
     private View mActionBarView;
     private ImageView mAvatarView;
     private TextView mNameView;
-    private ContactDetailsViewModel mContactDetailsViewModel;
 
     /** Creates a new ContactDetailsFragment using a {@link Contact}. */
     public static ContactDetailsFragment newInstance(Contact contact) {
@@ -79,6 +80,8 @@
                 ContactDetailsViewModel.class);
         mContactDetailsLiveData = mContactDetailsViewModel.getContactDetails(mContact);
 
+        mShowActionBarView = getResources().getBoolean(
+                R.bool.config_show_contact_details_action_bar_view);
         mActionBarView = LayoutInflater.from(getContext()).inflate(
                 R.layout.contact_details_action_bar, null);
         mAvatarView = mActionBarView.findViewById(R.id.contact_details_action_bar_avatar);
@@ -96,7 +99,7 @@
         ContactDetailsAdapter contactDetailsAdapter = new ContactDetailsAdapter(getContext(),
                 mContact, this);
         getRecyclerView().setAdapter(contactDetailsAdapter);
-        if (!DialerUtils.isShortScreen(getContext())) {
+        if (mShowActionBarView) {
             getRecyclerView().setScrollBarPadding(getTopBarHeight(), 0);
         }
         mContactDetailsLiveData.observe(this, contact -> {
@@ -128,19 +131,18 @@
 
     @Override
     public void setupActionBar(@NonNull ActionBar actionBar) {
-        actionBar.setCustomView(mActionBarView);
+        actionBar.setCustomView(mShowActionBarView ? mActionBarView : null);
         actionBar.setTitle(null);
 
-        // Remove the action bar background on non-short screens
-        // On short screens the avatar and name is in the action bar so we keep it
-        if (mAvatarView == null) {
+        // Remove the action bar background if the action bar view is not shown.
+        if (!mShowActionBarView) {
             setActionBarBackground(null);
         }
     }
 
     @Override
     protected int getTopOffset() {
-        if (DialerUtils.isShortScreen(getContext())) {
+        if (mShowActionBarView) {
             return super.getTopOffset();
         } else {
             return 0;